Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Struts 2: Returning a list to a s:select

Reply
Thread Tools

Struts 2: Returning a list to a s:select

 
 
Rich
Guest
Posts: n/a
 
      07-04-2007
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.

 
Reply With Quote
 
 
 
 
Richard Senior
Guest
Posts: n/a
 
      07-07-2007
Rich wrote:

> 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.

--
Regards,

Richard
 
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
List comprehension returning subclassed list type? Shane Geiger Python 4 03-25-2007 09:34 AM
returning none when it should be returning a list? randomtalk@gmail.com Python 11 05-02-2006 10:26 AM
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: returning to main window Dave Java 1 07-27-2004 08:30 PM
Struts Installation - missing struts.tld??? Jason Us Java 0 10-03-2003 11:36 PM



Advertisments