• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Passing Customized objects

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Navi Navi", please check your private messages for an important note from me.
 
Bear Bibeault
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This class has primitive and other customized objects in it.
-Navi.
 
Bear Bibeault
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
This tiny ad is guaranteed to be gluten free.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic