You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by RALPH ROPER <RR...@cuscal.com.au> on 2003/12/12 09:15:48 UTC

cannot populate input field within iterate tag

hi,

I have a fairly simple request but after many attempts I am no closer to
resolving it. The problem is trying to update a property within a
logic:iterate tag. The property is a Collection of PropertyRecords that live
on my PropertyForm bean. The PropertyRecord class contains two properties 1)
key and 2) value. I want to update the value property that is associated to
a key. This key/value comibination is better suited to a Map which I tried
to getting working initially but gave up on.

The display of the screen works fine. It is when I go to update a value and
Submit the form that it does not update the value. 

It looks like the name in the html:text tag name attribute is incorrect.
This is the only reason why I can see that the Collection does not update
with the newly entered value.

In my 

JSP Page ITSparamsPropertyEditor.jsp

<logic:iterate id="lr" name="propertyForm" property="properties"
type="com.cuscal.settlements.redinet.helpClass.utilities.properties.Property
Record" >
		
	<bean:define id="ky" name="lr" property="key"
type="java.lang.String" />
	<bean:define id="vl" name="lr" property="value"
type="java.lang.String" />
			
	<tr><td> <bean:write name="lr" property="key" /> </td><td>
	<% if (ky.endsWith("PWD") | ky.endsWith("PASSWORD")) { %>
		<html:password name="lr" property="propertyKey" value="<%=
vl%>" 				indexed="true" />
	<% } else { %>
		 <html:text name="lr" property="key" value="<%= vl%>"
indexed="true" />
	<% } %>
	 </td></tr>
</logic:iterate>

The PropertyEditorForm class which has the bean id propertyForm.

public class PropertyEditorForm extends ActionForm {

	private String fileName;
	private List properties;
	/**
	 * Returns the fileName.
	 * @return String
	 */
	public String getFileName() {
		return fileName;
	}

	/**
	 * Sets the fileName.
	 * @param fileName The fileName to set
	 */
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public void reset(
		ActionMapping mapping,
		javax.servlet.http.HttpServletRequest request) {
		fileName = "none";
		//	properties=null;
	}
	/**
	 * @return
	 */
	public List getProperties() {
		return properties;
	}

	/**
	 * @param map
	 */
	public void setProperties(List properties) {
		this.properties = properties;
	}

	public String getPropertyValue(int index) {
		return ((PropertyRecord)
getProperties().get(index)).getValue();
	}
	
	public void setPropertyValue(int index, String value)
	{
		this.properties.set(index, value);
	}
	
	public String getPropertyKey(int index) {
		return ((PropertyRecord)
getProperties().get(index)).getKey();
	}
	
	public void setPropertyKey(int index, String key)
	{
		this.properties.set(index, key);
	}

}


The PropertyRecord class.
public class PropertyRecord {
	
	private String key;
	private String value;
	
	/**
	 * @return
	 */
	public String getKey() {
		return key;
	}

	/**
	 * @return
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @param string
	 */
	public void setKey(String string) {
		key = string;
	}

	/**
	 * @param string
	 */
	public void setValue(String string) {
		value = string;
	}

}

Example of the HTML source that is generated.

<tr><td> EXPORT_MONTHLY_FEES_PATH </td><td>
<input type="text" name="lr[49].key"
value="/oracle/redinet/data/export/monthlyfees/">
</td></tr>

Even though I change the value of this imput field it does not update in the
Collection on the form bean.

Any help would be much appreciated as this is driving me crazy. If anyone
knows how to do this as a Map it would be great.

thanks,

Ralph Roper
Senior Analyst/Programmer
Business Technology Services (BTS)
Credit Union Services Corporation

________________________________________________________
NOTICE
The information in this email and or any of the attachments may contain;
a. Confidential information of Credit Union Services Corporation (Australia) Limited (CUSCAL) or third parties; and or
b. Legally privileged information of CUSCAL or third parties; and or
c. Copyright material of CUSCAL or third parties.
If you are not an authorised recipient of this email, please contact CUSCAL immediately by return email or by telephone on 61-2-8299 9000 and delete the email from your system.
We do not accept any liability in connection with computer virus, data corruption, interruption or any damage generally as a result of transmission of this email.

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