struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "CRANFORD, CHRIS" <Chris.Cranf...@setech.com>
Subject RE: JSON Result Behavior with Struts 2.2.3
Date Wed, 01 Jun 2011 16:35:31 GMT
Please disregard.

I found a discussion between Dave, Chris, and Jerry on this very issue
and it appears my problem was due to an interceptor placing data on the
stack incorrectly thus causing the action not to be on top of the stack
which was a code change during the 2.2.3 JSON plugin.

After their modiciation to use 
 
  invocation.getStack().getContext().put("myObj",x);

The expected results work as intended.

Chris

-----Original Message-----
From: CRANFORD, CHRIS [mailto:Chris.Cranford@setech.com] 
Sent: Wednesday, June 01, 2011 11:14 AM
To: Struts Users Mailing List
Subject: JSON Result Behavior with Struts 2.2.3

I recently upgraded to Struts 2.2.3 and noticing that result types of
JSON are not behaving the same way as they did before.  For example, the
following action is setup:

--- Action Class ---

package com.setech.dw.repair.web.ajax;

public class StatusAction implements ActionSupport 
{
  private Map<String,String> list = new LinkedHashMap<String,String>();
  private String type;
  @Autowired
  private IRepairService service;

  public void setType(String type) {
    this.type = type;
  }

  public Map<String,String> getList() {
    return list;
  }

  public String execute() 
  throws Exception {
    List<StatusCode> statuses = service.getStatusCodesByType(type);
    for(StatusCode statusCode : statuses) 
 
list.put(statusCode.getCode(),getText("repair.status."+statusCode.getCod
e().toLowerCase()));

    return SUCCESS;
  }
}

--- Struts Action Mapping ---

<action name="statusSelectList"
class="com.setech.dw.repair.web.ajax.StatusAction">
  <result name="success" type="json"/>
</action>

In the JSP; it is expecting to find variable "list" on the top of the
OGNL value stack which would be the action invoked.  This worked fine
when I was using 2.1.8.1; however after upgrading to 2.2.3; I am finding
that the JSON response only contains the following:

[org.apache.struts2.json.JSONUtil]:
[JSON]{"com.opensymphony.xwork2.util.OgnlValueStack.MAP_IDENTIFIER_KEY":
""}

Was there some fundamental change that I have overlooked?

Chris


---------------------------------------------------------------------
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