cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the values returned by a function in a drop down?

Former Member
0 Kudos

Hi All,

Can anyone please help in getting the values returned by a function into a drop down? I have a java class file where in i have written a function called getWeeks() which give all the week dates and i want to display these week dates in a drop down box in a JSP page.

Please help me in this regard.

Thanks in Advance!!

Lakshman.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

-

Former Member
0 Kudos

Hi Lakshman,

the following code can help you do what you want :


<hbj:dropdownListBox id="calendar" tooltip="Calendar" selection="<%= selected %>">
<%
String[] weeks = myObjectBean.getWeeks();
for (int i = 0; i < weeks.length; i++) {
%>
	<hbj:listBoxItem key="<%= i %>" value="<%= weeks<i> %>"/>
<%
}
%>
</hbj: dropdownListBox>

The <%= selected %> snippet allows you to pre-select one of the options (provided that the variable 'selected' is equal to one of the listBoxItem keys).

You can also add onSelect to the tag (e.g. = "setSelectedItem"). It corresponds to a method in the corresponding JSPDynPage class. This means that when you select another item in the dropdown list, the method in your Java class is performed (allowing you to save the selected value and performing actions with it)

I hope this helped you enough,

kind regards,

Frederic

Edited seven times by: Frederic Taes on Nov 5, 2008 11:24 AM -> the onSelect element was in the hbj tag and in the text with "='setSelectedItem'" next to it and when I tried to post my message, I got a 501 error all the time ! Seems like a SDN bug to me ...