struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hill" <andrew.david.h...@gridnode.com>
Subject RE: checkboxes - ActionForm in session scope
Date Wed, 16 Jul 2003 03:35:17 GMT
<snip>
I call reset method selectively since I am trying to develope wizard style
pages with one form.
</snip>

Ah, but if you dont reset the checkbox it will always stay ticked - as
nothing (not even an empty string!) is submitted for an unticked checkbox so
the forms setter method is never called.

THIS is the real reason the reset() method even exists in the first place -
its a workaround for this flaw in the html spec. Other fields that need to
be reset include multiple-select boxes and textareas. Empty input fields
will submit an empty string so they dont need to be reset, and single
selects always have something selected so dont need it either.

If your doing wizards you should still call reset() but you do the selective
stuff inside the code for the reset() method (such that it resets only those
fields that were visible on the page just submitted).

-----Original Message-----
From: Khalid K. [mailto:groups@maikada.com]
Sent: Wednesday, 16 July 2003 01:54
To: Struts Users Mailing List
Subject: checkboxes - ActionForm in session scope


Hello All,

I have the following problem, and any help is greatly appreciated:

1. html form that has a checkbox which is associated with a Action Form
Bean - boolean attribute
2. ActionForm is in session scope
3. I call reset method selectively since I am trying to develope wizard
style pages with one form.
4. using struts 1.0.2

problem:

  When I check a checkbox and submit the form, on the "pending" page, I see
the value as set to "true" which is OK.

Now, When I click on "modify" which takes me to the html with the form, and
I uncheck the checkbox and submit again....the value on the "pending" page
is still set to TRUE. Which it should be set to FALSE.  any ideas ??

Khalid
----- Original Message -----
From: "John M. Corro" <john.corro@cornerstone.net>
To: <struts-user@jakarta.apache.org>
Sent: Tuesday, July 15, 2003 10:48 AM
Subject: Re: Is this really the best way to handle this problem


> I've seen two ways of dealing w/ this problem, both of which I see as
'hackish'
> in nature.
>
> Solution A:
>
> In your getters/setters you implement the following code
>
> public MyCustomBean getMyCustomBean(int index) {
>    while(index >= myCustomBeanList.size()) {
>       myCustomBeanList.add(new MyCustomBean());
>    }
>    return (MyCustomBean)myCustomBeanList.get(index);
> }
>
> In that way you'll never encounter the common IndexOutOfBoundsException.
The
> problem here is that you tend to use alot of hidden fields in your UI to
repopulate
> the data back into the dynamically created beans.
>
> Solution B:
>
> In your reset() method you repopulate your internal Collection of beans.
The
> problem w/ this approach is that often times you have a separate Action
that
> prepopulates your ActionForm.  This provides for good separation - the
Action
> is a retriever of a data (nothing more) and the ActionForm is merely a
container
> for data (nothing more).  With this approach your ActionForm suddenly
starts
> becoming more intelligent than it really should be.  Now it's aware of how
to
> populate itself...not a good thing IMO.
>
> I'd be very interested in hearing other solutions to this problem as I
find
> both of the above solutions cumbersome and hackish and would love to stop
implementing
> them.
>
> >I've been struggling with a problem similar to the one described (and
> >solved) at
> >http://www.mail-archive.com/struts-user@jakarta.apache.org/msg50901.html
.
>
> >Is this really the recommended way to solve population / repopulation of
> >properties stored in a List() of
> >whatever-data-object-i-need-in-the-form-of-a-bean ? Is there a better way
to
>
> >acheive the same result ? (I.e represent a collection in a form)
> >
> >I've read that a practice often used to represent collections (a DB-table
> >for intstance) is to make a bean that has getters / setters for the
> >properties of a single row and then have the ActionForm contain a List()
of
>
> >those beans. One for every row  (in the DB-example). That far I can
follow,
>
> >and see how / why. But is there no better way to update the values in the
> >ActionForm (beans) when the data is submitted than in the URL above ?
> >
> >//Linus Nikander - linus@nikander.net
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >
>
>
>
> John M. Corro
> Cornerstone Consulting
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>


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


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


Mime
View raw message