Hello...I have an app where you are on a page that has a drop down with
select then some values.  After you choose a value the form is submitted.
Data is reloaded in the array list used to fill the form.  WHen I get back
to the page the drop down has the value in it that was previously selected.
So if you choose "green" in the drop down, after calling the action and
loading the drop down's arraylist with "Red", "Blue", and "Green", Green is
selected in the box.  Is there a way i can avoid this so the value goes back
to "Select"?

code from jsp:
<html:form action="/LoadHomePage">
    <html:select property="code" onchange="document.all.testForm.submit();">

        <option value="2">Select</option>
        <html:options collection="colors" property="id"
labelProperty="name"/>
</html:select>

Code from action:
GVO gvo = new GVO();
        gvo.setId(1);
        gvo.setName("Red");
        GVO gvo2 = new GVO();
        gvo2.setId(2);
        gvo2.setName("Green");
        ArrayList a = new ArrayList();
        a.add(gvo);
        a.add(gvo2);
        request.setAttribute("colors", a);

Struts config mapping:
        <form-bean name="testForm" type="
org.apache.struts.action.DynaActionForm">
            <form-property name="code" type="java.lang.String">
            </form-property>
        </form-bean>

        <action path="/LoadHomePage" type="test.LoadHomePageAction"
name="testForm">
            <forward name="success" path="home.jsp"/>
        </action>

Reply via email to