struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bala.Par...@novainfo.com
Subject RE: ActionForm automatic type conversion
Date Wed, 05 Jan 2005 16:36:21 GMT
ActionForm attributes are defined as Strings. In your case, a good solution
would be to define an adapter class that will do the conversion from String
to the appropriate type. Your business objects will use the converted data
types to execute the business logic. This approach is discussed in detail in
the book Struts in Action.

Bala

-----Original Message-----
From: dsarris [mailto:chipix@gmail.com]
Sent: Monday, January 03, 2005 4:16 AM
To: Struts Users Mailing List
Subject: ActionForm automatic type conversion


Hi all and happy new year,

I am trying to fill an ActionForm with values that are neither Strings
or primitives. The specified values are selected using the
<html:select> tag. This a sample of my JSP code:

   <html:form action="/sumbit.do">
		      	<html:select property="selectedAthlete">
		    		<html:optionsCollection
		    			name="controlPanelValues"
		    			property="athletes"
		    			label="name"
		    			value="value" />

		    	</html:select>
   <html:submit>
  	<bean:message key="cp.button.submit"/>
   </html:submit>
   </html:form>

The "controlPanelValues" Bean contains a collection (list) named
"athletes" containing Beans of type "Pair". The "Pair" object contains
2 attributes: The "name" which is a String and the value which is an
"Athlete" object.

My ActionForm contains an attribute named "selectedAthlete" of the
type "Athlete".

However, whenever I submit this form the "selectedAthlete"  is filled
with the string representation of the "Athlete" type.

I used both simple and map-backed actionform with no success. 

Is Struts capable for doing assignment of non String or primitive fields?

Chipix

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

Note:  The information contained in this email and in any attachments is
intended only for the person or entity to which it is addressed and may
contain confidential and/or privileged material.  Any review,
retransmission, dissemination or other use of, or taking of any action in
reliance upon, this information by persons or entities other than the
intended recipient is prohibited.  The recipient should check this email and
any attachments for the presence of viruses.  Sender accepts no liability
for any damages caused by any virus transmitted by this email. If you have
received this email in error, please notify us immediately by replying to
the message and delete the email from your computer.  This e-mail is and any
response to it will be unencrypted and, therefore, potentially unsecure.
Thank you.  NOVA Information Systems, Inc.

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


Mime
View raw message