File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Help on struts 2 bean usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help on struts 2 bean usage" Watch "Help on struts 2 bean usage" New topic

Help on struts 2 bean usage

Luca Zitto

Joined: Feb 08, 2010
Posts: 24
Probably I am doing something really stupid, but can anyone please explain?
I have a jsp and, at the top, before the html tag I populate a bean as follows:
<s:bean name="lucaluke.MyBean" var="myBean">
<s:param name="model"><s:property value="codePassed" /></s:param> <!-- this is just a code passed from previous action -->
Let's say in html I print the value from myBean.model, this is also fine.

then on the page I use the value from the bean, I have a form which calls an action and all is fine.
Problem is when the validation in the action fails (validate() method...) in this case I correctly addFieldError and go to the jsp set as input in struts.xml
the error is correctly displayed but...
As in input I have defined to remain on the same jsp as before, I would expect myBean to be still valid, am I correct in this assumption?
should myBean and / or codePassed as defined above still be valid or not? because apparently, they are not and I end up with a more or less blank page...
What am I doing wrong? Something really stupid I guess?
I agree. Here's the link:
subject: Help on struts 2 bean usage
jQuery in Action, 3rd edition