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 / July 2007

Tip: Looking for answers? Try searching our database.

Struts 2: Returning a list to a s:select

Thread view: 
Rich - 04 Jul 2007 19:29 GMT
I am trying to populate a s:select drop down using a list.  I am new
to all of this so I am having some trouble.

There is a example for populating a select using a list on this page:

http://struts.apache.org/2.0.8/docs/select.html

I was wondering what:

list="petDao.pets"
listKey="id"
listValue="name"

are referring to?

Is petDao a java bean?  Is it an action?  How do you set it up on the
page?  What is pets?  Does it refer to petDao.getPets?  what does it
return?  What do id and name refer to?   Does getPets return a list of
objects that contain the fields name and id which have the getters and
setters for those fields?

Sorry if this is posted in the wrong forum.  This is the only group I
found when I searched for struts 2.
Richard Senior - 07 Jul 2007 16:28 GMT
> Is petDao a java bean?  

Probably a DAO (Data Access Object), producing a Collection from a database.

Is it an action?

No.

How do you set it up on the page?

It's presumably imported as a bean, e.g. with <jsp:useBean .../>

Note this is not a particularly good way of doing it in anything other
than a sample. The view is accessing the model directly in MVC parlance.
Read up on MVC.

What is pets?

It's shorthand for the getPets() method in petDAO.

Does it refer to petDao.getPets?

Yes. You are one step ahead of me.

what does it return?

A Collection of Pets.

What do id and name refer to?

ID is what gets returned in the POST when you've selected that element
and submitted the form. Name is what is displayed for that element.

Does getPets return a list of objects that contain the fields name and
id which have the getters and
setters for those fields?

Yes.

Why do you ask so many questions?

A. I'm learning Struts. It's my job. :)

Signature

Regards,

Richard



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.