• 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

Struts2 parameters between actions

 
Greenhorn
Posts: 5
Mac Netbeans IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone, i'm new in Struts2 and i'm trying to create a web-app where the user can create a contest, registering name, date, number of contestants and jurymen, after compiling that form i need to pass the contestants and jurymen parameters to the next action in order to make a form for the contestants registration with the contestant and jury data (first name, last name, age etc...). i tried with this code looking around on the web:


struts.xml


InsertContest.java



InsertContestants.java



Can anyone explain me where I am wrong, it will be very usefull
thanks in advance
 
Ranch Hand
Posts: 213
Eclipse IDE Tomcat Server Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Redirects go to actions, not JSP pages.
 
Filippo Galante
Greenhorn
Posts: 5
Mac Netbeans IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Richard Golebiowski wrote:Redirects go to actions, not JSP pages.



Thank you for the answer... But as I said i'm new in struts... can you please be a little more specific?
 
Ranch Hand
Posts: 440
Hibernate Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings Filippo and welcome to the ranch :-)

I was going through the files you have provided and saw that you are Re-Directing to a jsp page as follows. Redirection works with action only as Richard said


If you need to open a JSP page that will be the input page , then just use result type = "success" . The params will be there already on the valuestack and you should be able to access them with the OGNL notation ${name} . Be sure to write the appropriate getter/setters before opening the input jsp page to push the params on the valuestack
 
Filippo Galante
Greenhorn
Posts: 5
Mac Netbeans IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So i need to create the contestants and jurymen setter/getter also in the next action?

Thanks for your patience...
 
Saif Asif
Ranch Hand
Posts: 440
Hibernate Eclipse IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Getter/setters should be in the next action also . This way you can make the param available in each action class.

The value stack is a wonderful feature of the struts2 framework. Do Take a look at its details when you get time here and also here
 
Filippo Galante
Greenhorn
Posts: 5
Mac Netbeans IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've found what i was looking for here!

The scope interceptor can be used to pass arbitrary objects from one action ActionA to another other ActionB, provided you have a getter in ActionA and and a similar setter in actionB. Also, you should use a key parameter to make sure you tell ASF/WW which action gets which objects. This allows you to mix several actions with several scopes, without running the risk of getting wrong objects.



 
Saif Asif
Ranch Hand
Posts: 440
Hibernate Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad you were able to solve your issue :-)
 
reply
    Bookmark Topic Watch Topic
  • New Topic