• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts action form properties

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have one question about the struts action form properties:

What type of properties can be used in action forms? Should we use only String and boolean properties or we can use any type of properties? Is it necessary to have some kind of converter if other types of properties are used?
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In fact, you can use any Objects as the ActionForm properties. If you want to store primitive data, you need to use the Wrapper classes. Of course, you need to have different *treatments* for each different objects.

Consider using Hashtable to store the checkbox values for dynamic checkboxes. For example, a JSP allow users to add a certain number of files, which upload to the server. Since the number of uploads varies, we can use Hashtable to store the values.

But, you cannot simply specify the getter and setter of the Hashtable, as Struts is not setting the whole hashtable variables into it (unlike String and other Wrapper classes for primitive data types).

You need:

Then, Struts knows how to handle those checkboxes with Hashtable.
So do others.

Nick
[ May 20, 2004: Message edited by: Nicholas Cheung ]
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use another type such as Map like this







----------------------------------
The types supported by DynaActionForm include:

java.lang.BigDecimal
java.lang.BigInteger
boolean and java.lang.Boolean
byte and java.lang.Byte
char and java.lang.Character
java.lang.Class
double and java.lang.Double
float and java.lang.Float
int and java.lang.Integer
long and java.lang.Long
short and java.lang.Short
java.lang.String
java.sql.Date
java.sql.Time
java.sql.Timestamp
reply
    Bookmark Topic Watch Topic
  • New Topic