Search code examples
validationstrutsresetdynamic-data

Struts 2 validation resets my dynamic data


I'm trying to validate a form and it works well, the right messages appear... My only problem is that my form fields are deleted if there are some errors.

Datas are taken by Database and be showed in forms with struts tags (so they're dynamic). If I put sono static value, that will not deleted after a wrong validation.

     <s:form action="updateUser" method="post" id="updateUser"
    name="updateUser" >     

    <s:textfield value="%{user.name}" class="modify"  id="name" name="name" key="modify.name" required="true"    />

this will be deleted while this:

<s:textfield value="HELLO" class="modify"  id="name" name="name" key="modify.name" required="true"    />

will not.

Any advice?


Solution

  • Have you set a User object in your Action Class? Do you have getters/setters for that object? Also how have you configured the "input" result of this action in struts.xml? Maybe you should use "chain" in result of INPUT (i guess this is the result you get from the validator.)