Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Passing values across pages for that session/user

Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • 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.
Posts: 3
  • Mark post as helpful
  • send pies
  • 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

Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • 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
    Bookmark Topic Watch Topic
  • New Topic