• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get s:hidden value to java class  RSS feed

 
kajal mukergi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends

i have one jsp called x.jsp and i that i have hidden variable as follows

<s:hidden name="xyz" value="%{x.y}"/>

when i have seen the "view source" i am getting the value here

Now i moving to other y.jsp by hitting the submit button in the x.jsp file

and i that Hidden.java action class(java class) i have kept getter and setter for this hidden variable "xyz"


and in y.jsp i have kept the hidden variable.

like this

<s:hidden name="xyz"/>

Problem.

1. i am not able to get the value of hidden variable in x.jsp to Hidden.java class (only the getter of xyz variable is been called and setter are not called at all when i tried to debug.).

2. if i will get the value to Hidden.java then how to send this.. next y.jsp file.
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. This sounds right in general, can you attach the actual JSP tags and getter and setter methods?

2. If your result is set up in your struts.xml file, the jsp should have access to the data in your action class when it runs. So this should work once you get the data from screen X into your action class.
 
Nandan Jain
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must be forgetting getter and setter method in your java class. Also coping values from java to jsp will be taken care by the getter and setter methods. Just remember to keep the name of the jsp variable and java variable same.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!