• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retrieving values of the Previous page in Struts

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I got stuck with a very simple logic. This is explained below.
I have 3 JSP pages. Page 1 has a hyperlink which takes you to Page 2.Page 2 has a 'Next' button which takes you to Page 3. Now Page 3 again has 'Cancel','Previous' and 'Next' buttons.Clicking on Cancel shud take you to Page 2 with the default values of input fields whereas a Previous button should take you to Page 2 with the User settings restored(the input fields you wud have selected in Page 2).
My approach for the same is :
Clicking on a cancel button invlkes the below method.

function cancel_action()
{
document.form.hdnAction.value ="cancel";

document.form.action = "ShowPage2.do";

document.form.submit();
}

Clicking on Previous button wud invoke the below method .

function previous_action()
{
document.form.hdnAction.value = "previous";

document.form.action ="ShowPage2.do";

document.form.submit();
}

In my Action Class, i wud check for this 'hdnAction' and if its 'cancel' , i wud clear the remove the values stored in the session(so as to show the default values).
And in my Struts-config.xml , I wud set the scope of my action as 'session'

<action path="/ ShowPage2 " type="qualifiedpath.myAction"
input="/jsp/ Page1.jsp" scope="session">
<forward name="success" path="/jsp/../Page2jsp" />
</forward>
</action>

Will this suffice ? Am i missing something?

Thanks in Advance,
Priya
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See keep the data in session scope(i mean form data) and as soon as cancle is clicked from 3 rd jsp invoke the earlier jsp directly and if u have used struts tag libraries then the data will b automatically populated

but if u want to call a action u can do that also and there is no need to check whether cacel is clicked r not because clicking cancel in 3 rd jsp will be same as clicking next in 2 nd jsp .....so reuse the actions
reply
    Bookmark Topic Watch Topic
  • New Topic