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 © 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 © 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 © 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]>