struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sri Sankaran" <Sri.Sanka...@sas.com>
Subject RE: How to handle a multiple select tag
Date Thu, 23 Jan 2003 18:53:05 GMT
Alright.  I look at the docs (http://jakarta.apache.org/struts/userGuide/struts-html.html#select)
and I think you are right.  It reads:

  multiple="true" IS selected - The corresponding property should be 
  an array of any supported data type

So -- in your case -- the form-bean property 'permissions' must be an array.  The docs also
recommend some initializations:

  WARNING: In order to correctly recognize cases where no selection
  at all is made, the ActionForm bean associated with this form must
  include a statement resetting the scalar property to a default 
  value (if multiple is not set), or the array property to zero 
  length (if multiple is set) in the reset() method

I hope you have taken similar necessary precautions.

If everything above checks out:
* Do you have any default selection(s)
  Are these being displayed correctly?
* Are you making any selections *after* the page is displayed?
* Can you (temporarily) modify your application logic to simply
  reload the page after submission?  Are your selections being
  retained?

Sri

> -----Original Message-----
> From: Jordan Thomas [mailto:jot@ipa.fraunhofer.de] 
> Sent: Thursday, January 23, 2003 10:06 AM
> To: Struts Users Mailing List
> Subject: RE: How to handle a multiple select tag
> 
> 
> Thanks Sri for the help. I have updated the code to reflect 
> your suggestions. I actually had an ArrayList in there 
> originally and I changed it to an String[] because I was 
> receiving the following error.
> 
> javax.servlet.ServletExcepion: BeanUtils.populate
> ...
> 
> ----------- Root Cause --------------
> java.lang.IllegalArgumentException: Argument Type Mismatch
> 
> Obviously I am trying to pass the wrong kind of value into 
> the method but I am not sure how to get around this. Any more 
> suggestions?
> 
> thanks again for your help
> 
> Jordan
> 
> -----Original Message-----
> From: Sri Sankaran [mailto:Sri.Sankaran@sas.com]
> Sent: Thursday, 23 January 2003 3:27 PM
> To: Struts Users Mailing List
> Subject: RE: How to handle a multiple select tag
> 
> 
> Is this setter being called at all?  If the 'permissions' 
> property of your form-bean is some kind of List (as it seems 
> looking at the setter you have
> shown) I don't think this setter will be invoked at all.  
> Struts will look for a
> 
>   void setPermissions(List x)
> 
> method.  Likewise when you displayed the page Struts would 
> have obtained the default selection(s) from calling a
> 
>   List getPermissions()
> 
> method.
> 
> I haven't given you a definitive answer but hopefully this 
> provided a clue.
> 
> Sri
> 
> > -----Original Message-----
> > From: Jordan Thomas [mailto:jot@ipa.fraunhofer.de]
> > Sent: Thursday, January 23, 2003 6:51 AM
> > To: Struts User List
> > Subject: How to handle a multiple select tag
> >
> >
> > Hi,
> >
> > I have a form that has an <html:select> tag that looks like this:
> >
> > <html:select property="permissions" multiple="true" size="10" 
> > tabindex="5">
> >     <html:options collection="allPermissions" 
> property="permissionId"
> >         labelProperty="permissionName"/>
> > </html:select>
> >
> > This renders out as intended but when I submit my form to an 
> > ActionForm that has a method that looks like this:
> >
> >
> > public void setPermissions( String[] permissions ) {
> >         Integer permissionId = null;
> >         for (int i = 0; i < permissions.length; i++){
> >             permissionId = new Integer(permissions[i]);
> >             this.permissions.add( new PermissionData(permissionId, 
> > null) );
> >         }
> >     }
> >
> > This essentially takes the permissions and adds them to a 
> Collection. 
> > For some reason though, the permissions String[] is null. Why isn't 
> > this getting submitted?
> >
> > thanks for your help
> >
> > Jordan
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:struts-user-> unsubscribe@jakarta.apache.org>
> > For
> > additional commands,
> > e-mail: <mailto:struts-user-help@jakarta.apache.org>
> >
> >
> 
> --
> To unsubscribe, e-mail: 
> <mailto:struts-user-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <mailto:struts-user-help@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:struts-user-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <mailto:struts-user-help@jakarta.apache.org>
> 
> 

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


Mime
View raw message