Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 05219200B45 for ; Fri, 15 Jul 2016 15:18:42 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 03D63160A6C; Fri, 15 Jul 2016 13:18:42 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DE774160A61 for ; Fri, 15 Jul 2016 15:18:40 +0200 (CEST) Received: (qmail 33668 invoked by uid 500); 15 Jul 2016 13:18:30 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 32327 invoked by uid 99); 15 Jul 2016 13:18:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jul 2016 13:18:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 70713ED49E; Fri, 15 Jul 2016 13:18:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lukaszlenart@apache.org To: commits@struts.apache.org Date: Fri, 15 Jul 2016 13:18:52 -0000 Message-Id: <83306bacfb574fa78cefe6674446338f@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [25/50] [abbrv] struts git commit: made methods non static and private, javadoc updates archived-at: Fri, 15 Jul 2016 13:18:42 -0000 made methods non static and private, javadoc updates Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/8a2f083d Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/8a2f083d Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/8a2f083d Branch: refs/heads/master Commit: 8a2f083d5dc2a20abd267e3c3fa3bd696da804e5 Parents: f6d0e15 Author: cnenning Authored: Tue Jan 12 14:14:09 2016 +0100 Committer: Lukasz Lenart Committed: Tue Jan 19 16:19:18 2016 +0100 ---------------------------------------------------------------------- .../validation/AjaxFormSubmitAction.java | 2 +- .../struts2/json/JSONActionRedirectResult.java | 23 ++++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/8a2f083d/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/AjaxFormSubmitAction.java ---------------------------------------------------------------------- diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/AjaxFormSubmitAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/AjaxFormSubmitAction.java index b179370..50ff53f 100644 --- a/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/AjaxFormSubmitAction.java +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/validation/AjaxFormSubmitAction.java @@ -23,7 +23,7 @@ import com.opensymphony.xwork2.validator.annotations.UrlValidator; *
    *
  • Depends on json-plugin.
  • *
  • Requires jsonValidationInterceptor to be on stack.
  • - *
  • Uses a special json redirect result type.
  • + *
  • Uses result type jsonActionRedirect.
  • *
  • Uses http parameters struts.enableJSONValidation=true and struts.validateOnly=false.
  • *
  • Uses a customized theme to make sure html elements required as error containers are always present and easily selectable in JS.
  • *
  • Uses some custom JS code depending on jQuery to issue AJAX request and to render errors in html.
  • http://git-wip-us.apache.org/repos/asf/struts/blob/8a2f083d/plugins/json/src/main/java/org/apache/struts2/json/JSONActionRedirectResult.java ---------------------------------------------------------------------- diff --git a/plugins/json/src/main/java/org/apache/struts2/json/JSONActionRedirectResult.java b/plugins/json/src/main/java/org/apache/struts2/json/JSONActionRedirectResult.java index f0f3f39..40aa092 100644 --- a/plugins/json/src/main/java/org/apache/struts2/json/JSONActionRedirectResult.java +++ b/plugins/json/src/main/java/org/apache/struts2/json/JSONActionRedirectResult.java @@ -16,13 +16,12 @@ import org.apache.struts2.result.ServletActionRedirectResult; * don't pass them to JS handlers. So this result produces a JSON response * containing redirect data. * - *

    - * To be used along with {@link JSONValidationInterceptor}. - *

    - *

    - * Response JSON looks like this: - *

    {"location": "$redirect url$"}
    - *

    + *

    To be used along with {@link JSONValidationInterceptor}.

    + * + *

    Response JSON looks like this: + * + *

    {"location": "$redirect url$"}
    + *

    * */ public class JSONActionRedirectResult extends ServletActionRedirectResult { @@ -30,7 +29,7 @@ public class JSONActionRedirectResult extends ServletActionRedirectResult { private static final long serialVersionUID = 3107276294073879542L; @Override - protected void sendRedirect(HttpServletResponse response, String finalLocation) throws IOException { + protected void sendRedirect(HttpServletResponse response, String finalLocation) throws IOException { if (sendJsonInsteadOfRedirect()) { printJson(response, finalLocation); } else { @@ -45,12 +44,12 @@ public class JSONActionRedirectResult extends ServletActionRedirectResult { * @return true if a JSON response shall be generated, false if a redirect * shall be sent. */ - static boolean sendJsonInsteadOfRedirect() { + private boolean sendJsonInsteadOfRedirect() { HttpServletRequest request = ServletActionContext.getRequest(); return isJsonEnabled(request) && !isValidateOnly(request); } - static void printJson(HttpServletResponse response, String finalLocation) throws IOException { + private void printJson(HttpServletResponse response, String finalLocation) throws IOException { response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json"); response.setHeader("Location", finalLocation); @@ -61,11 +60,11 @@ public class JSONActionRedirectResult extends ServletActionRedirectResult { writer.close(); } - private static boolean isJsonEnabled(HttpServletRequest request) { + private boolean isJsonEnabled(HttpServletRequest request) { return "true".equals(request.getParameter(JSONValidationInterceptor.VALIDATE_JSON_PARAM)); } - private static boolean isValidateOnly(HttpServletRequest request) { + private boolean isValidateOnly(HttpServletRequest request) { return "true".equals(request.getParameter(JSONValidationInterceptor.VALIDATE_ONLY_PARAM)); } }