DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18186>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18186 html:radio idName attribute doesn't work in resin 2.1.6 Summary: html:radio idName attribute doesn't work in resin 2.1.6 Product: Struts Version: 1.1 RC1 Platform: All OS/Version: All Status: NEW Severity: Normal Priority: Other Component: Custom Tags AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] ## Test this code in resin 2.1.6 --test-radio.jsp <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %> <%@ page import="java.util.*"%> <%@ page import="org.apache.struts.util.*"%> <% List l = new ArrayList( 5); request.setAttribute( "l", l); for( int i = 0; i < 5; i++) { LabelValueBean lvb = new LabelValueBean( String.valueOf( i), "labelxx " + i); l.add( lvb); } %> <html> <head> <title> test_radio </title> </head> <body bgcolor="#ffffff"> <html:form action="/test_radio"> <br><br> <logic:iterate id="lvb" name="l" type="org.apache.struts.util.LabelValueBean"> <html:radio idName="lvb" value="value" property="x"/> <bean:write name="lvb" property="label"/><br> </logic:iterate> <input type="submit" name="Submit" value="Submit"> <input type="reset" value="Reset"> </html:form> </body> </html> -- struts-config.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts- config_1_1.dtd"> <struts-config> <form-beans> <form-bean name="testRadioForm" type="org.apache.struts.action.DynaActionForm" dynamic="true"> <form-property name="x" type="java.lang.String" /> </form-bean> </form-beans> <action-mappings> <action name="testRadioForm" forward="/test_radio.jsp" path="/test_radio" /> </action-mappings> <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" /> <message-resources parameter="resources.application" /> <plug-in className="org.apache.struts.tiles.TilesPlugin"> <set-property value="/WEB-INF/tiles-defs.xml" property="definitions- config" /> <set-property value="true" property="moduleAware" /> <set-property value="true" property="definitions-parser-validate" /> </plug-in> <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" property="pathnames" /> </plug-in> </struts-config> The problem happens when the container is going to render the second radio button. It looses the value of the "value" attribute of RadioTag. The problem is due to: //Tomcat code org.apache.struts.taglib.html.RadioTag _jspx_th_html_radio_0 = (org.apache.struts.taglib.html.RadioTag) _jspx_tagPool_html_radio_value_property_idName.get (org.apache.struts.taglib.html.RadioTag.class); _jspx_th_html_radio_0.setPageContext(pageContext); _jspx_th_html_radio_0.setParent(_jspx_th_logic_iterate_0); _jspx_th_html_radio_0.setIdName("lvb"); _jspx_th_html_radio_0.setValue("value"); _jspx_th_html_radio_0.setProperty("x"); //Resin code if (_jsp_tag2 == null) { _jsp_tag2 = new org.apache.struts.taglib.html.RadioTag(); _jsp_tag2.setPageContext(pageContext); _jsp_tag2.setParent(_jsp_tag1); _jsp_tag2.setProperty("x"); _jsp_tag2.setValue("value"); _jsp_tag2.setIdName("lvb"); } Look in tomcat the radio tag is initialized every iterator but in resin the tag is initialized first time, so if the RadioTag changes the value of the "value" attribute, these changes remain for the rest of iterations. I did search in the JSP Specification to find if it is a resin error or struts error. I found the folowing: "All properties of a tag handler instance exposed as attributes will be initialized by the container using the appropriate setter methods before the instance can be used to perform the action methods. It is the responsibility of the JSP container to invoke the appropriate setter methods to initialize these properties. It is the responsability of user code, be it scriptlets, JavaBeans code, OR CODE INSIDE CUSTOM TAGS, TO NOT INVOKE THESE SETTER METHODS, AS DOING OTHERWISE WOULD INTERFERE WITH THE CONTAINER KNOWLEDGE. The setter methods that should be used when assigning a value to an attribute of a custom action are determined by using the JavaBeans introspector on the tag handler class, then use the setter method associated with the property that has the same name as the attribute in question. An implication (unclear in the JavaBeans specification) is that there is only one setter per property. Unspecified attributes/properties should not be set (using a setter method). ONCE PROPERLY SET, ALL PROPERTIES ARE EXPECTED TO BE PERSISTENT, SO THAT IF THE JSP CONTAINER ASCERTAINS THAT A PROPERTY HAS ALREADY BEEN SET ON A GIVEN TAG HANDLER INSTANCE, IT NEEDS NOT SET IT AGAIN. USER CODE CAN ACCESS PROPERTY INFORMATION AND ACCESS AND MODIFY TAG HANDLER INTERNAL STATE STARTING WITH THE FIRST ACTION METHOD (DOSTARTTAG) UP UNTIL THE LAST ACTION METHOD (DOENDTAG OR DOFINALLY FOR TAG HANDLERS IMPLEMENTING TRYCATCHFINALLY)." JavaServer Pages 1.2 Specification - Simple Tag Handlers Pages 161-162 Using the above information I modified the RadioTag for restore the value of the "value" attribute in the doEndTag. This is the patch file: Index: RadioTag.java =================================================================== RCS file: /home/cvspublic/jakarta- struts/src/share/org/apache/struts/taglib/html/RadioTag.java,v retrieving revision 1.19 diff -u -r1.19 RadioTag.java --- RadioTag.java 16 Dec 2002 03:41:43 -0000 1.19 +++ RadioTag.java 20 Mar 2003 12:56:27 -0000 @@ -123,6 +123,10 @@ */ protected String value = null; + /** + * To save the original value of "value". + */ + private String saveValue; /** * Name of the bean (in some scope) that will return the @@ -221,7 +225,9 @@ * @exception JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { - + /* We change the value of the "value" property so we must save the + original value to restore it */ + saveValue = value; // Acquire the current value of the appropriate field Object current = null; Object bean = RequestUtils.lookup(pageContext, name, null); @@ -324,6 +330,9 @@ // Render any description for this radio button if (text != null) ResponseUtils.write(pageContext, text); + + // Restore the original value of "value" property + value = saveValue; // Evaluate the remainder of this page return (EVAL_PAGE); I'm going to send this patch to the developer list. I suggest instead of modify the "value" attribute, create a new attribute called for example "idProperty". Or make a pair of "valueName" and "valueProperty". Thanks for your attention. Best Regards, --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
