Re: sorting drop down values in a drop box in jsp

2004-03-10 Thread Larry Meadors
Do it in the action?

 [EMAIL PROTECTED] 03/10/04 11:48 AM 
Hi,
 
Looking for  aeasy way to sort entries in the drop down in my jsp, that
are populated using the bean and html: select tag with options:
collection:
 
my code as of now is below:

select name=fullName style=width:225px

logic:iterate id=teacher name=teachers option value=bean:write
name=teacher property =employeeID/

bean:write name=teacher property =fullName/

/option

/logic:iterate

/select

 

 

My other approach to create same drop down is:

html:select style=width:225px property=fullName 

html:options collection=teachers property=teacher
labelProperty=fullName/

/html:select

Thanks in advance



-
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: sorting drop down values in a drop box in jsp

2004-03-10 Thread Wendy Smoak
 From: as as [mailto:[EMAIL PROTECTED] 
 Looking for  aeasy way to sort entries in the drop down in my 
 jsp, that are populated using the bean and html: select tag 
 with options: collection:
 my code as of now is below:
 html:select style=width:225px property=fullName 
 html:options collection=teachers property=teacher 
 labelProperty=fullName/
 /html:select

I do this to display a bunch of checkboxes sorted by either the account
number or the cost center. 

In the Action:
  HttpSession session = request.getSession();
  Map accountMap = (Map) session.getAttribute( accountMap );
  Map newMap = new TreeMap( new CostCenterComparator() );
  newMap.putAll( accountMap );
  session.setAttribute( accountMap, newMap );
  accountMap = null;

And now the Map sitting in session scope is sorted by cost center.
Sorting it by Account is the natural order, so I just make a new TreeMap
with no Comparator, and dump the items in.

It's a little different with List than Map.  What type of Collection is
'teachers'?

And you don't have to put it in the session, it might be in the request,
or be a form property.

-- 
Wendy Smoak
Application Systems Analyst, Sr.
ASU IA Information Resources Management 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: sorting drop down values in a drop box in jsp

2004-03-10 Thread Brian Lee
You can also use the BeanComparator class from the commons package instead 
of writing your own Comparator class.

It's pretty fast and allows for more flexibility (i.e. passing in the sort 
property, etc etc)

BAL

From: Wendy Smoak [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Subject: RE: sorting drop down values in a drop box in jsp
Date: Wed, 10 Mar 2004 12:04:13 -0700
 From: as as [mailto:[EMAIL PROTECTED]
 Looking for  aeasy way to sort entries in the drop down in my
 jsp, that are populated using the bean and html: select tag
 with options: collection:
 my code as of now is below:
 html:select style=width:225px property=fullName
 html:options collection=teachers property=teacher
 labelProperty=fullName/
 /html:select
I do this to display a bunch of checkboxes sorted by either the account
number or the cost center.
In the Action:
  HttpSession session = request.getSession();
  Map accountMap = (Map) session.getAttribute( accountMap );
  Map newMap = new TreeMap( new CostCenterComparator() );
  newMap.putAll( accountMap );
  session.setAttribute( accountMap, newMap );
  accountMap = null;
And now the Map sitting in session scope is sorted by cost center.
Sorting it by Account is the natural order, so I just make a new TreeMap
with no Comparator, and dump the items in.
It's a little different with List than Map.  What type of Collection is
'teachers'?
And you don't have to put it in the session, it might be in the request,
or be a form property.
--
Wendy Smoak
Application Systems Analyst, Sr.
ASU IA Information Resources Management
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_
Fast. Reliable. Get MSN 9 Dial-up - 3 months for the price of 1! 
(Limited-time Offer) http://click.atdmt.com/AVE/go/onm00200361ave/direct/01/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]