struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Gundersen" <R.Gunder...@salford.ac.uk>
Subject Collections and type conversion
Date Thu, 05 Feb 2009 12:00:12 GMT
Hi

Could anyone point out what I'm doing wrong here please? My model (FileType) has a collection
of Field objects and a getter called getFileFields(). 

I want to automatically display and set these when my form is rendered/posted. 

Rendering is easy using an iterator, but to allow the collection to be reconstructed upon
form submission, I think I need to enable type conversion. So, in the same package as my action,
I have this file:

------------------------------------------
FileManagementAction-conversion.properties
------------------------------------------
KeyProperty_fields=id
Element_fields=uk.ac.salford.bulkuploader.entity.Field
CreateIfNull_fields=true

In my JSP, I have the following 
-------------------------------

<s:iterator id="field" value="model.fileFields" status="status">
	<s:textfield name="fieldName" size="20"/>     <%-- version 1 --%>
	<s:textfield name="fileFields(%{id}).fieldName" />	<%-- version 2 --%>
		...

Version 1 displays OK, but because it's not indexed, when I submit the form, the model's collection
(fileFields) is not updated. 
Version 2 does not display the value (of 'fieldName') at all (although the '%{id}' value is
correctly output). And, it doesn't set the collection in my model either, although I believe
it should according to the docs. 

I've tried lots of variations on the OGNL syntax for the textfield's name attribute but can't
hit the right one; would really appreciate some help.

Thanks
 
Richard


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


Mime
View raw message