struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Schachter, Michael" <MSchach...@Bluestone.com>
Subject RE: Nested/Indexed Properties Now Supported
Date Sat, 06 Jan 2001 21:24:55 GMT
 I'd suggest you follow the javabean naming conventions in your FormBean,
which should look like this:

public class TestForm extends ActionForm {
	protected String[] prop = new String[10];

    	public void setProp(int index, String value) {
 		prop[index] = value;
	}
	
	public String getProp(int index) {
		return prop[index];
	}

	public String[] getProp() {
		return prop;
	}

	public void setProp(String[] prop) {
		this.prop = prop;
	}
}

Give that a try and tell me if it works

-----Original Message-----
From: Oleg V Alexeev
To: Schachter, Michael
Sent: 1/6/01 4:09 PM
Subject: Re: Nested/Indexed Properties Now Supported

Hello Michael,

Sorry, but some questions.. I try to write test Form  with listed
below indexed properties and this is not work...  What part of code is
wrong?

public class TestForm extends ActionForm {
    protected HashMap test = new HashMap();
    protected String[] ind = new String[10];

    public void setProp( int index, String value ) {
     test.put( new Integer( index ), value );
    }

    public String getProp( int index ) {
     return (String)test.get( new Integer( index ) );
    }

    public String[] getIndex() {
     return ind;
    }
}

and test jsp page to use this form -

<html><head>
<%@ page contentType="text/html;charset=windows-1251" %>
<%@ taglib uri="/WEB-INF/struts-form.tld" prefix="form" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/bcom.tld" prefix="bcom" %>
</head>

<body bgcolor="#F7E7CE" text="#510000" link="#800000" vlink="#800000"
alink="#800000" topmargin="0" leftmargin="0">

prop[4] = <%= request.getParameter("prop[4]") %><br>
prop[2] = <%= request.getParameter("prop[2]") %><br>
index[1] = <%= request.getParameter("index[1]") %><br>
index[4] = <%= request.getParameter("index[4]") %><br>

<form:form name="testForm" type="bcom.actions.TestForm" method="post"
action="test.do">
 <form:text property="prop[4]"/><br>
 <form:text property="prop[2]"/><br>
 <form:text property="index[1]"/><br>
 <form:text property="index[4]"/><br>
 <form:submit/>
</form:form>

</body>

</html>


Saturday, January 06, 2001, 10:24:20 PM, you wrote:

SM> Although strangely there was no commit email, last night I committed
changes
SM> to BeanUtils, PropertyUtils, and BaseFieldTag that enable form
elements to
SM> have nested and indexed properties.  If you check CVS the latest
code is
SM> there.  Just letting everyone know.



-- 
Best regards,
 Oleg                            mailto:gonza@penza.net


Mime
View raw message