On 6/25/07, Mansour <[EMAIL PROTECTED]> wrote:
Dave Newton wrote:
> --- Mansour <[EMAIL PROTECTED]> 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
This means that the object you are trying to cast is an String's Array.
Frequently, this is an Array with only one element, ..., the string you need!!!!
Good Luck!

nickar
    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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to