Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

Struts Presentation with custom objects?

Thread view: 
Scott Phelps - 15 Jun 2005 15:51 GMT
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
Wendy Smoak - 15 Jun 2005 16:22 GMT
> 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

Signature

Wendy Smoak

Scott Phelps - 15 Jun 2005 18:28 GMT
>> If I have a vector of custom objects... how can I make struts auto
> populate
[quoted text clipped - 21 lines]
> look at indexed properties.
> http://struts.apache.org/faqs/indexedprops.html

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.