Avatar billede fredand Forsker
09. juli 2009 - 09:23 Der er 5 kommentarer og
1 løsning

How to tell from what request user comming from (in this situation)?

Hello!

I got a problem to find out a solution to this problem.

Let me first describe the "environment".
I got a webapp in struts, that we should redesign.

The webapp got a menu that follows every page (no frames, hiermenus.js).
From the menu the user can access page search.jsp, a path through the struts framework.

The search.jsp contains a form.
When submitting the form a page result.jsp shows.

(The menu is visible all the time)

At the result page there is also a back-button, back to the search.jsp.
This back button is used at many places in the webapp and use javascript with history.back().

The struts setup looks like:
<!--Entry to the search form-->
<action    path="/Search"
              type="myapp.SearchAction"
              name="SearchForm"
              scope="session"
              validate="false">
      <forward name="Result" path="/search.jsp"/>
    </action>
   
<!--Entry to the result page-->
    <action    path="/Result"
              type="myapp.SearchAction"
              name="SearchForm"
              scope="session"
              validate="true">
      <forward name="success" path="/result.jsp"/>
      <forward name="failed" path="/search.jsp"/>
      <forward name="nohit" path="/search.jsp"/>
    </action>

My conclusion between the menu and the back button is that the request is always the same.


The task is that if the user enter the the search from the menu (at any time), the search-form should be "empty".
If the user enters the search form from the back button (history.back()) the search-form should be populated with
previous data.

The problem is then how can I differentiate the request from the menu versus the back-button?

If I can determine the request I can remove the form from the session in the ActionClass before returning the search form.

I have created a sketch that I hope you can access and see:
http://eunywq.blu.livefilestore.com/y1p2ScdmAKhhAC0dFk2IDmnEbrhj-6F2n0Lod37DtyA-RMJvfuNCLF4nLxB3tHgiIp_LAyZZS7RrxrGqcKUiRIkNY09yR_evRVJ/search.png


Any ideas are most welcome!

Best regards
Fredrik
Avatar billede fredand Forsker
09. juli 2009 - 20:35 #1
Hello guys!

I'm leaning towords to get rid of the use of "history.back()".

I will try it out tomorrow!

Best regards
Fredrik
Avatar billede arne_v Ekspert
10. juli 2009 - 03:40 #2
You let the search page fill out a default value or not.

It set it based on a value stored in session.

That value gets cleared by the action executed when clicking search in menu.
Avatar billede arne_v Ekspert
10. juli 2009 - 03:41 #3
If you change the JavaScript back via history to also call Struts, then you have a bunch of additional possibilities.
Avatar billede arne_v Ekspert
22. august 2009 - 18:09 #4
fredand?
Avatar billede fredand Forsker
25. august 2009 - 08:54 #5
Hola Amigo!

Thanks for the replies!

Please give a svar!

The solution that we used is based on a value in the session and upon that value is then set into the request.

Something like:
<A id="goback" href="java script:goback('<%= session.getAttribute("FROM_MARKER") %>')"><IMG border=0 src=images/tillbaka.gif></A>&#8207;

We then could find out from where we came from (our own backbutton or the browserbutton).

Best regards
Fredrik
Avatar billede arne_v Ekspert
26. august 2009 - 00:25 #6
ok
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester