You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by da...@efsnetwork.com on 2003/10/09 17:55:00 UTC

indexed properties

I'm working through the examples on http://jakarta.apache.org/struts/faqs/indexedprops.html and have some questions.

I am able to get the sample code under 'Indexed Properties' to work fine. 
----------------------------------------------------------
package Beans;
import org.apache.struts.action.ActionForm;
public class testBean extends ActionForm {
    private String strAry[] = { "String 0", "String 1", "String 2", "String 3", "String 4" };

    public String getStringIndexed(int index) { 
        return strAry[index]; 
    }
    
    public void setStringIndexed(int index, String value) { 
        strAry[index] = value; 
    }
}
------------------------------------------------------------
jsp
-----------------------------------------------------------
<jsp:useBean id="bean" class="Beans.testBean"/>
<bean:write name="bean" property="stringIndexed[1]"/> 

 ---> prints String 1




Under 'Dynamic Indexes for Indexed Properties' I receive an error stating ... (after adding in <jsp:useBean id="stringbean" class="Beans.testBean"/> so the bean could be used)
	"org.apache.jasper.JasperException: No getter method for property stringArray of bean stringbean."

----------------------------------------------------------------
<html:html locale="true">
<html:form action = "/chosenAddressID">
<body>
<jsp:useBean id="stringbean" class="Beans.testBean"/>
<logic:iterate name ="stringbean" property="stringArray" id="foo" indexId="ctr" >
<!-- <html:text name="stringbean" property='<%= "labelValue[" + ctr + "].label" %>' /> -->
</logic:iterate>
</html:form>
----------------------------------------------------------------------

'stringArray' was not defined in the original formbean, but stringIndexed was so I modified the code to:

----------------------------------------------------------------
<html:html locale="true">
<html:form action = "/chosenAddressID">
<body>
<jsp:useBean id="stringbean" class="Beans.testBean"/>
<logic:iterate name ="stringbean" property="stringIndexed" id="foo" indexId="ctr" >
<!-- 	<html:text name="stringbean" property='<%= "labelValue[" + ctr + "].label" %>' /> 		-->
</logic:iterate>
</html:form>
----------------------------------------------------------------------

and receive the error:
	"org.apache.jasper.JasperException: No getter method for property stringIndexed of bean stringbean"
despite the getter method being defined in Beans.testBean.


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