You could point your input result to the same action you use to populate
the form in the first place. That way you can do the same data
pre-fetching on validation failure as you do on first displaying the form.
The other alternative would be to make sure all data you want to have
available is included in the form, so it's carried through as request
parameters. For example, to solve the specific case of your order date
example, you could include that as a hidden field, like so:
<s:hidden name='orderItem.order.date'/>
Depending on what objects you place in what scopes, how you have your
initial action and form processing action set up, how you have
conversion and validation configured, etc, there may be other factors
you need to take into account.
L.
Struts2 Fan wrote:
Hi all,
I have this problem since I started using struts 2 and I still cannot find
the solution. Please help me. :)
Note : I didn't write all the codes.
I have a form.
<s:form>
<%-- order is a property in orderItem bean--%>
<s:set name="order" value="orderItem.order"/>
<s:label value="%{order.date}" label="order.date"/>
<s:hidden name="orderItem.order.id"/>
<s:textfield name="orderItem.quantity" key="orderItem.quantity"/>
<s:submit/>
</s:form>
Here orderItem.quantity is a required field. So when I left if blank and
press the submit button, the validation fails and displays the error message
in the screen. But this time label with id="orderDate" doesn't display the
order.date field on the screen because orderItem is no longer in the value
stack I guess. So it cannot get the order value of orderItem. It writes
nothing on the screen.
Here is the struts.xml
<action name="....." class="....." method="insert">
<result
name="input">/WEB-INF/pages/order/orderItem/orderItemModify.jsp</result>
</action>
When validation fails It returns to jsp. Because of not reaching an action I
cannot put order to the value stack back.
Any idea how can I get it worked? I hope I explained it well. If not please
post a message.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]