struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Close <>
Subject <html:select><html:optionsCollection>
Date Thu, 15 Jul 2004 17:53:30 GMT
alrighty,  i've got this half figured out.  i can populate my
dropdowns, but my form doesn't seem to be scrapping the values back
off the page.
i have an action that gets a collection of beans and puts them in
session for the JSP to use.  the JSP renders and displays those
objects correctly in the dropdowns.  when the first dropdown is
changed an onchange event fires off the previous action to populate
the second dropdown.  however, the selected value in the first
dropdown doesn't show up in my Action or the Form.

here's part of the JSP:

<td align="left">
 <html:select name="shoppingListForm" property="selectedShoppingList"
onchange="sl_getGroups(this.form);" >
  <html:option value="-1" >- Please Select A List -</html:option>
  <html:optionsCollection name="lists" />
 <html:select name="shoppingListForm"
onchange="sl_getItems(this.form);" >
  <logic:match name="selectedShoppingList" value="-1">
   <html:option value="-1" >- Please Select A List -</html:option>
  <logic:notMatch name="selectedShoppingList" value="-1">
   <html:option value="-1" >- Please Select A Group -</html:option>
   <html:option value="0" >- All Groups -</html:option>
   <html:optionsCollection name="groups" />

and i have an ActionForm created named shoppingListForm containing two
Strings: selectedShoppingList and selectedShoppingListGroup with
initial values set at "-1".  ShoppingListForm contains basic getters
and setters for these attributes.

so i'm guessing my problem lies within my Action.  i'm extending
DispatchAction and the getGroups method forwards to the above JSP on

public ActionForward getGroups (


try {
    HttpSession session = request.getSession(false);
    ShoppingListForm slForm = (ShoppingListForm)form;
    if (slForm == null) {
        session.setAttribute("selectedShoppingList", "-1");
        session.setAttribute("selectedShoppingListGroup", "-1");
    } else {
        System.out.println("\n\nShopping List Form...");
        System.out.println("Shopping List: " +
        System.out.println("Shopping List Group: " +
slForm.getSelectedShoppingListGroup() + "\n\n\n");

... go on to populate collection for lists, etc...

the first time through the form will be null because this action is
called from another page.  the action populates 'lists' and forwards
to the above JSP.  onchange in the JSP calls this same action and
should pass it my ShoppingListForm, in which should be found the value
to selectedShoppingList.  however this value remains "-1".
on success the same JSP is displayed...

here is the action-mapping for this particular action:

<action path="/refresh" 
  <forward name="success" path="/jsp/SLMain.jsp" />
  <forward name="failure" path="/jsp/SLError.jsp" />

thanks for any help

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message