You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Hayes <ja...@wm.edu> on 2003/11/09 20:30:42 UTC

mapped properties, checkboxes, and optionsCollection

I have two problems that I think are related, so I'm including them both
in this email.  I'm using Struts 1.1.

Problem #1:

I am trying to use a mapped property on an html:checkbox, and it does
not appear to be setting the value of the property to true if the
checkbox is checked and submitted.  This is the line in my JSP:

<html:checkbox property="parameterValue(searchSomething)"/>

In the reset method I set all Boolean objects in the map to
Boolean.FALSE as indicated in the html taglib documentation.  It works
fine if I use a "scalar" field with a boolean primitive like the
following:

protected boolean booleanValue = false;
public void setBooleanValue(boolean value)...
public boolean getBooleanValue()...

and

<html:checkbox property="booleanValue"/>

I'm wondering if there is a problem where the mapped property is not
being set properly (since checkbox is probably trying to set a boolean
value instead of Boolean).  Has anyone else encountered this before?

Problem #2

I am trying to use another mapped property in the same ActionForm
implementation on an html:optionsCollection.  

  <html:select property="parameterValue(selectedDbList)" multiple="true"
size="5">
  <html:optionsCollection property="parameterValue(dbList)"/>
  </html:select>

I initialize the dbList's value in the Map and the optionsCollection
loads properly in the browser.  However, on submission I only get the
first value if multiple values of the list are submitted in the Map for
the selectedDb key.  I suspect there might be a problem setting the
String array in the Map for some reason.

I also tried this with a "scalar" field and it worked just fine:

    protected String[] selectedDbList = null;
    
    public String[] getSelectedDbList() {
        return (this.dbList);
    }
    public void setSelectedDbList(String[] selectedDbList) {
        this.selectedDbList = selectedDbList;
    }

and 

<html:select property="selectedDbList" multiple="true" size="5">
<html:optionsCollection property="parameterValue(dbList)"/>
</html:select>

I get the impression that both these problems are bugs, and if so, I'd
be interested in looking into how to fix them.  So, if anyone has a idea
where I should look first it would be very helpful.  Or, if they're not
bugs, I'd really appreciate any help you can offer.  

-- 
John Hayes <ja...@wm.edu>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org