Hi,

I have a rather complex form with an <html:select> that uses dynamically
generated <html:option> values. The problem is that the destination array,
upon posting, returns an array with zero length. I am using a DynaActionForm
in Struts 1.2 (version cannot change).

The code ...

=File: allocate-manual-filter.jsp=
=SOURCE CODE: BEGIN=
<html:form action="/allocate-manual-select" method="POST">

// ... code to create "select_name" ... followed by ...
<html:hidden property='<%= "display_" + select_name %>' value="<%=
display_name %>" />

<html:select property="<%= select_name %>" multiple="true" size="5"
styleClass="filter">
// ... code to get the PK value and populate the options array ...  followed
by ...
<html:option value="<%= pk.toString() %>">
  <%= options[ INDEX_DISPLAY_VALUE ] %>
</html:option>
</html:select>
</html:form>
=SOURCE CODE: ENDED=

=File: struts-config.xml=
=SOURCE CODE: BEGIN=
    <form-bean
      name="allocate-manual-select-form"
      type="org.apache.struts.action.DynaActionForm">
      <form-property
        name="display_fiscal_year"
        type="java.lang.String" />
      <form-property
        name="fiscal_year"
        type="java.lang.String[]" />
    </form-bean>
=SOURCE CODE: ENDED=

=File: struts-config.xml=
=SOURCE CODE: BEGIN=
<action-mappings>
    <action
      path="/allocate-manual-select"
      type="ca.bc.gov.mof.bcas.allocate.ManualSelectAction"
      name="allocate-manual-select-form"
      input="/WEB-INF/jsp/allocate-manual-filter.jsp"
      scope="session"
      validate="false">
      <forward
        name="success"
        path="/WEB-INF/jsp/allocate-manual-select.jsp" />
    </action>
</action-mappings>
=SOURCE CODE: ENDED=

=File: ManualSelectAction.java=
=SOURCE CODE: BEGIN=
public boolean execute( ... ) {
    DynaActionForm dynaForm = (DynaActionForm)form;
    String values[] = (String[])dynaForm.get( "fiscal_year" );

    if( values != null ) {
      System.out.println( "fiscal_year: " + values.length );
    }
}
=SOURCE CODE: ENDED=

The log file shows the following:

fiscal_year: 0
display_fiscal_year: Fiscal Year

Everything is hooked up correctly, because display_fiscal_year is showing
the appropriate value. The former value is supposed to be an array of
strings with a size of 1 (for the one element I shuttle into it).

The ManualSelectAction class does not define a "fiscal_year" array of
Strings. This will be the next thing to try. (Although my impression was
that if I used a DynaActionForm, I wouldn't have to create a class that
contains variables ...?)

Aside from that, any other ideas?
-- 
View this message in context: 
http://www.nabble.com/Multiple-Select-tp16227737p16227737.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to