Your right, I was confusing it with the approach that was suggested here, which 
involved a hidden text box with java script on the checkbox setting the hidden field 
to a Y or N value.   That makes the Marc solution look a lot cleaner.

In our implementation, the lists maintain themselves.  The page designer, and form and 
action generator don't have to know what is happening.   The HTML tag classes could 
maintain the list of any kind of element that is included.  

Our application is built around an intelligent item type, one that does it's own 
formatting and validation, so it made sense for the forms reset and validation methods 
to just call the item's reset and validate methods.   While that is a useful concept 
that might be of general use, I'm now seeing that it really isn't a requirement for 
checkbox maintenance.  The underlying struts logic could reset the field by using 
reflection to find the setter method and calling that with a null or empty value.

-----Original Message-----
From: Jesse Alexander (KADA 11) 
Sent: Monday, August 26, 2002 2:27 PM
To: 'Struts Developers List'
Subject: RE: solution for missing refresh of ActionForm using checkboxes

Hi,

it does not seem to rely on JavaScript. Just some code in the reset()-method, plus
an enhanced JSP-tag adding a hidden form-value for each checkbox.
Me too I once conceived the idea to keep a list of all form-field-names for a
active page in a hidden field in the form. This allowed me to define reset-values
fro non-checkbox-fields as well. But it was more tedious to maintain for the
page-designer. Adding a similar mechanism to other form-elements could bring this
back in the way Marc does it for checkboxes...Gotta think it over...

regards
Alexander

-----Original Message-----
From: Corbin, Ken [mailto:[EMAIL PROTECTED]]
Sent: Montag, 26. August 2002 17:57
To: [EMAIL PROTECTED]
Subject: RE: solution for missing refresh of ActionForm using checkboxes


True, I assumed that any generated pages would be processed by the base Action class.  
 Which seemed like a reasonable assumption, but might possibly not be.   If it is 
true, than a wizard could move check boxes from one class to another without problems, 
the base Action class would process it wherever it was found.

Marc's solution is a good one.   It was proposed here, and I decided not to take it 
for reasons that probably aren't relevant to the general struts environment.   The 
active element list also allowed me to call the item validation methods of data items 
that were on the active list and might possibly have been changed, instead of 
attempting to validate every item in a very large form bean.   Partly this was an 
efficiency issue, but more than that, I didn't want a data field that had somehow been 
stored with invalid information in the database to stop processing of a user page 
unless the user could fix the information on that page.   If a validation check fails 
and stops processing of an item that isn't being maintained by the current page, the 
user is pretty much out of luck.

However, my data items keep the original value and can tell when they have been 
changed, so if the struts library adopts Marc's convention, I could and probably would 
use it to replace my list, making the validation check only on items whose value had 
been changed by the user.

There are some other drawbacks to Marc's approach, neither of them are show stoppers.  
 It relies on javascript associated with the checkbox field, which will
1) possibly interfere with javascript code that the user want to apply to that 
checkbox, and
2) won't work on a browser that doesn't support javascript.

-----Original Message-----
From: Jesse Alexander (KADA 11)
Sent: Monday, August 26, 2002 8:23 AM
To: 'Struts Developers List'
Subject: RE: solution for missing refresh of ActionForm using checkboxes

But in your way you are linking the presentation to the Base-Action. The original 
solution proposed by Marc decouples the presentation from the Action-classes. With his 
solution a designer can move a checkbox in a wizard-form from one page to another 
without any code-change. Therefor it should be a good enhancement.

regards
Alexander

-----Original Message-----
From: Corbin, Ken [mailto:[EMAIL PROTECTED]]
Sent: Donnerstag, 22. August 2002 22:21
To: [EMAIL PROTECTED]
Subject: RE: solution for missing refresh of ActionForm using checkboxes


The way I solved this was to have a base action class that keeps track of which fields 
are maintained by the current page and only resets those.   That means that the data 
fields have to be represented by objects derived from some class or implementing an 
interface that accepts a reset method.   And it isn't much of a step to have that 
interface implement common getValue and putValue methods that struts infrastructure 
can call to get and set text display strings.   Next add some html tags to support the 
new data element and build the active element list and we're all set.

I have this running on top of 1.02.   Right now it is pretty specialized for our 
particular application, but it could be turned into a general feature and anyone 
thinks that would be a good idea.

-----Original Message-----
From: Christopher Book
Sent: Thursday, August 22, 2002 12:05 PM
To: 'Struts Developers List'
Subject: RE: solution for missing refresh of ActionForm using checkboxes

This doesn't work in a lot of situations though...

Supposed you have a form that lives in the session (like a shopping cart).
There may be several pages that submit using the same form (but different
fields).  Each submit will destroy your checkbox value even if you're on a
page that doesn't have that checkbox.

The solution below allows the value only to be cleared if a checkbox was
actually on the page and not otherwise.... and it seems like a solution that
is easier to program for.  Instead of writing a complicated reset() method
that has to detect which page you're coming from, the process would be
transparent to the user.

Chris

-----Original Message-----
From: Martin Cooper [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 22, 2002 2:56 PM
To: 'Struts Developers List'
Subject: RE: solution for missing refresh of ActionForm using checkboxes


It's much simpler to have the reset() method in your form bean set checkbox
values to false. Then, if the checkbox is checked, the value will be set to
true when the form is submitted, whereas if the checkbox is not checked,
then the value will be false because no matching parameter will be
submitted.

--
Martin Cooper


> -----Original Message-----
> From: van Nuffel, Marc [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 22, 2002 5:12 AM
> To: '[EMAIL PROTECTED]'
> Subject: solution for missing refresh of ActionForm using checkboxes
>
>
> problem :
>
> a unchecked CheckBox doesent get unchecked after formSubmit..
>
> problem description:
>
> if you uncheck a CheckBox that was checked, after submiting the form,
> it remains checked, because the browser doesent post data
> from unchecked
> CheckBoxes.
> so the ActionForm-setterMethod doesent get invoked.
>
> our solution:
>
> customTag:
>
> the only enhancement of the
> org.apache.struts.taglib.html.CheckboxTag is
> that we overwrite the doEndTag method and printing out an hiddenfield
> after calling the super.doEndTag method. the hiddenfiled
> consists of an
> unique name,
> the value is the propertyString of the CheckboxTag .
>
>
> ActionForm:
>
> we made an abstract class ActionFormEnhanced that extends ActionForm.
> we overwrite the method reset() and use reflection to find
> the setterMethods
> which we have to invoke,
> to unset the checkboxes. the method names are found over a
> generated hidden
> field
> produced from our costumTag  "CheckBoxTagEnhanced" which
> inherits from
> org.apache.struts.taglib.html.CheckboxTag
>
> all this is fully transparent to the user.
>
>
>
>
>
> the ActionFormEnhanced.java:
>
>
>
>
> package com.eenterprises.ejob.web.forms;
>
> import java.lang.reflect.Method;
>
> import javax.servlet.http.HttpServletRequest;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionMapping;
>
> /**
>  * This ActionForm enhances Struts ActionForm
>  * @author Pierce Shah , Marc van Nuffel , Romeo Kienzler,
> Reto Bachmann
>  */
>
> public abstract class ActionFormEnhanced extends ActionForm {
>
>       private Class actionFormClass = getClass();
>       public static final String PARAMETER_TO_RESET =
> "res_checkb_666";
>       protected ActionFormEnhanced reference;
>
>       public void reset(ActionMapping mapping,
> HttpServletRequest request)
> {
>
>               String[] checkBoxAttributeName =
> request.getParameterValues(PARAMETER_TO_RESET);
>               Class[] parameterTypes = new Class[1];
>               parameterTypes[0] = boolean.class;
>
>               if (checkBoxAttributeName != null) {
>                       for (int i = 0; i <
> checkBoxAttributeName.length;
> i++) {
>
>                               StringBuffer buffer = new
> StringBuffer("set");
>                               buffer.append(checkBoxAttributeName[i]);
>    
> buffer.setCharAt(3,Character.toUpperCase(buffer.charAt(3)));
>                               Method method;
>
>                               try {
>                                       method =
> actionFormClass.getMethod(buffer.toString(), parameterTypes);
>                               } catch (NoSuchMethodException nsmx) {
>                                       throw new
> RuntimeException(nsmx.toString());
>                               } catch (SecurityException sx) {
>                                       throw new
> RuntimeException(sx.toString());
>                               }
>
>                               Object[] arglist = new Object[1];
>                               arglist[0] = Boolean.FALSE;
>                               try {
>                                    
> method.invoke(reference, arglist);
>                               } catch (Exception ex) {
>                                       throw new
> RuntimeException(ex.toString());
>                               }
>                       }
>               }
>       }
>
>       public ActionFormEnhanced() {
>               this.reference = this;
>               System.out.println(reference.getClass());
>       }
> }
>
>
>
>
> the CheckBoxTagEnhanced.java :
>
>
>
>
>
> package com.eenterprises.ejob.web.forms;
>
> import java.io.IOException;
>
> import javax.servlet.jsp.JspException;
> import javax.servlet.jsp.JspWriter;
> import org.apache.struts.taglib.html.CheckboxTag;
>
> public class CheckBoxTagEnhanced extends CheckboxTag {
>
>       public int doEndTag() throws JspException {
>               int returnValue = super.doEndTag();
>               JspWriter out = pageContext.getOut();
>               try {
>                       out.println(
>                               "<input type=\"hidden\"
> name=\""+ActionFormEnhanced.PARAMETER_TO_RESET+"\" value=\""
>                                       + super.getProperty()
>                                       + "\">");
>               } catch (IOException e) {
>                       throw new JspException(e.getMessage());
>               }
>               return returnValue;
>       }
>
> }
>
> the struts-htmlE.tld :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP
> Tag Library
> 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd";>
> <taglib>
>     <tlibversion>1.0</tlibversion>
>     <jspversion>1.1</jspversion>
>     <shortname>htmlE</shortname>
>     <uri>http://jakarta.apache.org/struts/tags-html-1.0</uri>
>     <tag>
>         <name>checkbox</name>
>
> <tagclass>com.eenterprises.ejob.web.forms.CheckBoxTagEnhanced<
> /tagclass>
>         <attribute>
>             <name>accesskey</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>alt</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>altKey</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>disabled</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>indexed</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>name</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onblur</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onchange</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onclick</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>ondblclick</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onfocus</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onkeydown</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onkeypress</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onkeyup</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onmousedown</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onmousemove</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onmouseout</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onmouseover</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>onmouseup</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>property</name>
>             <required>true</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>style</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>styleClass</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>styleId</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>tabindex</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>title</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>titleKey</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>         <attribute>
>             <name>value</name>
>             <required>false</required>
>             <rtexprvalue>true</rtexprvalue>
>         </attribute>
>     </tag>
> </taglib>
>
>
> Mit freundlichen Grüssen
> ( means kindly regards :-) )
>
> eEnterprises Technology
>
> Romeo Kienzler
> Reto Bachmann
> Pierce Sha
> Marc van Nuffel
>
> eProduction AG
> Software Engineering
>
> Förrlibuckstrasse 110, 8005 Zürich - Switzerland
> Telefon +41 1 448 2121/2137 | Fax +41 1 448 2122
> [EMAIL PROTECTED] | www.eproduction.ch
>
>
> (c) by eEnterprises Holding AG, www.eenterprises.com
> eProduction AG, a company of eEnterprises Holding AG
>
> ___________________________________________________________________
> eSitebuilder - Integration Platform for your eBusiness
> CREATE, MANAGE AND RUN YOUR BUSINESS ANYWHERE
> www.esitebuilder.net (c) 2000 by eProduction AG | All Rights Reserved
> ___________________________________________________________________
> Licence Control System : Phantophone : Secure eMail : Phantomax
> SECURE COMMUNICATION AND DATA MANAGEMENT IS OUR BUSINESS
> www.esafemaker.com (c) 2002 by eSafemaker AG | All Rights Reserved
> ___________________________________________________________________
>
> The information in this internet email is confidential and is intended
> solely for the addressee. Access, copying or re-use of
> information in it by
> anyone else is unauthorised. Any views or opinions presented
> are solely
> those of the author and do not necessarily represent those of
> eEnterprises
> Technology or any of its affiliates. If you are not the
> intended recipient
> please contact [EMAIL PROTECTED]
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to