• 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

Passing values across pages for that session/user

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

I'm developing a web-based app using Struts. My first page is a Category selection screen. I have created Action and ActionForm classes for this page and added entries in struts-config.xml. This part is working fine. The next page will be Parameters selection screen. I still need to create Action and ActionForm classes for this page. One thing I'm not able to find out is how do I pass the values from one page to another ? For instance how does Parameters selection screen will get the value selected in Category selection screen ? I'm thinking of using

* another bean class to store all variables
* using session varibale

But not sure what's the best option. Really appreciate any suggestions.

Thanks much.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why dont you use the same Action form for both screens.

All the form elements that are required in both these screens Category selection screen and Parameters selection screen can be made part of the same ActionForm.

The in the struts-config, define the scope of the bean as "session".

Then when you come to Parameters selection screen, the values selected in the Category selection screen will still be available in the ActionForm.

Let me know if you need more Explaination

--IshAsh
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You do not have to use session scoped forms to solve this issue if you do not want to. I would probably code this up to use a single form bean that both pages would use. When you submit the first page, the submitted category selected value will be populated on the form and available to the second page. If you need to maintain this value, then store it as a hidden field on the second jsp. Then when the second page is submitted, you will have both the selected category and parameter.

- Brent
reply
    Bookmark Topic Watch Topic
  • New Topic