struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mansour <mansou...@yahoo.com>
Subject Re: Preparable, Type conversion and parameter
Date Mon, 25 Jun 2007 22:29:34 GMT
Dave Newton wrote:
> --- Mansour <mansour77@yahoo.com> wrote:
>   
>> I am trying to extract an int in the prepare method.
>> I am not able to cast it.  This is an example of
>>     
> what
>   
>> I am trying to do:
>>
>> Map parameters =
>> ActionContext.getContext().getParameters();
>> Integer task_id  = (Integer) 
>> parameters.get("task.id");
>>     
For this one:

SEVERE: Servlet.service() for servlet default threw exception
java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to 
java.lang.Integer
    at action.TaskAction.prepare(TaskAction.java:62)
    at 
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:118)
    at 
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)

>> I wanna try to avoid using Type conversion.
>>     
>
> Um, why?
>
>   
>> This didn't work either:
>>
>> int task_id  = Integer.parseInt(
>> parameters.get("task.id").toString()) ;
>>     
parameters.get("task.id").toString() evaluates to   (java.lang.String) 
[Ljava.lang.String;@434ff9


>> Do I have to use type conversion even for primitive
>> types?
>>
>> Any idea?
>>     
>
> Yes, look up what the parameters map actually
> contains.
>
> Normally when reporting an error like this you'd show
> the typecast exception you're getting, which should
> provide a clue as to why it isn't working, as an array
> of a type can't be converted to a single instance of a
> type.
>
> There are quicker ways of finding answers to these
> questions than posting to the group!
>
>   
Like what. Please tell me a place where I can get this resolved. :) You 
think I didn't look ? Sometimes programmers get stuck with a problem 
that looks simple to others. No one knows everything, Dave !
> d.
>
>
>
>        
> ____________________________________________________________________________________
> Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo!
Answers - Check it out. 
> http://answers.yahoo.com/dir/?link=list&sid=396545433
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>   


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


Mime
View raw message