aspose file tools*
The moose likes Struts and the fly likes struts2 hidden fields empty after validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2 hidden fields empty after validation" Watch "struts2 hidden fields empty after validation" New topic
Author

struts2 hidden fields empty after validation

kuha guna
Greenhorn

Joined: Jan 08, 2009
Posts: 6
hi,

i have some hidden fields in in my form after server side struts validation these fields are emptied. what is the possible workaround to handle this problem.

Thanks in advance
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689


Hi,

First understand when you validate your form and validation called then the flow of your project not reached at your action calss.

So all the variable which is use in jsp initialize again when your validation fail.

so, when you validate every time your validate methid call.

so Override validate methd in your Action class and initialize your hidden varibale in validate methid. Like.

@Override
public void validate() {
hiddenvaribale=value;
}

all variable which you want to get back when validation failed you have to again initialize at validate method.


If you have still any problem post your jsp code and action code.





Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
kuha guna
Greenhorn

Joined: Jan 08, 2009
Posts: 6
Thanks Nishan.
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689


Hi,

Your welcome.

But is it working fine ??


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: struts2 hidden fields empty after validation