• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing Customized objects

 
Navi Lock
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,
Need some help on the below
I have a Customised class Object ex : Myclass.
I need to pass an instance of this class from a HTML/JSP form to Server side as 'Hidden' attribute.

I have the following which blows up ..
<%
MyClass myclass = new MyClass();
%>
<TR>
<TD colspan="2"><input type="hidden" value"<%=myclass%>" name="KEY">
</TD>
</TR>

Actually this is part of a Struts application..

Have defined the attribute as follows in Strust-Config.xml
<form-property name="KEY" type="MyClass"></form-property>

I am getting the following stack trace..

[BeanUtils.populate]: org.apache.commons.beanutils.ConversionException: Cannot assign value of type 'java.lang.String' to property 'KEY' of type 'MyClass'

Thanks in advance,
-Navi
[ October 17, 2007: Message edited by: Navi Navi ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Navi Navi", please check your private messages for an important note from me.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only strings can be set as the value of hidden elements. If MyClass is anything more complex, this hasn't a prayer of working. Can you give us any notions as to the nature of MyClass?
[ October 17, 2007: Message edited by: Bear Bibeault ]
 
Navi Lock
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This class has primitive and other customized objects in it.
-Navi.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any reason that you cannot simply place the object in the session so that it will be available in the next request?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!