struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Huber (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (WW-4605) Refactor MessageStoreInterceptor and use PreResultListener to store messages
Date Mon, 15 Feb 2016 15:25:18 GMT

    [ https://issues.apache.org/jira/browse/WW-4605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15147445#comment-15147445
] 

Greg Huber edited comment on WW-4605 at 2/15/16 3:24 PM:
---------------------------------------------------------

Is it necessary to move the position of the 

result = createResult();   in DefaultActionInvocation

as it stops my Interceptor from working.  I am modifying the result code in a PreResultListener()
interceptor and need the result to be created after applying the interceptor otherwise I have
the wrong value.

{code:java}
......
public String intercept(ActionInvocation invocation) throws Exception {

    if (applyInterceptor(invocation)) {

      invocation.addPreResultListener(new PreResultListener() {
        public void beforeResult(ActionInvocation invocation,
            String resultCode) {

          final ActionContext context = invocation
              .getInvocationContext();

          final HttpServletRequest request = (HttpServletRequest) context
              .get(StrutsStatics.HTTP_REQUEST);

          if (DeviceStore.isMobileDevice(request, true)
              && applyResult(resultCode)) {

            invocation.setResultCode(resultCode + "-"
                + DeviceType.mobile);

            Object action = invocation.getAction();

            if (action instanceof UIAction) {

              UIAction theAction = (UIAction) action;
              theAction.setMobileAwareResult(true);

            }
          }

        }
      });

    }

    return doIntercept(invocation);
  }
....
{code}

My interceptor appends to the result the device type, so if its a mobile I get list-mobile

<result name="list" type="tiles">.MyView</result>
<result name="list-mobile" type="tiles">.MyView-mobile</result>

Calling it where it currently is, all I get is list even though I am setting the ResultCode
using the above.




was (Author: gregh99):
Is it necessary to move the position of the 

result = createResult();   in DefaultActionInvocation

as it stops my Interceptor from working.  I am modifying the result code in a PreResultListener()
interceptor and need the result to be created after applying the interceptor otherwise I have
the wrong value.

{code:java}
......
public String intercept(ActionInvocation invocation) throws Exception {

    if (applyInterceptor(invocation)) {

      invocation.addPreResultListener(new PreResultListener() {
        public void beforeResult(ActionInvocation invocation,
            String resultCode) {

          final ActionContext context = invocation
              .getInvocationContext();

          final HttpServletRequest request = (HttpServletRequest) context
              .get(StrutsStatics.HTTP_REQUEST);

          if (DeviceStore.isMobileDevice(request, true)
              && applyResult(resultCode)) {

            invocation.setResultCode(resultCode + "-"
                + DeviceType.mobile);

            Object action = invocation.getAction();

            if (action instanceof UIAction) {

              UIAction theAction = (UIAction) action;
              theAction.setMobileAwareResult(true);

            }
          }

        }
      });

    }

    return doIntercept(invocation);
  }
....
{code}

My interceptor appends to the result the device type, so if its a mobile I get list-mobile

<result name="list" type="tiles">.MyView</result>
<result name="list-mobile" type="tiles">.MyView-mobile</result>

Calling it where it currently is all I get is list even though I am setting the ResultCode
using the above.



> Refactor MessageStoreInterceptor and use PreResultListener to store messages
> ----------------------------------------------------------------------------
>
>                 Key: WW-4605
>                 URL: https://issues.apache.org/jira/browse/WW-4605
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Core Interceptors
>    Affects Versions: 2.3.24
>            Reporter: Lukasz Lenart
>             Fix For: 2.3.25, 2.5
>
>
> See WW-4600 as this issue is similar, when response was already comitted (redirect was
send, JSP was rendered), logic in {{after}} method won't work as it isn't possible to modify
session when response was comitted.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message