English 中文(简体)
Populate values using optionCollection Tag in struts1
原标题:
  • 时间:2010-05-31 09:07:05
  •  标签:
  • struts-1

I have an arraylist which contains {1,2,3,4,5} as objects. i want to show these values in dropdown select box. how do i achieve it. how to map with value and label property?

问题回答
    <%
    for (int j = 0; j < arrayNew.size(); j++) {
    %>

        <%
            if ("dropDown") {
        %>
        <%
        if (counter == 0) {
        %>
        <select name="serveyTakerValue">
            <%
                counter++;
            }
            %>
                 <option value=<%=arrayNew.get(j)%>><%=arrayNew.get(j)%></option>

            <%
                }
            %>
 <%
  }
  counter = 0;
 %>
       </select><br><br>

Try this will solve your problem. NOte: <select name="serveyTakerValue"> and </select> must be called once. That s why counter is being used here in this code. Assume arrayNew be your ArrayList.





相关问题
JSP link submitting data to struts form bean

I am making a JSP page that links to a page where it will pull a list of data from the database depending on the user who is logged in. I am using a DataSourceRealm type authentication so I pull the ...

Populate values using optionCollection Tag in struts1

I have an arraylist which contains {1,2,3,4,5} as objects. i want to show these values in dropdown select box. how do i achieve it. how to map with value and label property?

Eclipse Dynamic Web Project fails to load under WTP

When trying to run an Eclipse Dynamic Web Project under a Tomcat setup using WTP, it fails with the attached stacktrace. Checklist At the project properties, under "Java EE Module Dependencies" I ...

How to use javascript to include struts html tag?

I have a check box and a text box. I have used struts tags and Now i need to validate that if the check box is checked, i should gray out (disable) the text box. If it is unchecked the text box ...

Struts 1 - How to display ActionMessages

I am displaying ActionMessages through a JSP file by the following command: <logic:messagesPresent message="true"> <ul id="messsages"> <html:messages id=&...

AJAX with Struts 1.x Version

I am having an application developed with Struts1.3, Jboss4.X version and jdk1.5 Now as an enhancement we are planning to implement AJAX to the web application Can you please suggest me Whether I ...

Using Bean Class variable into the Jsp (UI layer) in java

I want to use "if condition and while loop" in struts1 framework. I have a Bean class with setter() and getter() methods for fname and lname property. How to use that bean variable in jsp for checking ...

热门标签