struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hubert Rabago <hrab...@gmail.com>
Subject Re: [FORMDEF] Resetting booleans for session-scoped dynaforms
Date Wed, 12 Oct 2005 17:38:16 GMT
Wow, you've got good timing, because someone is calling for this very
feature in FormDef, patch provided:
https://formdef.dev.java.net/issues/show_bug.cgi?id=2

The quick answer to your question is "no".  FormDef doesn't meddle
with how Struts populates the form.  It's more of a utility class you
call in your Action.  The approach the patch takes is to use subclass
DynaActionForm to override reset() so the checkbox fields can be reset
to false.

My reservation with this approach is, the patch targets only
DynaActionForm.  We'd have to apply the same thing for the five or six
other dyna forms.  I brought this up on the dev list
http://marc.theaimsgroup.com/?l=struts-dev&m=112629799128003&w=2 but
the issue didn't get anybody's attention.  I think this problem is
best solved on the Struts core.

Maybe we can do something like this when configuring forms:
<form-bean
    name="MyForm"
    type="org.apache.struts.action.DynaActionForm">
    <form-property
        name="firstName"
        type="java.lang.String" />
    <form-property
        name="lastName"
        type="java.lang.String" />
    <form-property
        name="someFlag"
        type="java.lang.String"
        initial="false"
        reset="true"/>
</form-bean>

I'll bring it up again and see what happens.

Hubert


On 10/12/05, Michael Jouravlev <jmikus@gmail.com> wrote:
> If Struts is about community and bringing people and Struts-related
> tools together, not about one particular product anymore, then I'd ask
> this question right here.
>
> The question is inspired by katre's interest in checkboxes inside
> dynaforms. I guess, there should be no problem with request-scoped
> dynaforms, but session-scoped forms need to clear their
> checkbox-related fields right before a form is populated.
>
> Hubert, is it possible to add a feature in FormDef, which would allow to:
>   * either clear all boolean fields when request comes;
>   * or to clean only selected fields;
>   * to choose, when to do the cleaning: for all types of requests,
>     or for particular ones, like either POST or GET.
>
> Something like this:
>
> <form name="sampleForm" beanType="com.my.dto.SampleBean">
>   <field property="contactMe"
>     getter="getContactMe"
>     setter="toggleContactMe"
>     reset="POST, GET"/>     <=== Can be just "POST"; resets value to false
> </form>
>
> Currently, I need to clean the booleans for POST request only, this is
> when input comes. I do not need to clean form on GET, this is when the
> form is just displayed.
>
> I would like to start using FormDef in my project.
>
> Michael J.
>
> --
> Struts Dialogs
> http://struts.sourceforge.net/strutsdialogs
>

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


Mime
View raw message