struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Lulé <tho...@lule.fr>
Subject Struts 2 : redirect to action method on type conversion fail ?
Date Mon, 10 May 2010 07:31:54 GMT
Hi,

I've got a form with <s:textfield> mapped with "Long" variables in my
action class.

Also, my jsp displays some pre-computed information (that I retrieve
from database in my action's method).

When the user types letters in the number field, the type conversion
fails, and the JSP is reloaded. But the pre-computed infos are no more
displayed (because we did not execute the action's method).

I didn't find a way to redirect to the action's method even if type
conversion fails.

So I tried to store the pre-computed infos in http parameters by
adding a hidden field :
<s:hidden name="archiveProfile.name" />
<s:property value="archiveProfile.name"/>
it did not work because of the "archiveProfile" thing.

I currently use a workaround, a <s:hidden name="display"/> field that
forces struts 2 to execute the setter :
public void setDisplay(String display){
	display();
}
(display() is my method which loads stuff from db.)

That works but i'm afraid of potential side-effects, do you have a better idea ?

Thanks,
Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message