struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Mixon (qwest)" <>
Subject Map backed form with list of String Arrays
Date Tue, 04 May 2004 06:59:04 GMT
I am having a problem with a map-backed form and html:select with multiple="true".  Would appreciate
any help/ideas.

I need to display a set of "html:select" lists. The number of lists is user-defined (based
on database data) and each select list
must allow more than one choice to be selected.

I settled on using a map property in the form bean as the manual suggests. Everything works
great on initial display, furthermore I
am selecting all values which will be the normal use case for the user.

However, upon return, only a single value is passed in. Should I be using the "value" attribute
on the html:select tag? I cannot
seem to figure out how to make it work as an array.

Here are the relevant struts/JSTL tags.

    <c:forEach items="${form1.choiceList}" var="valueArray">
    <td style="text-align: center;">
      <c:set var="cList" value="${Collection_charChoices[choiceArray.key]}"/>
      <html-el:select name="form1" property="choiceLists(${choiceArray.key})" size="6"
        <html-el:options collection="cList" property="id" labelProperty="name"/>

Here is a code snipped I use to inspect the map as it comes in (afer having been successfully
sent out and displayed with all values

        Set keySet = map.keySet();
        Iterator ik = keySet.iterator();
        while (ik.hasNext()) {
            Object key = (String);
            log.debug("showMap - mapKey='"+key.toString()+"'");
            Object value = map.get(key);
            if ( value instanceof String[] ) {
                String[] valArray = (String[]) value;
                for (int i=0;i<valArray.length;i++)
                    log.debug("showMap -   valArray["+i+"]='"+valArray[i]+"'");
            } else {
                    log.debug("showMap -   value instanceof '"+value.getClass().getName()+"'");
                    log.debug("showMap -   value='"+value.toString()+"'");

It shows a simple String object (the first choice in the options list, actually) rather than
the String[] that was sent out.

Thank you again - Richard

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

View raw message