struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurizio Cucchiara <maurizio.cucchi...@gmail.com>
Subject Re: How to set a List<Integer> using JSON plugin?
Date Sat, 04 Jun 2011 16:24:03 GMT
This should not be a JSON plugin's error, more likely a OGNL conversion error.
The problem have to do with the ajax request. JQuery send the
following query string:
integerList[]=1&integerList[]=3
Try to express the data parameter in html instead of json:
 data: "ignoreTaskIds=1&ignoreTaskIds=3"

On 4 June 2011 17:20, Burton Rhodes <burtonrhodes@gmail.com> wrote:
> I am trying to do something incredibly simple and for some reason I
> cannot get the JSON plugin to work.  Below are a few code snippits.
> Can any tell me why I get an error when trying to set a List<Integer>
> when using the JSON plugin?  Do I need a converter for this?  Or am I
> missing somthing simple?
>
> // Test Submit - This correctly sets 'xactionId'
> $.ajax({
>  url: "json/TaskBatchJson_saveNewTasks.action",
>  data: { 'xactionId': 1 },
>  success: function(data){
>    alert("Success.");
>  }
> });
>
> // Test Submit - This gives me an error (below)
> $.ajax({
>  url: "json/TaskBatchJson_saveNewTasks.action",
>  data: { 'ignoreTaskIds': [1,2] },
>  success: function(data){
>    alert("Success.");
>  }
> });
>
>
> ** Error When Trying to Set "ignoreTaskIds"
> WARN : Error setting expression 'ignoreTaskIds[]' with value
> '[Ljava.lang.String;@19e9da7'
> ognl.ExpressionSyntaxException: Malformed OGNL expression:
> ignoreTaskIds[] [ognl.ParseException: Encountered " "]" "] "" at line
> 1, column 15.
>
>
> My Action includes the following:
>
> private int xactionId;
> private List<Integer> ignoreTaskIds;
>
> public int getXactionId() {
>        return xactionId;
> }
> public void setXactionId(int xactionId) {
>        this.xactionId = xactionId;
> }
> public List<Integer> getIgnoreTaskIds() {
>        return ignoreTaskIds;
> }
> public void setIgnoreTaskIds(List<Integer> ignoreTaskIds) {
>        this.ignoreTaskIds = ignoreTaskIds;
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
Maurizio Cucchiara

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


Mime
View raw message