Return-Path: X-Original-To: apmail-struts-user-archive@www.apache.org Delivered-To: apmail-struts-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C96481758E for ; Wed, 5 Nov 2014 11:57:41 +0000 (UTC) Received: (qmail 54816 invoked by uid 500); 5 Nov 2014 11:57:40 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 54774 invoked by uid 500); 5 Nov 2014 11:57:40 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 54758 invoked by uid 99); 5 Nov 2014 11:57:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Nov 2014 11:57:40 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lukasz.lenart@gmail.com designates 209.85.160.177 as permitted sender) Received: from [209.85.160.177] (HELO mail-yk0-f177.google.com) (209.85.160.177) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Nov 2014 11:57:14 +0000 Received: by mail-yk0-f177.google.com with SMTP id 142so116382ykq.22 for ; Wed, 05 Nov 2014 03:54:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=QjLiI8unkM1DxKbEw0Q4TGzy7yd5yMT7sW4dKm8ztdc=; b=ldeXURqFDrGz0xxs5QNCVjynch4dmUXVg/DrI6cQcrvtbAVd25qGjrSQufQ0vmc0dO tdG1kDuC/dK4xuP9R8JiJyeaFOWPv8bBoAA8a19Cm+HgVMUfjEicTrPnWQ/+NhVFRry/ Pq3Hl6CM53STShYYSpCfQNrd6bBJxkwjXygWIxJkk/7rmGnJi5XMoRq5PeGiEfRLC3J1 g1q0KY5fL6ENFRt0Zi6FWu5riaocp0UBYAxk1BKPlI/6rRm+1prYD0jLn5kiwZWBWKa9 EfQjwOU826eLtS1rRP9J3UD1bMV0UL2yFCfEdcZZt9Hl+9AeKP2/SIac+fbjjNLPZ6lD SKng== X-Received: by 10.236.20.226 with SMTP id p62mr39261309yhp.97.1415188498406; Wed, 05 Nov 2014 03:54:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.170.117.197 with HTTP; Wed, 5 Nov 2014 03:54:38 -0800 (PST) Reply-To: lukasz.lenart@gmail.com In-Reply-To: References: From: =?UTF-8?Q?=C5=81ukasz_Lenart?= Date: Wed, 5 Nov 2014 12:54:38 +0100 Message-ID: Subject: Re: Struts 2 JSON plugin change in finding the target action instance problem Pavel Ilyushko Original Poster Greenhorn Joined: Nov 05, 2014 Posts: 1 To: Struts Users Mailing List Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org You can redefine root http://struts.apache.org/release/2.3.x/docs/json-plugin.html#JSONPlugin-RootObject 2014-11-05 12:13 GMT+01:00 Pavel Ilyushko : > Hello there! > > Recently I've upgraded our struts2 framework and its related plugins (eg: > json plugin) from version 2.1.8 to version 2.3.16.3. > > Now I'm having problems in using the json plugin while making json requests > and returning the json responses. > > The problem is that the parameter values passed in the json request are not > set on my struts 2 action any more (likewise, the return fields set in my > action are not returned as a json string). > Why does this happen? The problem is that a change has been made in the > newer version of json plugin regarding to how the target action is found. > > 1. Consider this method: > > public String intercept(ActionInvocation invocation) throws Exception > > from the older version of the json plugin: > > http://grepcode.com/file/repo1.maven.org/maven2/org.apache.struts/struts2-json-plugin/2.1.8/org/apache/struts2/json/JSONInterceptor.java?av=f > > line 100: > > rootObject = invocation.getAction(); // that's why the action class > instance is found ok in struts 2.1.8 > > now from the newer plugin: > > http://grepcode.com/file/repo1.maven.org/maven2/org.apache.struts/struts2-json-plugin/2.3.16.3/org/apache/struts2/json/JSONInterceptor.java?av=f > > line 91: > > ValueStack stack = invocation.getStack(); > rootObject = stack.findValue(this.root); // the value on the top of the > value stack is used! and this is not an action in our case (we push an > interceptor on the top of the stack!). > > 2. Returning the target action's fields as the json return result: > > consider this method: > > public void execute(ActionInvocation invocation) throws Exception > > from the older plugin: > > http://grepcode.com/file/repo1.maven.org/maven2/org.apache.struts/struts2-json-plugin/2.1.8/org/apache/struts2/json/JSONResult.java?av=f > > line 195: > > rootObject = invocation.getAction(); // that's why the action class > instance is found in struts 2.1.8 > > from the newer plugin: > > http://grepcode.com/file/repo1.maven.org/maven2/org.apache.struts/struts2-json-plugin/2.3.16.3/org/apache/struts2/json/JSONResult.java?av=f > > line 175: > > rootObject = readRootObject(invocation); > > line 187: > > return findRootObject(invocation); > > line 193: > > ValueStack stack = invocation.getStack(); > rootObject = stack.findValue(root); // the value on the top of the value > stack is an instance of our custom interceptor, not the target action! > > It is not clear to me why the logic of finding the target action has > changed to popping up the value from the top of the stack. > > In our case this approach does not work anymore, since we have a custom > interceptor pushed onto the top of the stack. > > Is there any workaround? > > Thanks > > > > -- > Pavel Ilyushko --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org