Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Struts Presentation with custom objects?

Reply
Thread Tools

Struts Presentation with custom objects?

 
 
Scott Phelps
Guest
Posts: n/a
 
      06-15-2005
If I have a vector of custom objects... how can I make struts auto populate
those objects with checkboxes?

ie

class myObject{
Integer id;
checked boolean;
}



class myActionForm{
Vector myList = new Vector();
}


myList will contain mulitable myObjects.... or am I approaching this wrong?

Thanks


 
Reply With Quote
 
 
 
 
Wendy Smoak
Guest
Posts: n/a
 
      06-15-2005
"Scott Phelps" <(E-Mail Removed)> wrote

> If I have a vector of custom objects... how can I make struts auto

populate
> those objects with checkboxes?
>
> myList will contain mulitable myObjects.... or am I approaching this

wrong?
>


Both your form and your object need to be JavaBeans. Struts uses BeanUtils
to populate the form, and it expects to see properly named get/set methods.

Make sure you understand how checkboxes work from an HTML perspective--
unchecked checkboxes are NOT successful form elements and will not be
present in the request. If your form is in session scope, you'll need to
manually reset the checkboxes to false/off.

If all you're trying to do is get a list of IDs, a String[] will work fine.
(The boolean is implied... true if the ID is in the array, false if not.)

If you really need that object (maybe it has other properties?) then take a
look at indexed properties.
http://struts.apache.org/faqs/indexedprops.html

--
Wendy Smoak



 
Reply With Quote
 
 
 
 
Scott Phelps
Guest
Posts: n/a
 
      06-15-2005

"Wendy Smoak" <(E-Mail Removed)> wrote in message
news:d8phio$d54$(E-Mail Removed)...
> "Scott Phelps" <(E-Mail Removed)> wrote
>
>> If I have a vector of custom objects... how can I make struts auto

> populate
>> those objects with checkboxes?
>>
>> myList will contain mulitable myObjects.... or am I approaching this

> wrong?
>>

>
> Both your form and your object need to be JavaBeans. Struts uses
> BeanUtils
> to populate the form, and it expects to see properly named get/set
> methods.
>
> Make sure you understand how checkboxes work from an HTML perspective--
> unchecked checkboxes are NOT successful form elements and will not be
> present in the request. If your form is in session scope, you'll need to
> manually reset the checkboxes to false/off.
>
> If all you're trying to do is get a list of IDs, a String[] will work
> fine.
> (The boolean is implied... true if the ID is in the array, false if not.)
>
> If you really need that object (maybe it has other properties?) then take
> a
> look at indexed properties.
> http://struts.apache.org/faqs/indexedprops.html
>
> --
> Wendy Smoak
>


Yea the reason I have that obeject is because it is directly related to how
castor pulls and pushes the object to the database.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it safe to point to Internet for locating struts DTD files in struts TLDs and XML files? Katie Wright Java 8 01-07-2005 03:37 PM
[Struts] Newbie - For ActionForm population, must I use Struts taglib? Pratap Das Java 2 04-05-2004 07:42 PM
[Struts]output javascript in struts perform() sin Java 3 02-22-2004 08:27 AM
Integrate a Struts app with a non-struts app jc1771 Java 0 12-28-2003 06:36 PM
Struts Installation - missing struts.tld??? Jason Us Java 0 10-03-2003 11:36 PM



Advertisments