You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Thomas Thomas <de...@gmail.com> on 2006/12/10 12:17:36 UTC

Formbean information lost

Hi,

If I fill my form with, for example, "xyz" as login,
and if there is an error,
"xyz" will stay in the textfield,
(for some reason, as additional question if u can say me why that happen,
would be great)

That's perfect, BUT

I don't have this behaviour with my  <html:select>  tags for the day and
month of his birth date.

For example if user enters day 31 and month February (which is invalid) and
submits,
there will appear 1 January and an error text under it:
date invalid (that can lead to confusion since 1 January is valid) => the
day 31 and month February is lost,
so I have not the same behavior than with my login => if there is error ,
the login he entered is displayed again.
I hope I was clear.

How can I fix this ? Thank u.

Re: Formbean information lost

Posted by Thomas Thomas <de...@gmail.com>.
Thank u ! it works great
:-)

Re: Formbean information lost

Posted by Chris Pratt <th...@gmail.com>.
Try using the <html:option> tag instead of the <option> tag, that way Struts
has some control.
  (*Chris*)

On 12/16/06, Thomas Thomas <de...@gmail.com> wrote:
>
> Thank u very much Miss Harper.
>
> I think it's due to this code, and I don't really know a good way to
> rectify
> this :
>
> Jour
> <html:select size="1" property="birthDay">
>     <c:forEach var="aDay" begin="1" end="31">
>         <option value="${aDay}"/>
>         <c:out value="${aDay}"/>
>     </c:forEach>
> </html:select>
>
> Mois
> <html:select size="1" property="birthMonth">
>     <c:forEach var="aMonth" begin="1" end="12">
>         <option value="${aMonth}"/>
>         <c:out value="${aMonth}"/>
>     </c:forEach>
> </html:select>
>
>
> Thank u very much for your support.
>
>

Re: Formbean information lost

Posted by Thomas Thomas <de...@gmail.com>.
Thank u very much Miss Harper.

I think it's due to this code, and I don't really know a good way to rectify
this :

Jour
<html:select size="1" property="birthDay">
    <c:forEach var="aDay" begin="1" end="31">
        <option value="${aDay}"/>
        <c:out value="${aDay}"/>
    </c:forEach>
</html:select>

Mois
<html:select size="1" property="birthMonth">
    <c:forEach var="aMonth" begin="1" end="12">
        <option value="${aMonth}"/>
        <c:out value="${aMonth}"/>
    </c:forEach>
</html:select>


Thank u very much for your support.

Re: Formbean information lost

Posted by Laurie Harper <la...@holoweb.net>.
Thomas Thomas wrote:
> Hi,
> 
> If I fill my form with, for example, "xyz" as login,
> and if there is an error,
> "xyz" will stay in the textfield,
> (for some reason, as additional question if u can say me why that happen,
> would be great)

It's a function of the design of Struts. When you form is submitted, 
Struts automatically populates your form bean. When you forward back to 
your input page, the values in the form bean are used to populate the 
form fields. Hence, the user's input is preserved and redisplayed.

> That's perfect, BUT
> 
> I don't have this behaviour with my  <html:select>  tags for the day and
> month of his birth date.
> 
> For example if user enters day 31 and month February (which is invalid) and
> submits,
> there will appear 1 January and an error text under it:
> date invalid (that can lead to confusion since 1 January is valid) => the
> day 31 and month February is lost,
> so I have not the same behavior than with my login => if there is error ,
> the login he entered is displayed again.
> I hope I was clear.

It's not clear to me what's going on with the date fields. What does 
your form bean look like? How's it configured in struts-config.xml? 
Assuming you have two form bean properties (one for day and one for 
month), they should retain the values entered unless you are doing 
something to change them.

Try posting the relevant parts of your code and configuration if you 
still need help with this.

L.


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