how to increase the length of the<html:select>
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kriss_j
Posted On:   Friday, November 9, 2001 09:38 AM

hi all,
How to increase the size of the <
html:select>
here is my code in .jsp file...
html:select property="itemIds" multiple="true" >

Re: how to increase the length of the&lt;html:select&gt;

Posted By:   Ted_Husted  
Posted On:   Thursday, November 15, 2001 02:35 PM

The properties for options are very confusing, and there's talk on DEV of
an alternate tag, optimized to use something like the LabelValue beans.


Here's how to use the current options tag when the LabelValue collection
(from the Example) has been stored as a property on the ActionForm. If
you want to provide the collection through an ActionForm method, you
need to define a scripting variable first.



property="myOptions" type="java.util.Collection"/>



Then




labelProperty="label"/>



If you wanted to build the list from a static method in your business
layer, a simple one could look like this:



public static String getMyOptions(int image) {
String text = null;
switch (image) {
case -5: text = "Photograph item"; break;
case -4: text = "Clip from Website"; break;
case -3: text = "Expect by email"; break;
case -2: text = "Expect by mail"; break;
case -1: text = "Do not use"; break;
case 0: text = "No"; break;
case 1: text = "Yes"; break;
case 2: text = "Use icon"; break;
}
return text;
}

public static Collection getMyOptionss() {
Collection list = (Collection) new ArrayList();
for (int i=-5; i<2; i++) {
list.add(new LabelValueBean(
getMyOptions(i),
String.valueOf(i)
));
}
return list;
}



Then in the ActionForm, a wrapper method can be used:




public Collection getMyOptions() {
return app.StaticClass.getMyOptions();
}


HTH - Ted

About | Sitemap | Contact