Search code examples
javajspwebwork

How to get selected items in OpenSymphony WebWork select


I inherited somebody else's code, and it uses OpenSymphony WebWorks, which I've never encountered before. I'm trying to "cargo cult" a small fix to it. It includes the following in a JSP:

      <ww:select
    name="'selectedOrigDoctypes'"
    value="selectedOrigDoctypes"
    size="5"
    multiple="true"
    cssClass="'doctype'"
    list="origDoctypeChoices"
    theme="'simple'" />

and I can't figure out how to get the selected items out of the list. The list is correctly populated with the contents of the Action bean's origDoctypeChoices property. I thought I'd just have to implement a "setSelectedOrigDoctypes(List docTypes)" in the Action bean, but that's not working. Instead I see the following in the log files:

150876 [http-8080-1] DEBUG com.opensymphony.xwork.interceptor.ParametersIntercep
tor  - Setting params {selectedOrigDoctypes=[Ljava.lang.String;@5249c469}
150965 [http-8080-1] DEBUG com.opensymphony.xwork.util.CompoundRootAccessor  - No object in the CompoundRoot has a property named 'selectedOrigDoctypes'.

Solution

  • I finally figured out what the "selectedOrigDoctypes=[Ljava.lang.String;" thing meant - I changed "origDoctypeChoices" from a List to an String[], and everything worked.