You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Felipe Rodrigues <fe...@yahoo.com.br> on 2007/04/11 14:48:20 UTC

returns an String[] when is checked!

Hi guys,

I'm using ActionContext.getContext().getParameters().get("checkboxName"); to
get a value from a checkbox in my jsp.
The problem here is, when its value is false, works fine, I got an String.
But when my checkbox is checked and I call this same method, I got a
String[] and as you know, if I cast from String[] to String I got an cast
exception.
Does somebody knows why I got this behavior?

Thanks,

Felipe
-- 
View this message in context: http://www.nabble.com/%3Cs%3Acheckbox%3E-returns-an-String---when-is-checked%21-tf3559152.html#a9938814
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: returns an String[] when is checked!

Posted by cilquirm <aa...@gmail.com>.

Try declaring a boolean setter in your Action with the checkbox name.

i.e.  

setCheckboxName( boolean val ) { this.checkboxName = val ; } 

and using that instead.

I'm not sure why you're trying to get the value from the
ActionContext.getParameters().  That will return the raw, globbed values of
the parameters, and they by nature are multi-valued, so a String[] is
expected. 
( it's possible for a query string to be someParam=a&someParam=b ).








Felipe Rodrigues wrote:
> 
> Hi guys,
> 
> I'm using ActionContext.getContext().getParameters().get("checkboxName");
> to get a value from a checkbox in my jsp.
> The problem here is, when its value is false, works fine, I got an String.
> But when my checkbox is checked and I call this same method, I got a
> String[] and as you know, if I cast from String[] to String I got an cast
> exception.
> Does somebody knows why I got this behavior?
> 
> Thanks,
> 
> Felipe
> 

-- 
View this message in context: http://www.nabble.com/%3Cs%3Acheckbox%3E-returns-an-String---when-is-checked%21-tf3559152.html#a9943331
Sent from the Struts - User mailing list archive at Nabble.com.


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