Re: Placing interceptor in arbitrary position in the stack

2023-03-23 Thread Lukasz Lenart
As far I know you must declare a new stack

czw., 23 mar 2023 o 18:29 Shawn Griffith
<276ee31...@proton.me.invalid> napisał(a):
>
> Hi,
>
> let's say I have this default interceptor stack
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> input,back,cancel,browse
>
> 
>
> 
>
> 
>
> 
>
> input,back,cancel,browse
>
> 
>
> using annotations on an action class, can I place another interceptor between 
> prepare and model driven? Or do I need to re-declare the entire stack with 
> the additional interceptor?
>
> Thanks

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



Placing interceptor in arbitrary position in the stack

2023-03-23 Thread Shawn Griffith
Hi,

let's say I have this default interceptor stack





















input,back,cancel,browse









input,back,cancel,browse



using annotations on an action class, can I place another interceptor between 
prepare and model driven? Or do I need to re-declare the entire stack with the 
additional interceptor?

Thanks

Re: When using the ExecuteAndWait interceptor, is it possible to avoid calling prepare / validate methods on reloads?

2021-10-11 Thread Lukasz Lenart
pon., 11 paź 2021 o 16:26 Burton Rhodes  napisał(a):
> Thanks for the reply Lukasz.  I thought about doing something like that,
> but this page
> https://struts.apache.org/core-developers/execute-and-wait-interceptor.html
> mentions the ExecuteAndWait interceptor must be at the end of the stack.  I
> guess you're saying that is not always the case.  I'll give it a try and
> see what happens.  Thanks!

Yes, this can be problematic if you want to have prepare() and
validate() called on initial action execution. If that won't work, we
can implement some sort of skip mechanism, to allow skip processing
given interceptor as there should be any kind of dependency between
interceptors.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



Re: When using the ExecuteAndWait interceptor, is it possible to avoid calling prepare / validate methods on reloads?

2021-10-11 Thread Burton Rhodes
Thanks for the reply Lukasz.  I thought about doing something like that,
but this page
https://struts.apache.org/core-developers/execute-and-wait-interceptor.html
mentions the ExecuteAndWait interceptor must be at the end of the stack.  I
guess you're saying that is not always the case.  I'll give it a try and
see what happens.  Thanks!

On Mon, Oct 11, 2021 at 1:13 AM Lukasz Lenart 
wrote:

> czw., 7 paź 2021 o 16:16 Burton Rhodes 
> napisał(a):
> >
> > Through a recent debugging session I realized that when refreshing a
> "wait"
> > page during an ExecuteAndWait process, it calls the action's prepare()
> and
> > validate() methods each time. For some reason I thought Struts
> > would immediately identify the "waiting" Action, and if it wasn't
> finished,
> > it would return a WAIT result with the running Action at the top of the
> > stack.  I now realize since the ExecuteAndWait filter is at the end of
> the
> > interceptor stack, it obviously doesn't send the WAIT result until all
> > interceptors have been executed.
> >
> > That said, in some of my long running actions the prepare() method hits
> the
> > database for some rather resource heavy database queries. So if I have an
> > executeAndWait page showing the progress status (refreshing every 2
> seconds
> > in my case), this seems incredibly inefficient.  Is there a way to avoid
> > this?  Am I setting up my Action flow incorrectly?
> >
> > A sample of one of my Action setups in struts.xml:
> >
> >   > class="com.afs.web.struts.action.contact.ContactDeleteAction">
> > 
> > /struts/contact/contactDelete_modal.jsp
> >  > name="error">/struts/common/error/error_modal.jsp
> >  > name="login">/struts/common/login/login_modal.jsp
> > 
> >  > class="com.afs.web.struts.action.contact.ContactDeleteAction"
> > method="delete">
> > 
> >  >
> > 0
> > 
> >  > name="input">/struts/contact/contactDelete_modal.jsp
> >  > name="wait">/struts/common/progressMonitorWait_modal.jsp
> >
>  /struts/common/progressMonitorSuccess_modal.jsp
> >  > name="error">/struts/common/error/error_modal.jsp
> >  > name="login">/struts/common/login/login_modal.jsp
> >   
>
> prepare() and validate() are called by different interceptors, which
> means you must put your Exec interceptor before them in the
> stack. I would use a custom stack for Exec actions with proper
> order of interceptors. As I see you have a default stack which is
> prepended to Exec interceptor and that's why those methods are
> called.
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


Re: When using the ExecuteAndWait interceptor, is it possible to avoid calling prepare / validate methods on reloads?

2021-10-11 Thread Lukasz Lenart
czw., 7 paź 2021 o 16:16 Burton Rhodes  napisał(a):
>
> Through a recent debugging session I realized that when refreshing a "wait"
> page during an ExecuteAndWait process, it calls the action's prepare() and
> validate() methods each time. For some reason I thought Struts
> would immediately identify the "waiting" Action, and if it wasn't finished,
> it would return a WAIT result with the running Action at the top of the
> stack.  I now realize since the ExecuteAndWait filter is at the end of the
> interceptor stack, it obviously doesn't send the WAIT result until all
> interceptors have been executed.
>
> That said, in some of my long running actions the prepare() method hits the
> database for some rather resource heavy database queries. So if I have an
> executeAndWait page showing the progress status (refreshing every 2 seconds
> in my case), this seems incredibly inefficient.  Is there a way to avoid
> this?  Am I setting up my Action flow incorrectly?
>
> A sample of one of my Action setups in struts.xml:
>
>   class="com.afs.web.struts.action.contact.ContactDeleteAction">
> 
> /struts/contact/contactDelete_modal.jsp
>  name="error">/struts/common/error/error_modal.jsp
>  name="login">/struts/common/login/login_modal.jsp
> 
>  class="com.afs.web.struts.action.contact.ContactDeleteAction"
> method="delete">
> 
> 
> 0
> 
>  name="input">/struts/contact/contactDelete_modal.jsp
>  name="wait">/struts/common/progressMonitorWait_modal.jsp
> /struts/common/progressMonitorSuccess_modal.jsp
>  name="error">/struts/common/error/error_modal.jsp
>  name="login">/struts/common/login/login_modal.jsp
>   

prepare() and validate() are called by different interceptors, which
means you must put your Exec interceptor before them in the
stack. I would use a custom stack for Exec actions with proper
order of interceptors. As I see you have a default stack which is
prepended to Exec interceptor and that's why those methods are
called.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



When using the ExecuteAndWait interceptor, is it possible to avoid calling prepare / validate methods on reloads?

2021-10-07 Thread Burton Rhodes
Through a recent debugging session I realized that when refreshing a "wait"
page during an ExecuteAndWait process, it calls the action's prepare() and
validate() methods each time. For some reason I thought Struts
would immediately identify the "waiting" Action, and if it wasn't finished,
it would return a WAIT result with the running Action at the top of the
stack.  I now realize since the ExecuteAndWait filter is at the end of the
interceptor stack, it obviously doesn't send the WAIT result until all
interceptors have been executed.

That said, in some of my long running actions the prepare() method hits the
database for some rather resource heavy database queries. So if I have an
executeAndWait page showing the progress status (refreshing every 2 seconds
in my case), this seems incredibly inefficient.  Is there a way to avoid
this?  Am I setting up my Action flow incorrectly?

A sample of one of my Action setups in struts.xml:

 

/struts/contact/contactDelete_modal.jsp
/struts/common/error/error_modal.jsp
/struts/common/login/login_modal.jsp




0

/struts/contact/contactDelete_modal.jsp
/struts/common/progressMonitorWait_modal.jsp
/struts/common/progressMonitorSuccess_modal.jsp
/struts/common/error/error_modal.jsp
/struts/common/login/login_modal.jsp
  


Re: URI too long error when using ExecuteAndWait interceptor

2020-11-30 Thread Lukasz Lenart
I thought a bit about this problem and to be honest I didn't find a
better solution. It would require some selective logic which params
include, e.g:



Would that work for you?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

sob., 21 lis 2020 o 16:21 Burton Rhodes  napisał(a):
>
> I ended up replacing the  tag refresh method with javascript that
> parses the "url" variable and recreates a  element on the fly to
> submit via POST.
>
> On Fri, Nov 20, 2020 at 4:19 PM Burton Rhodes 
> wrote:
>
> > I have a page that submits a form via POST and uses the ExecuteAndWait
> > interceptor.  On the "wait" jsp I have:
> >
> > "/>
> >
> > However, the includeParams "all" is including all the POST form variables
> > (which there are many), and as a result, I am getting a "URI too long"
> > exception.  Is there an easy fix for this?  Can't believe I've never run
> > into this issue before.
> >
> > Many thanks.
> >

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



Re: URI too long error when using ExecuteAndWait interceptor

2020-11-21 Thread Burton Rhodes
I ended up replacing the  tag refresh method with javascript that
parses the "url" variable and recreates a  element on the fly to
submit via POST.

On Fri, Nov 20, 2020 at 4:19 PM Burton Rhodes 
wrote:

> I have a page that submits a form via POST and uses the ExecuteAndWait
> interceptor.  On the "wait" jsp I have:
>
> "/>
>
> However, the includeParams "all" is including all the POST form variables
> (which there are many), and as a result, I am getting a "URI too long"
> exception.  Is there an easy fix for this?  Can't believe I've never run
> into this issue before.
>
> Many thanks.
>


URI too long error when using ExecuteAndWait interceptor

2020-11-20 Thread Burton Rhodes
I have a page that submits a form via POST and uses the ExecuteAndWait
interceptor.  On the "wait" jsp I have:

"/>

However, the includeParams "all" is including all the POST form variables
(which there are many), and as a result, I am getting a "URI too long"
exception.  Is there an easy fix for this?  Can't believe I've never run
into this issue before.

Many thanks.


Re: i18n Interceptor cookie

2019-02-20 Thread Lukasz Lenart
śr., 20 lut 2019 o 13:21 Rita Brito  napisał(a):
> I am defining an i18n interceptor with  name="localeStorage">cookie so that a cookie with the user's
> selected language is stored.
>
> Everything is working fine if when I navigate in my domain (eg:
> my.domain.com/somepage.html).
>
> However, when navigating to a subdomain (eg:
> my.domain.com/subdomain/somepage.html), a new cookie is created with
> path=/subdomain and the previous one (path=/) is not overriden, due to
> having different paths (despite having the same name).
>
> My question is: is there a way of defining the cookie path other than
> having a custom i18n interceptor?

Sorry but not. You must redefine the interceptor and feel free to open
a ticket in JIRA to cover this case.
If overriding the interceptor you must just override the
"getLocaleHandler" method and implement your own "LocaleHandler".


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



i18n Interceptor cookie

2019-02-20 Thread Rita Brito

Hi,


I am defining an i18n interceptor with name="localeStorage">cookie so that a cookie with the user's 
selected language is stored.


Everything is working fine if when I navigate in my domain (eg: 
my.domain.com/somepage.html).


However, when navigating to a subdomain (eg: 
my.domain.com/subdomain/somepage.html), a new cookie is created with 
path=/subdomain and the previous one (path=/) is not overriden, due to 
having different paths (despite having the same name).


My question is: is there a way of defining the cookie path other than 
having a custom i18n interceptor?



Kind regards and thanks in advance,

--
Rita Brito
Software Developer, ITClinical


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



Re: default interceptor overriding parent package default interceptor

2018-12-17 Thread Steven Yang
thanks for the reply

i will look into it more

if problem persists, i will try to put a sample together.

On Mon, Dec 17, 2018 at 10:41 PM Lukasz Lenart 
wrote:

> This is strange, inheritance should work just one way. Can you prepare
> a small Maven based demo to demonstrate this behaviour?
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> śr., 12 gru 2018 o 10:26 Steven Yang  napisał(a):
> >
> > Hi
> > I have the following setup of my struts2 xml.
> >
> > in cus.xml
> > 
> >
> > ...no interceptors defined, using interceptors form defaultPackage
> >
> > in cus-cus.xml
> > 
> >
> >
> >   
> > new interceptors
> >   
> >   
> >   
> >
> >
> > But all now all the Actions defined in cus.xml uses the
> newInterceptorStack
> > as the default interceptor.
> > I only want the Actions defined in cus-cus.xml to use the
> > newInterceptorStack as the default interceptor.
> >
> > Using Struts 2.3.x
> >
> > Please advice
> >
> > Thanks
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


Re: default interceptor overriding parent package default interceptor

2018-12-17 Thread Lukasz Lenart
This is strange, inheritance should work just one way. Can you prepare
a small Maven based demo to demonstrate this behaviour?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

śr., 12 gru 2018 o 10:26 Steven Yang  napisał(a):
>
> Hi
> I have the following setup of my struts2 xml.
>
> in cus.xml
> 
>
> ...no interceptors defined, using interceptors form defaultPackage
>
> in cus-cus.xml
> 
>
>
>   
> new interceptors
>   
>   
>   
>
>
> But all now all the Actions defined in cus.xml uses the newInterceptorStack
> as the default interceptor.
> I only want the Actions defined in cus-cus.xml to use the
> newInterceptorStack as the default interceptor.
>
> Using Struts 2.3.x
>
> Please advice
>
> Thanks

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



RE: default interceptor overriding parent package default interceptor

2018-12-15 Thread Yasser Zamani
Hi Steven,

We have similar config at showcase [1]. I putted a breakpoint at [2]. It works 
as expected i.e. for "index" action it hits break point as not a first 
interceptor but for "skill/save" action it hits it as the first interceptor.

Does issue persist with latest Struts 2.3.x version? Could you check with 
latest 2.5.x version? If in both the issue persists, then you may miss 
something in your app or checking method.

Regards.

[1] 
https://github.com/apache/struts/blob/414719171ae14b215537c1c17f8e0e6d34ec5c19/apps/showcase/src/main/resources/struts.xml#L132
[2] 
https://github.com/apache/struts/blob/414719171ae14b215537c1c17f8e0e6d34ec5c19/core/src/main/java/org/apache/struts2/interceptor/CheckboxInterceptor.java#L62


>-Original Message-
>From: Steven Yang 
>Sent: Wednesday, December 12, 2018 12:56 PM
>To: Struts Users Mailing List 
>Subject: default interceptor overriding parent package default interceptor
>
>Hi
>I have the following setup of my struts2 xml.
>
>in cus.xml
>
>...no interceptors 
> defined,
>using interceptors form defaultPackage
>
>in cus-cus.xml
>
>   
>   
>  
>new interceptors
>  
>  
>  
>
>
>But all now all the Actions defined in cus.xml uses the newInterceptorStack as 
>the
>default interceptor.
>I only want the Actions defined in cus-cus.xml to use the newInterceptorStack 
>as
>the default interceptor.
>
>Using Struts 2.3.x
>
>Please advice
>
>Thanks


default interceptor overriding parent package default interceptor

2018-12-12 Thread Steven Yang
Hi
I have the following setup of my struts2 xml.

in cus.xml

   
...no interceptors defined, using interceptors form defaultPackage

in cus-cus.xml

   
   
  
new interceptors
  
  
  


But all now all the Actions defined in cus.xml uses the newInterceptorStack
as the default interceptor.
I only want the Actions defined in cus-cus.xml to use the
newInterceptorStack as the default interceptor.

Using Struts 2.3.x

Please advice

Thanks


Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-21 Thread Yasser Zamani


On 4/21/2018 3:05 PM, Martin Gainty wrote:
> i could'nt find it in servlet-api spec?
> 
> https://tomcat.apache.org/tomcat-8.0-doc/servletapi/javax/servlet/http/HttpServletResponse.html
> 
> HttpServletResponse (Servlet 3.1 API Documentation 
> ...
> tomcat.apache.org
> Extends the ServletResponse interface to provide HTTP-specific functionality 
> in sending a response. For example, it has methods to access HTTP headers and 
> cookies. The servlet container creates an HttpServletResponse object and 
> passes it as an argument to the servlet's service methods (doGet, doPost, 
> etc).
> 
> i did find sendLocalRedirect method in ATG Dynamo HttpServletResponse
> https://docs.oracle.com/cd/E23095_01/Platform.93/ATGProgGuide/html/s0803httpservletresponse01.html
> HttpServletResponse - 
> Oracle
> docs.oracle.com
> Set Response Codes. The response code for a request is a numeric value that 
> represents the status of the response. For example, 200 represents a 
> successful response, 404 represents a file not found, and so on.
> 
> 
> 
> 
> i didnt know struts2 supported ATG Dynamo sendLocalRedirect

I found something at [1]. Following is it's copied answer:

"For the redirected request to come back and attach to the same session,
it needs a session ID, usually carried in a JSESSIONID (or another name)
cookie or in the URL as a parameter.

This cookie or URL parameter should be added by the servlet container
and you should not have to add it yourself.

If you do not see the cookie in your browser, and you are not attaching
the JSESSIONID to the URL, then it is creating a new session with each
request, and not attaching to the same session."

Regards.

[1] https://stackoverflow.com/a/13462878/1362623

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



Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-21 Thread Martin Gainty
Hi Yassir

i could'nt find it in servlet-api spec?

https://tomcat.apache.org/tomcat-8.0-doc/servletapi/javax/servlet/http/HttpServletResponse.html

HttpServletResponse (Servlet 3.1 API Documentation 
...<https://tomcat.apache.org/tomcat-8.0-doc/servletapi/javax/servlet/http/HttpServletResponse.html>
tomcat.apache.org
Extends the ServletResponse interface to provide HTTP-specific functionality in 
sending a response. For example, it has methods to access HTTP headers and 
cookies. The servlet container creates an HttpServletResponse object and passes 
it as an argument to the servlet's service methods (doGet, doPost, etc).

i did find sendLocalRedirect method in ATG Dynamo HttpServletResponse
https://docs.oracle.com/cd/E23095_01/Platform.93/ATGProgGuide/html/s0803httpservletresponse01.html
HttpServletResponse - 
Oracle<https://docs.oracle.com/cd/E23095_01/Platform.93/ATGProgGuide/html/s0803httpservletresponse01.html>
docs.oracle.com
Set Response Codes. The response code for a request is a numeric value that 
represents the status of the response. For example, 200 represents a successful 
response, 404 represents a file not found, and so on.




i didnt know struts2 supported ATG Dynamo sendLocalRedirect

Thanks for the clarification


Regards

Martin Gainty
__




From: Yasser Zamani <yasser.zam...@live.com> on behalf of Yasser Zamani 
<yasserzam...@apache.org>
Sent: Wednesday, April 18, 2018 2:57 AM
To: user@struts.apache.org
Subject: Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters 
on refresh?



On 4/18/2018 1:21 AM, Martin Gainty wrote:
> MG>AFAIK a redirect terminates the old session and creates a new session

I think redirect to same domain:ip in same browser tab page should keep
session.

> MG>a better alternative is to implement ChainingInterceptor with  type="chain"> e.g.

As Struts uses action name for the key of the background process saved
into session, I think chain doesn't work for this requirement.

Regards.

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



Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-18 Thread Yasser Zamani


On 4/18/2018 5:27 PM, Martin Gainty wrote:
> MG2>some confusion on where session is accessed
>  * available. This is because actions are built on a single-thread model. The
>  * only way to pass data is through the session
> MG2>with chain interceptor

No it didn't mean "with chain interceptor" that you have added. It meant
the action1.execute (i.e. the Struts user him/herself) can store data in
session and can then retrieve them inside action2.execute after
redirect. It didn't mean Strut's RedirectAction result does these itself
i.e. access, read and pass all session data.

> MG2>Here is code that *should access session params* to pass to new 
> finalLocation (but session is not accessed?)

As mentioned above, we didn't mean RedirectAction result access, read
and pass all session data. The Struts user him/herself should store them
in action1.execute then redirect then access and read them in
action2.execute.

> MG2>
> //where the session *should* be accessed
> // public Map<String, ResultConfig> getResults()
> //i see ResultConfig here but no reference to session?

(Same as above)

> MG2>i found a testcase for redirect
> MG2>in this case a HTTPGet with appended params..but no session vars?

(Same as above)

> MG2>am i reading the code incorrectly?

No you're right that there is no session access but as mentioned above,
it's OK. There is no need to pass session data. They're always available
at server side.

Regards.

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



Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-18 Thread Martin Gainty
MG2>some confusion on where session is accessed


From: Yasser Zamani <yasser.zam...@live.com> on behalf of Yasser Zamani 
<yasserzam...@apache.org>
Sent: Wednesday, April 18, 2018 2:57 AM
To: user@struts.apache.org
Subject: Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters 
on refresh?



On 4/18/2018 1:21 AM, Martin Gainty wrote:
> MG>AFAIK a redirect terminates the old session and creates a new session

I think redirect to same domain:ip in same browser tab page should keep
session.

MG2>2 alternatives: build out HTTPGet with 

 * Calls the {@link HttpServletResponse#sendRedirect(String) sendRedirect}
 * method to the location specified. The response is told to redirect the
 * browser to the specified location (a new request from the client). The
 * consequence of doing this means that the action (action instance, action
 * errors, field errors, etc) that was just executed is lost and no longer
 * available. This is because actions are built on a single-thread model. The
 * only way to pass data is through the session
MG2>with chain interceptor

 * or with web parameters

 * (url?name=value) which can be OGNL expressions.
MG2>essentially a HTTP Get with params. here is example:
* 
 * !--
 *   The redirect URL generated will be:
 *   /foo.jsp#FRAGMENT
 * --
 * result name="success" type="redirect"
 *   param name="location"foo.jsp/param
 *   param name="parse"false/param
 *   param name="anchor"FRAGMENT/param
 * /result
 * 
MG2>

MG2>Here is code that *should access session params* to pass to new 
finalLocation (but session is not accessed?)
/**
 * Redirects to the location specified by calling
 * {@link HttpServletResponse#sendRedirect(String)}.
 *
 * @param finalLocation the location to redirect to.
 * @param invocation an encapsulation of the action execution state.
 * @throws Exception if an error occurs when redirecting.
 */
protected void doExecute(String finalLocation, ActionInvocation invocation) 
throws Exception {
ActionContext ctx = invocation.getInvocationContext();
HttpServletRequest request = (HttpServletRequest) 
ctx.get(ServletActionContext.HTTP_REQUEST);
HttpServletResponse response = (HttpServletResponse) 
ctx.get(ServletActionContext.HTTP_RESPONSE);

if (isPathUrl(finalLocation)) {
if (!finalLocation.startsWith("/")) {
ActionMapping mapping = actionMapper.getMapping(request, 
Dispatcher.getInstance().getConfigurationManager());
String namespace = null;
if (mapping != null) {
namespace = mapping.getNamespace();
}

if ((namespace != null) && (namespace.length() > 0) && 
(!"/".equals(namespace))) {
finalLocation = namespace + "/" + finalLocation;
} else {
finalLocation = "/" + finalLocation;
}
}

// if the URL's are relative to the servlet context, append 
(prepend) the servlet context path to finalLocation
if (prependServletContext && (request.getContextPath() != null) && 
(request.getContextPath().length() > 0)) {
finalLocation = request.getContextPath() + finalLocation;
}

MG2>
//where the session *should* be accessed
// public Map<String, ResultConfig> getResults()
//i see ResultConfig here but no reference to session?
//where in ResultConfig The Builder class I see
 /**
 * The builder for this object.  An instance of this object is the only way 
to construct a new instance.  The
 * purpose is to enforce the immutability of the object.
 * The methods are structured in a way to support chaining.
 * After setting any values you need, call the {@link #build()} method to 
create the object.
 */

MG2>

ResultConfig resultConfig = 
invocation.getProxy().getConfig().getResults().get(invocation.getResultCode());

if (resultConfig != null) {
Map<String, String> resultConfigParams = 
resultConfig.getParams();

List prohibitedResultParams = 
getProhibitedResultParams();
for (Map.Entry<String, String> e : 
resultConfigParams.entrySet()) {
if (!prohibitedResultParams.contains(e.getKey())) {
Collection values = 
conditionalParseCollection(e.getValue(), invocation, suppressEmptyParameters);
if (!suppressEmptyParameters || !values.isEmpty()) {
requestParameters.put(e.getKey(), values);
}
}
}
}

StringBuilder tmpLocation = new StringBuilder(finalLocation);
u

Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-18 Thread Yasser Zamani


On 4/18/2018 1:21 AM, Martin Gainty wrote:
> MG>AFAIK a redirect terminates the old session and creates a new session

I think redirect to same domain:ip in same browser tab page should keep
session.

> MG>a better alternative is to implement ChainingInterceptor with  type="chain"> e.g.

As Struts uses action name for the key of the background process saved
into session, I think chain doesn't work for this requirement.

Regards.

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



Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-17 Thread Martin Gainty



From: Burton Rhodes <burtonrho...@gmail.com>
Sent: Tuesday, April 17, 2018 7:23 AM
To: Struts Users Mailing List
Subject: Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters 
on refresh?

That's a great thought.  I think the session method makes more sense.

On Tue, Apr 17, 2018 at 2:12 AM, Yasser Zamani <yasserzam...@apache.org>
wrote:

>
>
> On 4/17/2018 6:42 AM, Burton Rhodes wrote:
> > Also, How would I include everything except the email body field with the
> > s:url tag?
>
> Unfortunately, I couldn't find a simple way :(
>
> However, as a workaround, instead, in your email form jsp, could you put
> the email body field as a POST param and the rest short fields which
> need validation as GET params (i.e. in a query string inside action url
> using s:url)? Because then you can use  content="3;url="/> which only counts GET
> params i.e. only query string which doesn't include email body but
> includes other validation needed fields.
>
> But if I were you, I prefer to use two actions for such requirement.
> action1 which doesn't have ExecAndWait interceptor but has others like
> validation, gets form data and stores them as a single object inside
> session with a unique key every-time i.e. a GUID. Then action1 redirects
> to action2 and also passes that key to action2. action2 behaves like a
> mail sender and only has ExecAndWait interceptor. action2 gets then
> deletes data from session by that key and the rest is same as your
> current single action :)

MG>AFAIK a redirect terminates the old session and creates a new session
MG>a better alternative is to implement ChainingInterceptor with  e.g.
MG>

 
 otherAction
 

 
 
 
 good_result.ftl
 
MG>
http://viralpatel.net/blogs/struts-2-action-chaining-example/
Struts 2 Action Chaining example - 
ViralPatel.net<http://viralpatel.net/blogs/struts-2-action-chaining-example/>
viralpatel.net
In Struts 2, sometimes you may want to process another action when one action 
completes. For example on successfully submitting a form you want to render 
output from other action.

MG>?

>
> Regards.
>


Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-17 Thread Yasser Zamani


On 4/17/2018 3:53 PM, Burton Rhodes wrote:
> That's a great thought.  I think the session method makes more sense.

Glad to hear :) thanks! I would like to add that you also can delete
ExecAndWait interceptor. Then just save posted data in db and
immediately send a thank you message to your user. Then check for and
send emails (e.g. each 10 minutes) e.g. using quartz jar.

Regards.


Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-17 Thread Burton Rhodes
That's a great thought.  I think the session method makes more sense.

On Tue, Apr 17, 2018 at 2:12 AM, Yasser Zamani <yasserzam...@apache.org>
wrote:

>
>
> On 4/17/2018 6:42 AM, Burton Rhodes wrote:
> > Also, How would I include everything except the email body field with the
> > s:url tag?
>
> Unfortunately, I couldn't find a simple way :(
>
> However, as a workaround, instead, in your email form jsp, could you put
> the email body field as a POST param and the rest short fields which
> need validation as GET params (i.e. in a query string inside action url
> using s:url)? Because then you can use  content="3;url="/> which only counts GET
> params i.e. only query string which doesn't include email body but
> includes other validation needed fields.
>
> But if I were you, I prefer to use two actions for such requirement.
> action1 which doesn't have ExecAndWait interceptor but has others like
> validation, gets form data and stores them as a single object inside
> session with a unique key every-time i.e. a GUID. Then action1 redirects
> to action2 and also passes that key to action2. action2 behaves like a
> mail sender and only has ExecAndWait interceptor. action2 gets then
> deletes data from session by that key and the rest is same as your
> current single action :)
>
> Regards.
>


Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-17 Thread Yasser Zamani


On 4/17/2018 6:42 AM, Burton Rhodes wrote:
> Also, How would I include everything except the email body field with the
> s:url tag?

Unfortunately, I couldn't find a simple way :(

However, as a workaround, instead, in your email form jsp, could you put
the email body field as a POST param and the rest short fields which
need validation as GET params (i.e. in a query string inside action url
using s:url)? Because then you can use "/> which only counts GET
params i.e. only query string which doesn't include email body but
includes other validation needed fields.

But if I were you, I prefer to use two actions for such requirement.
action1 which doesn't have ExecAndWait interceptor but has others like
validation, gets form data and stores them as a single object inside
session with a unique key every-time i.e. a GUID. Then action1 redirects
to action2 and also passes that key to action2. action2 behaves like a
mail sender and only has ExecAndWait interceptor. action2 gets then
deletes data from session by that key and the rest is same as your
current single action :)

Regards.


Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-16 Thread Burton Rhodes
Yes. I believe this is the case. Let me see if I can track down an example
that breaks. Right now I just have reports of this happening but I haven’t
been able to reproduce on my end yet.

Also, How would I include everything except the email body field with the
s:url tag?

Thanks,
Burton


On Monday, April 16, 2018, Yasser Zamani <yasserzam...@apache.org> wrote:

>
>
> On 4/15/2018 11:39 PM, Burton Rhodes wrote:
> > I have been getting "Bad Request" or "URL too long" errors on occasion
> for
> > an email form that uses the execute and wait interceptor.  I am using the
> >  to resubmit the form per the documentation.
> >
> > "/>
> >
> > However, the original form submits via POST and the meta tag uses GET
> which
> > I believe is the source of the issue.  I've tried the code below thinking
> > that I could omit all the parameters except the token, but this doesn't
> > seem to do the trick.  Struts wants the entire form (again) - without all
> > the parameters the validate methods fail for the action class.
> >
> > 
> > 
> > "/>
> >
> > Any ideas on how to implement execute and wait correctly without
> submitting
> > the entire form via GET parameters each time a refresh that happens?
>
> Could you try including all except the email body field? I guess this
> issue happens because the email body usually is too long to being
> included inside url query string. To confirm, could you increase refresh
> timeout to have time to right-click on your browser page then click view
> source? I'm interested what is generated by  content="3;url="/> there when there is a
> long email body posted!
>
> Thanks in advance!
>


Re: [S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-16 Thread Yasser Zamani


On 4/15/2018 11:39 PM, Burton Rhodes wrote:
> I have been getting "Bad Request" or "URL too long" errors on occasion for
> an email form that uses the execute and wait interceptor.  I am using the
>  to resubmit the form per the documentation.
> 
> "/>
> 
> However, the original form submits via POST and the meta tag uses GET which
> I believe is the source of the issue.  I've tried the code below thinking
> that I could omit all the parameters except the token, but this doesn't
> seem to do the trick.  Struts wants the entire form (again) - without all
> the parameters the validate methods fail for the action class.
> 
> 
> 
> "/>
> 
> Any ideas on how to implement execute and wait correctly without submitting
> the entire form via GET parameters each time a refresh that happens?

Could you try including all except the email body field? I guess this
issue happens because the email body usually is too long to being
included inside url query string. To confirm, could you increase refresh
timeout to have time to right-click on your browser page then click view
source? I'm interested what is generated by "/> there when there is a
long email body posted!

Thanks in advance!


[S2] ExecuteAndWait Interceptor // Only re-submit token parameters on refresh?

2018-04-15 Thread Burton Rhodes
I have been getting "Bad Request" or "URL too long" errors on occasion for
an email form that uses the execute and wait interceptor.  I am using the
 to resubmit the form per the documentation.

"/>

However, the original form submits via POST and the meta tag uses GET which
I believe is the source of the issue.  I've tried the code below thinking
that I could omit all the parameters except the token, but this doesn't
seem to do the trick.  Struts wants the entire form (again) - without all
the parameters the validate methods fail for the action class.



"/>

Any ideas on how to implement execute and wait correctly without submitting
the entire form via GET parameters each time a refresh that happens?

Thanks!
Burton


RE: Conversion Error Interceptor prevent errors for empty values

2018-02-15 Thread Paul Zepernick
Yasser,

Thanks for pointing me to the right class.  After debugging, I found the 
problem was in my template and it was including the option body in the value 
when trying to set it to empty.  There is no issue with the Interceptor and it 
is working as documented.  Thanks for your help.

Paul R. Zepernick
Sr. Programmer Analyst
HealthSmart Benefit Solutions

-Original Message-
From: Yasser Zamani [mailto:yasser.zam...@live.com] On Behalf Of Yasser Zamani
Sent: Wednesday, February 14, 2018 11:41 AM
To: user@struts.apache.org
Subject: Re: Conversion Error Interceptor prevent errors for empty values



On 2/14/2018 5:13 PM, Paul Zepernick wrote:
> Yes, I have it happening on 2.5.14.1.  I have a select box pointing at a 
> Integer like this: auditForm.incorrectAuditReason.id  I am using the rest 
> plugin which is including it in the stack.  I have attached the source from 
> Maven.  Where is the check being done in the code?  I see the check for 
> shouldAddError() always returning true.
>

No you should check
`org.apache.struts2.interceptor.StrutsConversionErrorInterceptor`
(prefixed with `Struts`) instead. Could you put a break point on it's 
`shouldAddError` method and see what happens when you post 
auditForm.incorrectAuditReason.id?

> I have attempted to override the default interceptor by adding this in my 
> package and overriding the shouldAddError(), but it continues to call the 
> default Struts ConversionErrorInterceptor.
>
>  class="com.hs.iws.struts2.IwsConversionErrorInterceptor"/>
>
I think you should define your stack including your new interceptor and ref it 
in your action definition.


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




Disclaimer: This communication and any files transmitted with it may contain 
information that is privileged, confidential and/or exempt from disclosure 
under applicable law. If you are not the intended recipient, you are hereby 
notified that any disclosure, copying, distribution, or use of the information 
contained herein (including any reliance thereon) is strictly prohibited. If 
you received this communication in error, please immediately contact the sender 
and destroy the material in its entirety, whether in electronic or hard copy 
format. Thank you.

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



Re: Conversion Error Interceptor prevent errors for empty values

2018-02-14 Thread Yasser Zamani


On 2/14/2018 5:13 PM, Paul Zepernick wrote:
> Yes, I have it happening on 2.5.14.1.  I have a select box pointing at a 
> Integer like this: auditForm.incorrectAuditReason.id  I am using the rest 
> plugin which is including it in the stack.  I have attached the source from 
> Maven.  Where is the check being done in the code?  I see the check for 
> shouldAddError() always returning true.
> 

No you should check
`org.apache.struts2.interceptor.StrutsConversionErrorInterceptor`
(prefixed with `Struts`) instead. Could you put a break point on it's
`shouldAddError` method and see what happens when you post
auditForm.incorrectAuditReason.id?

> I have attempted to override the default interceptor by adding this in my 
> package and overriding the shouldAddError(), but it continues to call the 
> default Struts ConversionErrorInterceptor.
> 
>  class="com.hs.iws.struts2.IwsConversionErrorInterceptor"/>
>
I think you should define your stack including your new interceptor and
ref it in your action definition.


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



RE: Conversion Error Interceptor prevent errors for empty values

2018-02-14 Thread Paul Zepernick
Trying the attachment again as a txt

Paul R. Zepernick
Sr. Programmer Analyst
HealthSmart Benefit Solutions

-Original Message-
From: Paul Zepernick [mailto:paul.zepern...@healthsmart.com] 
Sent: Wednesday, February 14, 2018 8:44 AM
To: user@struts.apache.org
Subject: RE: Conversion Error Interceptor prevent errors for empty values

Yes, I have it happening on 2.5.14.1.  I have a select box pointing at a 
Integer like this: auditForm.incorrectAuditReason.id  I am using the rest 
plugin which is including it in the stack.  I have attached the source from 
Maven.  Where is the check being done in the code?  I see the check for 
shouldAddError() always returning true.

I have attempted to override the default interceptor by adding this in my 
package and overriding the shouldAddError(), but it continues to call the 
default Struts ConversionErrorInterceptor.





Paul R. Zepernick
Sr. Programmer Analyst
HealthSmart Benefit Solutions

-Original Message-
From: Yasser Zamani [mailto:yasser.zam...@live.com] On Behalf Of Yasser Zamani
Sent: Wednesday, February 14, 2018 4:25 AM
To: user@struts.apache.org
Subject: Re: Conversion Error Interceptor prevent errors for empty values



On 2/13/2018 8:06 PM, Paul Zepernick wrote:
> Can someone provide some clarification on if this interceptor should be 
> adding a field error when an empty string is passed to a Integer in the 
> action?

No, it should not be happening for `conversionError` interceptor. Does it 
happen?

>   I am trying to prevent the field error from happening in this case.  It 
> looks like it should not be happening according to the docs: 
> https://struts.apache.org/core-developers/conversion-error-interceptor.html , 
> or am I not understanding what it is saying here:
>
> "This interceptor extends ConversionErrorInterceptor but only adds conversion 
> errors from the ActionContext to the field errors of the action if the field 
> value is not null, "", or {""} (a size 1 String array with only an empty 
> String). See ConversionErrorInterceptor for more information, as well as the 
> Type Conversion documentation"

You understood correctly. I reviewed it's code and looks like it should behave 
as above. Doesn't it?

I also saw `conversionError` is already included in default stack.


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




Disclaimer: This communication and any files transmitted with it may contain 
information that is privileged, confidential and/or exempt from disclosure 
under applicable law. If you are not the intended recipient, you are hereby 
notified that any disclosure, copying, distribution, or use of the information 
contained herein (including any reliance thereon) is strictly prohibited. If 
you received this communication in error, please immediately contact the sender 
and destroy the material in its entirety, whether in electronic or hard copy 
format. Thank you.

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package com.opensymphony.xwork2.interceptor;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.commons.lang3.StringEscapeUtils;

import java.util.HashMap;
import java.util.Map;


/**
 * 
 * ConversionErrorInterceptor adds conversion errors from the ActionContext to 
the Action's field errors.
 *
 * 
 * This interceptor adds any error found in the {@link ActionContext}'s 
conversionErrors map as a field error (provided
 * that the action implements {@link ValidationAware}). In addition, any field 
that contains a validation error has its
 * original value saved such that any subsequent requests for that value return 
the original value rather than the value
 * in the action. This is important because if the value "abc" is submitted and 
can't be converted to an int, we want to
 * display the original string ("abc") again rather than t

RE: Conversion Error Interceptor prevent errors for empty values

2018-02-14 Thread Paul Zepernick
Yes, I have it happening on 2.5.14.1.  I have a select box pointing at a 
Integer like this: auditForm.incorrectAuditReason.id  I am using the rest 
plugin which is including it in the stack.  I have attached the source from 
Maven.  Where is the check being done in the code?  I see the check for 
shouldAddError() always returning true.

I have attempted to override the default interceptor by adding this in my 
package and overriding the shouldAddError(), but it continues to call the 
default Struts ConversionErrorInterceptor.





Paul R. Zepernick
Sr. Programmer Analyst
HealthSmart Benefit Solutions

-Original Message-
From: Yasser Zamani [mailto:yasser.zam...@live.com] On Behalf Of Yasser Zamani
Sent: Wednesday, February 14, 2018 4:25 AM
To: user@struts.apache.org
Subject: Re: Conversion Error Interceptor prevent errors for empty values



On 2/13/2018 8:06 PM, Paul Zepernick wrote:
> Can someone provide some clarification on if this interceptor should be 
> adding a field error when an empty string is passed to a Integer in the 
> action?

No, it should not be happening for `conversionError` interceptor. Does it 
happen?

>   I am trying to prevent the field error from happening in this case.  It 
> looks like it should not be happening according to the docs: 
> https://struts.apache.org/core-developers/conversion-error-interceptor.html , 
> or am I not understanding what it is saying here:
>
> "This interceptor extends ConversionErrorInterceptor but only adds conversion 
> errors from the ActionContext to the field errors of the action if the field 
> value is not null, "", or {""} (a size 1 String array with only an empty 
> String). See ConversionErrorInterceptor for more information, as well as the 
> Type Conversion documentation"

You understood correctly. I reviewed it's code and looks like it should behave 
as above. Doesn't it?

I also saw `conversionError` is already included in default stack.


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




Disclaimer: This communication and any files transmitted with it may contain 
information that is privileged, confidential and/or exempt from disclosure 
under applicable law. If you are not the intended recipient, you are hereby 
notified that any disclosure, copying, distribution, or use of the information 
contained herein (including any reliance thereon) is strictly prohibited. If 
you received this communication in error, please immediately contact the sender 
and destroy the material in its entirety, whether in electronic or hard copy 
format. Thank you.


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

Re: Conversion Error Interceptor prevent errors for empty values

2018-02-14 Thread Yasser Zamani


On 2/13/2018 8:06 PM, Paul Zepernick wrote:
> Can someone provide some clarification on if this interceptor should be 
> adding a field error when an empty string is passed to a Integer in the 
> action?

No, it should not be happening for `conversionError` interceptor. Does
it happen?

>   I am trying to prevent the field error from happening in this case.  It 
> looks like it should not be happening according to the docs: 
> https://struts.apache.org/core-developers/conversion-error-interceptor.html , 
> or am I not understanding what it is saying here:
> 
> "This interceptor extends ConversionErrorInterceptor but only adds conversion 
> errors from the ActionContext to the field errors of the action if the field 
> value is not null, "", or {""} (a size 1 String array with only an empty 
> String). See ConversionErrorInterceptor for more information, as well as the 
> Type Conversion documentation"

You understood correctly. I reviewed it's code and looks like it should
behave as above. Doesn't it?

I also saw `conversionError` is already included in default stack.


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



Conversion Error Interceptor prevent errors for empty values

2018-02-13 Thread Paul Zepernick
Can someone provide some clarification on if this interceptor should be adding 
a field error when an empty string is passed to a Integer in the action?  I am 
trying to prevent the field error from happening in this case.  It looks like 
it should not be happening according to the docs: 
https://struts.apache.org/core-developers/conversion-error-interceptor.html , 
or am I not understanding what it is saying here:

"This interceptor extends ConversionErrorInterceptor but only adds conversion 
errors from the ActionContext to the field errors of the action if the field 
value is not null, "", or {""} (a size 1 String array with only an empty 
String). See ConversionErrorInterceptor for more information, as well as the 
Type Conversion documentation"

Paul R. Zepernick
Sr. Programmer Analyst
HealthSmart Benefit Solutions




Disclaimer: This communication and any files transmitted with it may contain 
information that is privileged, confidential and/or exempt from disclosure 
under applicable law. If you are not the intended recipient, you are hereby 
notified that any disclosure, copying, distribution, or use of the information 
contained herein (including any reliance thereon) is strictly prohibited. If 
you received this communication in error, please immediately contact the sender 
and destroy the material in its entirety, whether in electronic or hard copy 
format. Thank you.


Re: Interceptor implementing SessionAware interface

2017-12-03 Thread Yasser Zamani


On 12/4/2017 3:00 AM, saravana2...@gmail.com wrote:
> setSession() method is not called even after implementing sessionAware

ServletConfigInterceptor calls setSession but only on action, not on 
previous or next interceptors:

 if (action instanceof SessionAware) {
 ((SessionAware) action).setSession(context.getSession());
 }

I think you can rewrite your interceptor as below instead (like 
ServletConfigInterceptor):

public class SessionInterceptor extends AbstractInterceptor  {
SessionMap<String, Object> session;

@Override
public String intercept(ActionInvocation arg0) throws Exception
{
session = arg0.getInvocationContext().getSession();
//...
}

}


Interceptor implementing SessionAware interface

2017-12-03 Thread saravana2...@gmail.com
Hi,
I am trying to create custom interceptor which implements SessionAware 
interface to handle session management logic so that cross-cutting concern is 
not implemented Action class which is concentrating on core concern.
setSession() method is not called even after implementing sessionAware and even 
in struts website , suggestions given to implement in action class and not in 
Interceptor.

I went through some question in SO and it suggested to add servletconfig 
interceptor in struts.xml .But I don't know why to add it even though it's 
already part of default stack.

Struts.xml file :

http://struts.apache.org/dtds/struts-2.5.dtd;>


   
 

  
 
  
 



/signup.jsp


   /signup.jsp


/signup.jsp
/succcess.jsp

   


SessionInterceptor.java

package com.contacts.interceptors;

import java.util.Map;

import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class SessionInterceptor extends AbstractInterceptor  implements 
SessionAware  {
SessionMap<String, Object> session;

/**
 * 
 */
private static final long serialVersionUID = 1L;

@Override
public String intercept(ActionInvocation arg0) throws Exception {
// TODO Auto-generated method stub
//preprocessing
System.out.println("Pre-processing");
arg0.invoke();
System.out.println("Post-Processing");
return "SUCCESS";
}

@Override
public void setSession(Map<String, Object> session) {
// TODO Auto-generated method stub
System.out.println("Set Session Method");
this.session=(SessionMap<String,Object>) session;

}

}


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



Re: Setting interceptor param on package level

2017-07-31 Thread Lukasz Lenart
2017-07-29 10:26 GMT+02:00 Norbert Harrer <nhar...@gmx.at>:
> Hi.
>
> A question just out of curiosity. Is it possible to set an interceptor
> parameter on the package level.
>
> For example I have a couple interceptor stacks more or less like this:
>
> 
> 
> 
> 
> 
> true
> ERROR
> 
> 
> 
>
> I want the Parameters for the ExceptionMappingInterceptor to be present in
> all interceptor stacks:
>
> true
> ERROR
>
> Is it possible to set them somewhere just once on a global or package level?

You should be able to create a basic interceptors stack and use it in
your other stacks, so you can configure all the parameters in the
basic stack.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



Setting interceptor param on package level

2017-07-29 Thread Norbert Harrer

Hi.

A question just out of curiosity. Is it possible to set an interceptor 
parameter on the package level.


For example I have a couple interceptor stacks more or less like this:






true
ERROR




I want the Parameters for the ExceptionMappingInterceptor to be present 
in all interceptor stacks:


true
ERROR

Is it possible to set them somewhere just once on a global or package level?

Thanks!

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



Re: S2 String Trim Interceptor?

2017-04-24 Thread Lukasz Lenart
2017-04-21 15:53 GMT+02:00 Burton Rhodes <burtonrho...@gmail.com>:
> Since the invocation.getInvocationContext().getParameters().toMap() method
> is now deprecated, how would I refactor my String Trim interceptor to trim
> incoming parameters?  The HttpParameters parameter objects are designed to
> be "immutable".  Some posts online have suggested type converters, but
> seems like this is the perfect use for an interceptor.
>
> My trim interceptor code is below...
>
> protected String doIntercept(ActionInvocation invocation) throws Exception {
> Map<String, String[]> parameters =
> invocation.getInvocationContext().getParameters().toMap();
> for (String param : parameters.keySet()) {
> if (isIncluded(param)) {
> String[] values = parameters.get(param);
> for (int i = 0; i < values.length; i++) {
> values[i] = values[i].trim();
> }
> }
> }
>
> return invocation.invoke();
> }

HttpParameters httpParameters = HttpParameters.create(parameters).build();
invocation.getInvocationContext().setParameters(htttpParameters);

this should work.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



S2 String Trim Interceptor?

2017-04-21 Thread Burton Rhodes
Since the invocation.getInvocationContext().getParameters().toMap() method
is now deprecated, how would I refactor my String Trim interceptor to trim
incoming parameters?  The HttpParameters parameter objects are designed to
be "immutable".  Some posts online have suggested type converters, but
seems like this is the perfect use for an interceptor.

My trim interceptor code is below...

protected String doIntercept(ActionInvocation invocation) throws Exception {
Map<String, String[]> parameters =
invocation.getInvocationContext().getParameters().toMap();
for (String param : parameters.keySet()) {
if (isIncluded(param)) {
String[] values = parameters.get(param);
for (int i = 0; i < values.length; i++) {
values[i] = values[i].trim();
}
}
}

return invocation.invoke();
}

Thanks!


Re: What is the best way to get all JSON params in custom Interceptor to log them all in a custom logger ?

2017-04-06 Thread Christoph Nenning
> > > > > Hi,
> > > > > 
> > > > > AFAIK that is defined in servlet spec. Only parameters with 
> > > content-type "
> > > > > application/x-www-form-urlencoded" are made available via 
> > > getParameters(). 
> > > > > The struts method you mentioned just forwards to according 
method of 
> > > > > servlet api.
> > > > > 
> > > > > Your json data can only be read by consuming request 
inputstream. If 
> > > you 
> > > > > do so in your interceptor it is not available anymore to your 
actions 
> > > (or 
> > > > > struts json interceptor) so you must rewrite them, too.
> > > > > 
> > > > > Regards,
> > > > > Christoph
> > > > > 
> > > > > 
> > > > > 
> > > > > > From: "Snowball RC" <craf....@gmail.com>
> > > > > > To: <user@struts.apache.org>, 
> > > > > > Date: 23.03.2017 11:28
> > > > > > Subject: What is the best way to get all JSON params in custom 

> > > > > > Interceptor to log them all in a custom logger ?
> > > > > > 
> > > > > > Hi,
> > > > > > 
> > > > > > I am trying to implement a custom Interceptor to have a global 

> > > > > > custom "security" logger in my web app.
> > > > > > 
> > > > > > The target is to log all the datas sended to the server during 

> > > > > > update, save, delete etc... to have a custom logger for 
security 
> > > > > reasons.
> > > > > > 
> > > > > > In case of GET and POST (query string param or form data 
without 
> > > > > > json object) : 
> > > > > > HttpParameters httpParameters = 
> > > > > ActionContext.getContext().getParameters();
> > > > > > works fine.
> > > > > > 
> > > > > > But in case of json params in POST (request payload) the 
previous 
> > > > > > code doesn't works
> > > > > > when the params is serialize via : JSON.stringify(...)
> > > > > > 
> > > > > > code sample: 
> > > > > > jQuery.ajax({
> > > > > >type: 'POST', 
> > > > > >url: url, 
> > > > > >data: JSON.stringify(data),
> > > > > >dataType: 'json',
> > > > > >async: false ,
> > > > > >contentType: 'application/json; charset=utf-8',
> > > > > >success: function(){
> > > > > >self.load();
> > > > > >},
> > > > > >error: function(data) {
> > > > > >    if (data.responseText) {
> > > > > >   var error = JSON.parse(data.responseText);
> > > > > >}
> > > > > >}
> > > > > > 
> > > > > > My custom Interceptor is added at the end of my stack after 
the json
> > > > > > interceptor like this :
> > > > > > 
> > > > > >   application/json
> > > > > >   
> > > > > >   
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > 
-
> > > > > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > > > > > For additional commands, e-mail: user-h...@struts.apache.org
> > > > > > 
> > > > > 
> > > > > This Email was scanned by Sophos Anti Virus
> > > > > 
> > > > You are right I have tried to use "request.getReader()" and after 
> > > > the json object was not available anymore.
> > > > How can I rewrite them ? Should I do the same like in 
JSONInterceptor ?
> > > > 
> > > 
> > > 
> > > Well, when your interceptor reads the inputsream it has to preserve 
data 
> > > in memory in some way and your actions must read it from there.
> > > 
> > > You can try to copy the inputstream to a byte array first (by using 
> > > ByteArrayOutputStream) and wrap request.getInputStream() with a 
> > > ByteArrayInputStream pointing to same byte array. Of course that 
will 
> > > cause issues if your users upload large amount of data.
> > > 
> > > 
> > > Regards,
> > > Christoph
> > > 
> > > This Email was scanned by Sophos Anti Virus
> > > 
> > So It is possible in my web app to post large amount of data...
> > 
> > I am trying to use the reflexion API to retrieve all getter of 
> actions and then try to get one by one getters... 
> > 
> > I don't think if it's a better solution to do that.
> > 
> > -
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> > 
> > 
> Any other possibility to do that in Struts2 ?
> 


Well, doing it with reflection would mean to populate the action as ususal 
and logging it's values afterwards. IMO that should work. An issue could 
be that you don't log data which is present in JSON but not applied to 
actions.


Logging data from request body is general a hard issue for web 
applications, no matter what programming language or framework. A simple 
way to avoid the memory issue of my previous proposal would be to store 
data on disk (which introduces other issues of course).

Or if you use a reverse proxy like apache or nginx you could log data 
there.

Another option could be to check if your application server provides an 
option to log request data.


Regards,
Christoph

This Email was scanned by Sophos Anti Virus


Re: What is the best way to get all JSON params in custom Interceptor to log them all in a custom logger ?

2017-03-27 Thread Snowball RC


On 2017-03-23 14:28 (+0200), "Snowball RC"<craf@gmail.com> wrote: 
> 
> 
> On 2017-03-23 14:23 (+0100), Christoph Nenning 
> <christoph.nenn...@lex-com.net> wrote: 
> > > <christoph.nenn...@lex-com.net> wrote: 
> > > > Hi,
> > > > 
> > > > AFAIK that is defined in servlet spec. Only parameters with 
> > content-type "
> > > > application/x-www-form-urlencoded" are made available via 
> > getParameters(). 
> > > > The struts method you mentioned just forwards to according method of 
> > > > servlet api.
> > > > 
> > > > Your json data can only be read by consuming request inputstream. If 
> > you 
> > > > do so in your interceptor it is not available anymore to your actions 
> > (or 
> > > > struts json interceptor) so you must rewrite them, too.
> > > > 
> > > > Regards,
> > > > Christoph
> > > > 
> > > > 
> > > > 
> > > > > From: "Snowball RC" <craf@gmail.com>
> > > > > To: <user@struts.apache.org>, 
> > > > > Date: 23.03.2017 11:28
> > > > > Subject: What is the best way to get all JSON params in custom 
> > > > > Interceptor to log them all in a custom logger ?
> > > > > 
> > > > > Hi,
> > > > > 
> > > > > I am trying to implement a custom Interceptor to have a global 
> > > > > custom "security" logger in my web app.
> > > > > 
> > > > > The target is to log all the datas sended to the server during 
> > > > > update, save, delete etc... to have a custom logger for security 
> > > > reasons.
> > > > > 
> > > > > In case of GET and POST (query string param or form data without 
> > > > > json object) : 
> > > > > HttpParameters httpParameters = 
> > > > ActionContext.getContext().getParameters();
> > > > > works fine.
> > > > > 
> > > > > But in case of json params in POST (request payload) the previous 
> > > > > code doesn't works
> > > > > when the params is serialize via : JSON.stringify(...)
> > > > > 
> > > > > code sample: 
> > > > > jQuery.ajax({
> > > > >type: 'POST', 
> > > > >url: url, 
> > > > >data: JSON.stringify(data),
> > > > >dataType: 'json',
> > > > >async: false ,
> > > > >contentType: 'application/json; charset=utf-8',
> > > > >success: function(){
> > > > >self.load();
> > > > >},
> > > > >error: function(data) {
> > > > >if (data.responseText) {
> > > > >   var error = JSON.parse(data.responseText);
> > > > >}
> > > > >}
> > > > > 
> > > > > My custom Interceptor is added at the end of my stack after the json
> > > > > interceptor like this :
> > > > > 
> > > > >   application/json
> > > > >   
> > > > >   
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > -
> > > > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > > > > For additional commands, e-mail: user-h...@struts.apache.org
> > > > > 
> > > > 
> > > > This Email was scanned by Sophos Anti Virus
> > > > 
> > > You are right I have tried to use "request.getReader()" and after 
> > > the json object was not available anymore.
> > > How can I rewrite them ? Should I do the same like in JSONInterceptor ?
> > > 
> > 
> > 
> > Well, when your interceptor reads the inputsream it has to preserve data 
> > in memory in some way and your actions must read it from there.
> > 
> > You can try to copy the inputstream to a byte array first (by using 
> > ByteArrayOutputStream) and wrap request.getInputStream() with a 
> > ByteArrayInputStream pointing to same byte array. Of course that will 
> > cause issues if your users upload large amount of data.
> > 
> > 
> > Regards,
> > Christoph
> > 
> > This Email was scanned by Sophos Anti Virus
> > 
> So It is possible in my web app to post large amount of data...
> 
> I am trying to use the reflexion API to retrieve all getter of actions and 
> then try to get one by one getters... 
> 
> I don't think if it's a better solution to do that.
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
> 
Any other possibility to do that in Struts2 ?

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



Re: Passing a parameter from an interceptor to an action

2017-03-26 Thread Lukasz Lenart
2017-03-26 18:23 GMT+02:00 Heikki Hyyrö <heikki.hy...@uta.fi>:
> Hi,
>
> I would like to pass a parameter from an interceptor to an action, but am
> not sure what is a proper way to do it if I also want to ensure that a
> parameter with the same name cannot be injected into the action as a request
> parameter.
>
> I have set the interceptor to add the parameter into the valuestack, but
> this approach does not seem to work if the parameter name is included either
> in the excludeParams-parameter of the params interceptor or as a blocked
> parameter of the parameter filter. Either of these last two seems to prevent
> the parameter from being accessible by the action. If the params interceptor
> and parameter filter apply to _all_ values in the value stack, and not only
> request parameters, then is there some other route that allows to pass a
> "private" parameter from an interceptor to an action?

I would use a marking aware interface, the same as is done in Struts

https://struts.apache.org/maven/struts2-core/apidocs/org/apache/struts2/interceptor/package-summary.html


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



Passing a parameter from an interceptor to an action

2017-03-26 Thread Heikki Hyyrö

Hi,

I would like to pass a parameter from an interceptor to an action, but 
am not sure what is a proper way to do it if I also want to ensure that 
a parameter with the same name cannot be injected into the action as a 
request parameter.


I have set the interceptor to add the parameter into the valuestack, but 
this approach does not seem to work if the parameter name is included 
either in the excludeParams-parameter of the params interceptor or as a 
blocked parameter of the parameter filter. Either of these last two 
seems to prevent the parameter from being accessible by the action. If 
the params interceptor and parameter filter apply to _all_ values in the 
value stack, and not only request parameters, then is there some other 
route that allows to pass a "private" parameter from an interceptor to 
an action?


-Heikki


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



Re: What is the best way to get all JSON params in custom Interceptor to log them all in a custom logger ?

2017-03-23 Thread Snowball RC


On 2017-03-23 14:23 (+0100), Christoph Nenning <christoph.nenn...@lex-com.net> 
wrote: 
> > <christoph.nenn...@lex-com.net> wrote: 
> > > Hi,
> > > 
> > > AFAIK that is defined in servlet spec. Only parameters with 
> content-type "
> > > application/x-www-form-urlencoded" are made available via 
> getParameters(). 
> > > The struts method you mentioned just forwards to according method of 
> > > servlet api.
> > > 
> > > Your json data can only be read by consuming request inputstream. If 
> you 
> > > do so in your interceptor it is not available anymore to your actions 
> (or 
> > > struts json interceptor) so you must rewrite them, too.
> > > 
> > > Regards,
> > > Christoph
> > > 
> > > 
> > > 
> > > > From: "Snowball RC" <craf@gmail.com>
> > > > To: <user@struts.apache.org>, 
> > > > Date: 23.03.2017 11:28
> > > > Subject: What is the best way to get all JSON params in custom 
> > > > Interceptor to log them all in a custom logger ?
> > > > 
> > > > Hi,
> > > > 
> > > > I am trying to implement a custom Interceptor to have a global 
> > > > custom "security" logger in my web app.
> > > > 
> > > > The target is to log all the datas sended to the server during 
> > > > update, save, delete etc... to have a custom logger for security 
> > > reasons.
> > > > 
> > > > In case of GET and POST (query string param or form data without 
> > > > json object) : 
> > > > HttpParameters httpParameters = 
> > > ActionContext.getContext().getParameters();
> > > > works fine.
> > > > 
> > > > But in case of json params in POST (request payload) the previous 
> > > > code doesn't works
> > > > when the params is serialize via : JSON.stringify(...)
> > > > 
> > > > code sample: 
> > > > jQuery.ajax({
> > > >type: 'POST', 
> > > >url: url, 
> > > >data: JSON.stringify(data),
> > > >dataType: 'json',
> > > >async: false ,
> > > >contentType: 'application/json; charset=utf-8',
> > > >success: function(){
> > > >self.load();
> > > >},
> > > >error: function(data) {
> > > >if (data.responseText) {
> > > >   var error = JSON.parse(data.responseText);
> > > >}
> > > >}
> > > > 
> > > > My custom Interceptor is added at the end of my stack after the json
> > > > interceptor like this :
> > > > 
> > > >   application/json
> > > >   
> > > >   
> > > > 
> > > > 
> > > > 
> > > > 
> -
> > > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > > > For additional commands, e-mail: user-h...@struts.apache.org
> > > > 
> > > 
> > > This Email was scanned by Sophos Anti Virus
> > > 
> > You are right I have tried to use "request.getReader()" and after 
> > the json object was not available anymore.
> > How can I rewrite them ? Should I do the same like in JSONInterceptor ?
> > 
> 
> 
> Well, when your interceptor reads the inputsream it has to preserve data 
> in memory in some way and your actions must read it from there.
> 
> You can try to copy the inputstream to a byte array first (by using 
> ByteArrayOutputStream) and wrap request.getInputStream() with a 
> ByteArrayInputStream pointing to same byte array. Of course that will 
> cause issues if your users upload large amount of data.
> 
> 
> Regards,
> Christoph
> 
> This Email was scanned by Sophos Anti Virus
> 
So It is possible in my web app to post large amount of data...

I am trying to use the reflexion API to retrieve all getter of actions and then 
try to get one by one getters... 

I don't think if it's a better solution to do that.

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



Re: What is the best way to get all JSON params in custom Interceptor to log them all in a custom logger ?

2017-03-23 Thread Christoph Nenning
> <christoph.nenn...@lex-com.net> wrote: 
> > Hi,
> > 
> > AFAIK that is defined in servlet spec. Only parameters with 
content-type "
> > application/x-www-form-urlencoded" are made available via 
getParameters(). 
> > The struts method you mentioned just forwards to according method of 
> > servlet api.
> > 
> > Your json data can only be read by consuming request inputstream. If 
you 
> > do so in your interceptor it is not available anymore to your actions 
(or 
> > struts json interceptor) so you must rewrite them, too.
> > 
> > Regards,
> > Christoph
> > 
> > 
> > 
> > > From: "Snowball RC" <craf@gmail.com>
> > > To: <user@struts.apache.org>, 
> > > Date: 23.03.2017 11:28
> > > Subject: What is the best way to get all JSON params in custom 
> > > Interceptor to log them all in a custom logger ?
> > > 
> > > Hi,
> > > 
> > > I am trying to implement a custom Interceptor to have a global 
> > > custom "security" logger in my web app.
> > > 
> > > The target is to log all the datas sended to the server during 
> > > update, save, delete etc... to have a custom logger for security 
> > reasons.
> > > 
> > > In case of GET and POST (query string param or form data without 
> > > json object) : 
> > > HttpParameters httpParameters = 
> > ActionContext.getContext().getParameters();
> > > works fine.
> > > 
> > > But in case of json params in POST (request payload) the previous 
> > > code doesn't works
> > > when the params is serialize via : JSON.stringify(...)
> > > 
> > > code sample: 
> > > jQuery.ajax({
> > >type: 'POST', 
> > >url: url, 
> > >data: JSON.stringify(data),
> > >dataType: 'json',
> > >async: false ,
> > >contentType: 'application/json; charset=utf-8',
> > >success: function(){
> > >self.load();
> > >},
> > >error: function(data) {
> > >if (data.responseText) {
> > >   var error = JSON.parse(data.responseText);
> > >}
> > >}
> > > 
> > > My custom Interceptor is added at the end of my stack after the json
> > > interceptor like this :
> > > 
> > >   application/json
> > >   
> > >   
> > > 
> > > 
> > > 
> > > 
-
> > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > > For additional commands, e-mail: user-h...@struts.apache.org
> > > 
> > 
> > This Email was scanned by Sophos Anti Virus
> > 
> You are right I have tried to use "request.getReader()" and after 
> the json object was not available anymore.
> How can I rewrite them ? Should I do the same like in JSONInterceptor ?
> 


Well, when your interceptor reads the inputsream it has to preserve data 
in memory in some way and your actions must read it from there.

You can try to copy the inputstream to a byte array first (by using 
ByteArrayOutputStream) and wrap request.getInputStream() with a 
ByteArrayInputStream pointing to same byte array. Of course that will 
cause issues if your users upload large amount of data.


Regards,
Christoph

This Email was scanned by Sophos Anti Virus


Re: What is the best way to get all JSON params in custom Interceptor to log them all in a custom logger ?

2017-03-23 Thread Snowball RC


On 2017-03-23 14:04 (+0100), Christoph Nenning <christoph.nenn...@lex-com.net> 
wrote: 
> Hi,
> 
> AFAIK that is defined in servlet spec. Only parameters with content-type "
> application/x-www-form-urlencoded" are made available via getParameters(). 
> The struts method you mentioned just forwards to according method of 
> servlet api.
> 
> Your json data can only be read by consuming request inputstream. If you 
> do so in your interceptor it is not available anymore to your actions (or 
> struts json interceptor) so you must rewrite them, too.
> 
> Regards,
> Christoph
> 
> 
> 
> > From: "Snowball RC" <craf@gmail.com>
> > To: <user@struts.apache.org>, 
> > Date: 23.03.2017 11:28
> > Subject: What is the best way to get all JSON params in custom 
> > Interceptor to log them all in a custom logger ?
> > 
> > Hi,
> > 
> > I am trying to implement a custom Interceptor to have a global 
> > custom "security" logger in my web app.
> > 
> > The target is to log all the datas sended to the server during 
> > update, save, delete etc... to have a custom logger for security 
> reasons.
> > 
> > In case of GET and POST (query string param or form data without 
> > json object) : 
> > HttpParameters httpParameters = 
> ActionContext.getContext().getParameters();
> > works fine.
> > 
> > But in case of json params in POST (request payload) the previous 
> > code doesn't works
> > when the params is serialize via : JSON.stringify(...)
> > 
> > code sample: 
> > jQuery.ajax({
> >type: 'POST', 
> >url: url, 
> >data: JSON.stringify(data),
> >dataType: 'json',
> >async: false ,
> >    contentType: 'application/json; charset=utf-8',
> >success: function(){
> >self.load();
> >},
> >error: function(data) {
> >if (data.responseText) {
> >   var error = JSON.parse(data.responseText);
> >}
> >}
> > 
> > My custom Interceptor is added at the end of my stack after the json
> > interceptor like this :
> > 
> >   application/json
> >   
> >   
> > 
> > 
> > 
> > -
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> > 
> 
> This Email was scanned by Sophos Anti Virus
> 
You are right I have tried to use "request.getReader()" and after the json 
object was not available anymore.
How can I rewrite them ? Should I do the same like in JSONInterceptor ?

Regards,


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



Re: What is the best way to get all JSON params in custom Interceptor to log them all in a custom logger ?

2017-03-23 Thread Christoph Nenning
Hi,

AFAIK that is defined in servlet spec. Only parameters with content-type "
application/x-www-form-urlencoded" are made available via getParameters(). 
The struts method you mentioned just forwards to according method of 
servlet api.

Your json data can only be read by consuming request inputstream. If you 
do so in your interceptor it is not available anymore to your actions (or 
struts json interceptor) so you must rewrite them, too.

Regards,
Christoph



> From: "Snowball RC" <craf@gmail.com>
> To: <user@struts.apache.org>, 
> Date: 23.03.2017 11:28
> Subject: What is the best way to get all JSON params in custom 
> Interceptor to log them all in a custom logger ?
> 
> Hi,
> 
> I am trying to implement a custom Interceptor to have a global 
> custom "security" logger in my web app.
> 
> The target is to log all the datas sended to the server during 
> update, save, delete etc... to have a custom logger for security 
reasons.
> 
> In case of GET and POST (query string param or form data without 
> json object) : 
> HttpParameters httpParameters = 
ActionContext.getContext().getParameters();
> works fine.
> 
> But in case of json params in POST (request payload) the previous 
> code doesn't works
> when the params is serialize via : JSON.stringify(...)
> 
> code sample: 
> jQuery.ajax({
>type: 'POST', 
>url: url, 
>data: JSON.stringify(data),
>dataType: 'json',
>async: false ,
>contentType: 'application/json; charset=utf-8',
>success: function(){
>self.load();
>},
>    error: function(data) {
>if (data.responseText) {
>   var error = JSON.parse(data.responseText);
>}
>}
> 
> My custom Interceptor is added at the end of my stack after the json
> interceptor like this :
> 
>   application/json
>   
>   
> 
> 
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 

This Email was scanned by Sophos Anti Virus


What is the best way to get all JSON params in custom Interceptor to log them all in a custom logger ?

2017-03-23 Thread Snowball RC
Hi,

I am trying to implement a custom Interceptor to have a global custom 
"security" logger in my web app.

The target is to log all the datas sended to the server during update, save, 
delete etc... to have a custom logger for security reasons.

In case of GET and POST (query string param or form data without json object) : 
HttpParameters httpParameters = ActionContext.getContext().getParameters();
works fine.

But in case of json params in POST (request payload) the previous code doesn't 
works
when the params is serialize via : JSON.stringify(...)

code sample: 
jQuery.ajax({
type: 'POST', 
url: url, 
data: JSON.stringify(data),
dataType: 'json',
async: false ,
contentType: 'application/json; charset=utf-8',
success: function(){
 self.load();
},
error: function(data) {
 if (data.responseText) {
 var error = JSON.parse(data.responseText);
 }
}

My custom Interceptor is added at the end of my stack after the json 
interceptor like this :

application/json





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



Re: I18N Interceptor Change

2016-08-16 Thread Johannes Geppert
HI Zoran,

can you please register an Issue for this request?

https://issues.apache.org/jira/browse/WW

Thank you

Johannes

#
web: http://www.jgeppert.com
twitter: http://twitter.com/jogep


2016-08-16 12:06 GMT+02:00 Zoran Avtarovski <zo...@sparecreative.com>:

> HI Guys,
>
>
>
> We have an old project which has been happily working for years. Recently
> we updated it to 2.5.x which was surprisingly easy.
>
>
>
> One issue we did run into which was quite annoying was the I18N
> Interceptor now validates locales against the list of default available
> locales in this bit of code:
>
>
>
> if (locale != null && 
> !Arrays.asList(Locale.getAvailableLocales()).contains(locale))
> {
>
> locale = Locale.getDefault();
>
> }
>
>
>
> The problem is our app is for refugees and not all the languages in in the
> available locales array. This must be relatively new as it worked in the
> old version 2.x ish.
>
>
>
> As a work-around we over-rode the standard interceptor without the
> validation but I wanted to ask if the sore team could use a parameter to
> bi-pass the validation.
>
>
>
> For example a tag in the struts.xml file:
>
>
>
> 
>
>   
>
>  false
>
>   
>
> 
>
>
>
> and then access it in the interceptor.
>
>
>
> Z.
>
>


I18N Interceptor Change

2016-08-16 Thread Zoran Avtarovski
HI Guys,

 

We have an old project which has been happily working for years. Recently we 
updated it to 2.5.x which was surprisingly easy.

 

One issue we did run into which was quite annoying was the I18N Interceptor now 
validates locales against the list of default available locales in this bit of 
code:

 

if (locale != null && 
!Arrays.asList(Locale.getAvailableLocales()).contains(locale)) {

    locale = Locale.getDefault();

}

 

The problem is our app is for refugees and not all the languages in in the 
available locales array. This must be relatively new as it worked in the old 
version 2.x ish.

 

As a work-around we over-rode the standard interceptor without the validation 
but I wanted to ask if the sore team could use a parameter to bi-pass the 
validation.

 

For example a tag in the struts.xml file:

 



  

 false

  



 

and then access it in the interceptor.

 

Z.



Re: Passing Query String to Action through Interceptor

2016-05-23 Thread Nick Broadhurst
Wow!

I am embarrassed I did not know that and had not come across it yet. Of
course it resolved the issue.

Thank you very much,

Nick

On Mon, May 23, 2016 at 1:39 AM, Lukasz Lenart <lukaszlen...@apache.org>
wrote:

> 2016-05-23 3:01 GMT+02:00 Nick Broadhurst <hou1...@gmail.com>:
> > Hello,
> >
> > I have an interceptor that is working fine except the query string is not
> > being passed on to the action from the interceptor.
> >
> > 
> > 
>
> This will overwrite defined default stack - you can create a custom
> stack or add reference to existing stack
>
> 
> 
> 
> iro/IroCaseFORM.jsp
>  
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


Re: Passing Query String to Action through Interceptor

2016-05-23 Thread Lukasz Lenart
2016-05-23 3:01 GMT+02:00 Nick Broadhurst <hou1...@gmail.com>:
> Hello,
>
> I have an interceptor that is working fine except the query string is not
> being passed on to the action from the interceptor.
>
> 
> 

This will overwrite defined default stack - you can create a custom
stack or add reference to existing stack




iro/IroCaseFORM.jsp
 


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



Passing Query String to Action through Interceptor

2016-05-22 Thread Nick Broadhurst
Hello,

I have an interceptor that is working fine except the query string is not
being passed on to the action from the interceptor.



iro/IroCaseFORM.jsp
 


URL: http:///EditIroCase.action?id=123

Action is an existing one that I am adding the interceptor to. Implementing
ParamAware to get ID from URL and that works fine. Tried a couple different
things, but can't seem to make it work. Used lots of interceptors, just
never needed to maintain a param across its execution.

Thanks,

Nick


RE: Token Interceptor between Struts1 and Sturts2

2016-04-13 Thread Dhandapani, Rajeswaran
Thank you so much Chris.

With the TokenHelper class we resolved the issue.  Actually we do keep the s1 
and s2 action separate in our apps. But this is special situation.

Regards,
Rajeswaran D

-Original Message-
From: Christoph Nenning [mailto:christoph.nenn...@lex-com.net] 
Sent: Tuesday, April 12, 2016 1:31 PM
To: Struts Users Mailing List
Subject: Re: Token Interceptor between Struts1 and Sturts2

> Hi,
> 
> We have a form in JSP rendered by Struts1 action class.
> 
> But the form is submitted to the Struts2 action class which is 
> configured with Struts2 Token Interceptor.
> 
> Is there any way to generate a struts2 token inside struts1 JSP file?
> 
> Thanks & Regards,
> Rajeswaran D
> 

Hi,

you can invoke TokenHelper.setToken() from your struts1 code to generate it. In 
our apps that migrate from s1 to s2 we usually don't do things like that. We 
let one form be handled by one action. And migrate the wohle form/action to s2.



Regards,
Christoph

This Email was scanned by Sophos Anti Virus

**
This message and any files or attachments sent with this message contain 
confidential information and is intended only for the individual named.  If you 
are not the named addressee, you should not disseminate, distribute, copy or 
use any part of this email.  If you have received this message in error, please 
delete it and all copies from your system and notify the sender immediately by 
return Email.

Email transmission cannot be guaranteed to be secure or error-free as 
information can be intercepted, corrupted, lost, destroyed, late, incomplete or 
may contain viruses.  The sender, therefore, does not accept liability for any 
errors or omissions in the contents of this message, which arise as a result of 
email transmission.
**

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



Re: Token Interceptor between Struts1 and Sturts2

2016-04-12 Thread Christoph Nenning
> Hi,
> 
> We have a form in JSP rendered by Struts1 action class.
> 
> But the form is submitted to the Struts2 action class which is 
> configured with Struts2 Token Interceptor.
> 
> Is there any way to generate a struts2 token inside struts1 JSP file?
> 
> Thanks & Regards,
> Rajeswaran D
> 

Hi,

you can invoke TokenHelper.setToken() from your struts1 code to generate 
it. In our apps that migrate from s1 to s2 we usually don't do things like 
that. We let one form be handled by one action. And migrate the wohle 
form/action to s2.



Regards,
Christoph

This Email was scanned by Sophos Anti Virus


Token Interceptor between Struts1 and Sturts2

2016-04-11 Thread Dhandapani, Rajeswaran
Hi,

We have a form in JSP rendered by Struts1 action class.

But the form is submitted to the Struts2 action class which is configured with 
Struts2 Token Interceptor.

Is there any way to generate a struts2 token inside struts1 JSP file?

Thanks & Regards,
Rajeswaran D

**
This message and any files or attachments sent with this message contain 
confidential information and is intended only for the individual named.  If you 
are not the named addressee, you should not disseminate, distribute, copy or 
use any part of this email.  If you have received this message in error, please 
delete it and all copies from your system and notify the sender immediately by 
return Email.

Email transmission cannot be guaranteed to be secure or error-free as 
information can be intercepted, corrupted, lost, destroyed, late, incomplete or 
may contain viruses.  The sender, therefore, does not accept liability for any 
errors or omissions in the contents of this message, which arise as a result of 
email transmission.
**

RE: struts2 interceptor session timeout with ajax

2016-03-30 Thread Martin Gainty
MG>pls see below

> From: lukaszlen...@apache.org
> Date: Wed, 30 Mar 2016 07:59:28 +0200
> Subject: Re: struts2 interceptor session timeout with ajax
> To: user@struts.apache.org
> 
> I think you must use `onSuccessTopics` instead of `onErrorTopics` -
> returning 403 doesn't mean an error

MG>if browser client sees 403 you will want to redirect to a Secure SSL3/TLS 
connection index.jsp default page with username/password fields
MG>FYI: tomcat Connector can define a secure port for redirects on the 
connection via attribute  redirectPort="8443"
http://stackoverflow.com/questions/24736543/tomcat-7-automatically-redirect-https-requests-to-port-8443
> 
> 2016-03-29 21:59 GMT+02:00 fea jabi <zy...@hotmail.com>:
> > Thanks, it worked but now trying this and not sure how to fix this.
> >
> > Have a  on a page.
> > After session timeout trying to click on another tab of tabbed panel should 
> > redirect the user to login page.
> >  panel not firing the onErrorTopics. The javascript function is 
> > not getting called. The server is sending result 403. Please see below and 
> > guide me on how to fix this issue. I am seeing in fire bug that the 403 
> > error is thrown but I am unable to catch it in jsp. Need help with the same.
> >
> > struts.xml
> >
> >  > class="com.xxx.secondPanelAction">
> > 
> >
> > /jsp/secondPanel.jsp
> > 
> > 403
> > User session expired  
> > 
> > 
> > 
> >
> > jsp
> >
> >  > hide="'fade'" collapsible="true" sortable="true" onErrorTopics="loadError">
> >  > onErrorTopics="loadError"/>
> >  > onErrorTopics="loadError"/>
> > 
> >
> > 
> > $(document).ready(function() {
> >   $.subscribe('loadError', function(event, status, data) { 
> > alert('in error');
> >   var status1 = event.status;
> >
> >   if(status1 == 403 ) {
> >   window.location.href = "/Sample/login.action";
> >   }
> > });
> > 
> >
> >
> >
> >
> >
> >
> >
> > ________
> > From: Lukasz Lenart <lukaszlen...@apache.org>
> > Sent: Friday, March 11, 2016 2:21 PM
> > To: Struts Users Mailing List
> > Subject: Re: struts2 interceptor session timeout with ajax
> >
> > It won't work that way, when using Ajax you must use Ajax to redirect
> > to a login page. You can use something like this
> >
> > http://cypressnorth.com/programming/global-ajax-error-handling-with-jquery/
> >
> > so your interceptor must return 403 status code (it can return also an
> > url to login page to redirect to) and you must handle redirect on
> > client side
> >
> >
> > Regards
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > 2016-03-11 15:31 GMT+01:00 fea jabi <zy...@hotmail.com>:
> >> Need help with this please.
> >>
> >> 
> >> From: fea jabi <zy...@hotmail.com>
> >> Sent: Wednesday, March 9, 2016 10:51 AM
> >> To: user@struts.apache.org
> >> Subject: struts2 interceptor session timeout with ajax
> >>
> >> Have jquery tabbed panel in a jsp page which has a button to Save the form 
> >> in the tabbed panel which is making an ajax call and is working fine.
> >>
> >> Now trying to implement the session management for all requests in the 
> >> application and imlemented the new interceptor to perform the same. Having 
> >> issue with session management with the ajax calls. Have the below package 
> >> for ajax requests in which configured the new interceptor created and the 
> >> default interceptor. But, the below is not redirecting to the login page 
> >> instead opening the popup with login page html in it. what am I missing 
> >> here?
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> true
> >>
> >> true
> >>
> >> jsonResult
> >>
> >> 
> >>
> >> 
> >>
> >> appLogin
> >>
> >> /
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >> 
> >>
> >>
> >> -
> >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> >> For additional commands, e-mail: user-h...@struts.apache.org
> >>
> >
> > -
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> >
> >
> > -
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> >
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
  

Re: struts2 interceptor session timeout with ajax

2016-03-30 Thread Lukasz Lenart
I think you must use `onSuccessTopics` instead of `onErrorTopics` -
returning 403 doesn't mean an error

2016-03-29 21:59 GMT+02:00 fea jabi <zy...@hotmail.com>:
> Thanks, it worked but now trying this and not sure how to fix this.
>
> Have a  on a page.
> After session timeout trying to click on another tab of tabbed panel should 
> redirect the user to login page.
>  panel not firing the onErrorTopics. The javascript function is 
> not getting called. The server is sending result 403. Please see below and 
> guide me on how to fix this issue. I am seeing in fire bug that the 403 error 
> is thrown but I am unable to catch it in jsp. Need help with the same.
>
> struts.xml
>
> 
> 
>
> /jsp/secondPanel.jsp
> 
> 403
> User session expired  
> 
> 
> 
>
> jsp
>
>  hide="'fade'" collapsible="true" sortable="true" onErrorTopics="loadError">
>  onErrorTopics="loadError"/>
>  onErrorTopics="loadError"/>
> 
>
> 
> $(document).ready(function() {
>   $.subscribe('loadError', function(event, status, data) { 
> alert('in error');
>   var status1 = event.status;
>
>   if(status1 == 403 ) {
>   window.location.href = "/Sample/login.action";
>   }
> });
> 
>
>
>
>
>
>
>
> 
> From: Lukasz Lenart <lukaszlen...@apache.org>
> Sent: Friday, March 11, 2016 2:21 PM
> To: Struts Users Mailing List
> Subject: Re: struts2 interceptor session timeout with ajax
>
> It won't work that way, when using Ajax you must use Ajax to redirect
> to a login page. You can use something like this
>
> http://cypressnorth.com/programming/global-ajax-error-handling-with-jquery/
>
> so your interceptor must return 403 status code (it can return also an
> url to login page to redirect to) and you must handle redirect on
> client side
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> 2016-03-11 15:31 GMT+01:00 fea jabi <zy...@hotmail.com>:
>> Need help with this please.
>>
>> 
>> From: fea jabi <zy...@hotmail.com>
>> Sent: Wednesday, March 9, 2016 10:51 AM
>> To: user@struts.apache.org
>> Subject: struts2 interceptor session timeout with ajax
>>
>> Have jquery tabbed panel in a jsp page which has a button to Save the form 
>> in the tabbed panel which is making an ajax call and is working fine.
>>
>> Now trying to implement the session management for all requests in the 
>> application and imlemented the new interceptor to perform the same. Having 
>> issue with session management with the ajax calls. Have the below package 
>> for ajax requests in which configured the new interceptor created and the 
>> default interceptor. But, the below is not redirecting to the login page 
>> instead opening the popup with login page html in it. what am I missing here?
>>
>> 
>>
>> 
>>
>> 
>>
>> 
>>
>> 
>>
>> 
>>
>> 
>>
>> 
>>
>> 
>>
>> 
>>
>> 
>>
>> 
>>
>> true
>>
>> true
>>
>> jsonResult
>>
>> 
>>
>> 
>>
>> appLogin
>>
>> /
>>
>> 
>>
>> 
>>
>> 
>>
>> 
>>
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>

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



Re: struts2 interceptor session timeout with ajax

2016-03-29 Thread fea jabi
Thanks, it worked but now trying this and not sure how to fix this. 

Have a  on a page.
After session timeout trying to click on another tab of tabbed panel should 
redirect the user to login page. 
 panel not firing the onErrorTopics. The javascript function is not 
getting called. The server is sending result 403. Please see below and guide me 
on how to fix this issue. I am seeing in fire bug that the 403 error is thrown 
but I am unable to catch it in jsp. Need help with the same.

struts.xml




/jsp/secondPanel.jsp 

403
User session expired  




jsp







$(document).ready(function() {  
  $.subscribe('loadError', function(event, status, data) { 
alert('in error');
  var status1 = event.status;

  if(status1 == 403 ) {
  window.location.href = "/Sample/login.action";
  }
}); 









From: Lukasz Lenart <lukaszlen...@apache.org>
Sent: Friday, March 11, 2016 2:21 PM
To: Struts Users Mailing List
Subject: Re: struts2 interceptor session timeout with ajax

It won't work that way, when using Ajax you must use Ajax to redirect
to a login page. You can use something like this

http://cypressnorth.com/programming/global-ajax-error-handling-with-jquery/

so your interceptor must return 403 status code (it can return also an
url to login page to redirect to) and you must handle redirect on
client side


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2016-03-11 15:31 GMT+01:00 fea jabi <zy...@hotmail.com>:
> Need help with this please.
>
> 
> From: fea jabi <zy...@hotmail.com>
> Sent: Wednesday, March 9, 2016 10:51 AM
> To: user@struts.apache.org
> Subject: struts2 interceptor session timeout with ajax
>
> Have jquery tabbed panel in a jsp page which has a button to Save the form in 
> the tabbed panel which is making an ajax call and is working fine.
>
> Now trying to implement the session management for all requests in the 
> application and imlemented the new interceptor to perform the same. Having 
> issue with session management with the ajax calls. Have the below package for 
> ajax requests in which configured the new interceptor created and the default 
> interceptor. But, the below is not redirecting to the login page instead 
> opening the popup with login page html in it. what am I missing here?
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> true
>
> true
>
> jsonResult
>
> 
>
> 
>
> appLogin
>
> /
>
> 
>
> 
>
> 
>
> 
>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>

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


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



Re: struts2 interceptor session timeout with ajax

2016-03-11 Thread Lukasz Lenart
It won't work that way, when using Ajax you must use Ajax to redirect
to a login page. You can use something like this

http://cypressnorth.com/programming/global-ajax-error-handling-with-jquery/

so your interceptor must return 403 status code (it can return also an
url to login page to redirect to) and you must handle redirect on
client side


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

2016-03-11 15:31 GMT+01:00 fea jabi <zy...@hotmail.com>:
> Need help with this please.
>
> 
> From: fea jabi <zy...@hotmail.com>
> Sent: Wednesday, March 9, 2016 10:51 AM
> To: user@struts.apache.org
> Subject: struts2 interceptor session timeout with ajax
>
> Have jquery tabbed panel in a jsp page which has a button to Save the form in 
> the tabbed panel which is making an ajax call and is working fine.
>
> Now trying to implement the session management for all requests in the 
> application and imlemented the new interceptor to perform the same. Having 
> issue with session management with the ajax calls. Have the below package for 
> ajax requests in which configured the new interceptor created and the default 
> interceptor. But, the below is not redirecting to the login page instead 
> opening the popup with login page html in it. what am I missing here?
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> 
>
> true
>
> true
>
> jsonResult
>
> 
>
> 
>
> appLogin
>
> /
>
> 
>
> 
>
> 
>
> 
>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>

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



Re: struts2 interceptor session timeout with ajax

2016-03-11 Thread fea jabi
Need help with this please.


From: fea jabi <zy...@hotmail.com>
Sent: Wednesday, March 9, 2016 10:51 AM
To: user@struts.apache.org
Subject: struts2 interceptor session timeout with ajax

Have jquery tabbed panel in a jsp page which has a button to Save the form in 
the tabbed panel which is making an ajax call and is working fine.

Now trying to implement the session management for all requests in the 
application and imlemented the new interceptor to perform the same. Having 
issue with session management with the ajax calls. Have the below package for 
ajax requests in which configured the new interceptor created and the default 
interceptor. But, the below is not redirecting to the login page instead 
opening the popup with login page html in it. what am I missing here?

























true

true

jsonResult





appLogin

/










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



struts2 interceptor session timeout with ajax

2016-03-09 Thread fea jabi
Have jquery tabbed panel in a jsp page which has a button to Save the form in 
the tabbed panel which is making an ajax call and is working fine.

Now trying to implement the session management for all requests in the 
application and imlemented the new interceptor to perform the same. Having 
issue with session management with the ajax calls. Have the below package for 
ajax requests in which configured the new interceptor created and the default 
interceptor. But, the below is not redirecting to the login page instead 
opening the popup with login page html in it. what am I missing here?

























true

true

jsonResult





appLogin

/











Re: S2: How to tell if a response has been committed from an interceptor?

2016-01-07 Thread Christoph Nenning
> Inside an Interceptor I'm getting an exception
> 
> java.lang.IllegalStateException: Cannot create a session after the 
response
> has been committed
> I have access to the ActionInvocation as this is passed into 
doIntercept()
> public String doIntercept(ActionInvocation invocation) throws Exception
> 
> My question is: from the ActionInvocation how do I find out if the 
response
> has been committed?
> 
> Can I get the HttpServletResponse? So I can call response.isCommitted() 
?
> 
> How?
> 


If you really need access to Response you can get it via a static method 
in ServletActionContext.



Regards,
Christoph

This Email was scanned by Sophos Anti Virus


S2: How to tell if a response has been committed from an interceptor?

2016-01-06 Thread Greg Lindholm
Inside an Interceptor I'm getting an exception

java.lang.IllegalStateException: Cannot create a session after the response
has been committed
I have access to the ActionInvocation as this is passed into doIntercept()
public String doIntercept(ActionInvocation invocation) throws Exception

My question is: from the ActionInvocation how do I find out if the response
has been committed?

Can I get the HttpServletResponse? So I can call response.isCommitted() ?

How?

Thanks,
Greg


Re: S2: How to tell if a response has been committed from an interceptor?

2016-01-06 Thread Ken McWilliams
Well you go down the chain create the result and then back up the chain.
So when going back up the response should already be committed.

see: https://struts.apache.org/docs/writing-interceptors.html

//modified code from above link to clarify
public String intercept(ActionInvocation invocation) throws Exception {
   //do stuff before response, going down the chain
   String result = invocation.invoke();
   //do stuff after response, going back up the chain, can't do what
you seem to be trying to do here...
   return result;
}

That aside, "Cannot create a session" isn't a good message because you
shouldn't be trying to create a session at all! It's part of the containers
responsibility to do that. You just ask for it. So the real cause of the
issue might be something else.

On Wed, Jan 6, 2016 at 11:41 AM, Greg Lindholm <greg.lindh...@gmail.com>
wrote:

> Inside an Interceptor I'm getting an exception
>
> java.lang.IllegalStateException: Cannot create a session after the response
> has been committed
> I have access to the ActionInvocation as this is passed into doIntercept()
> public String doIntercept(ActionInvocation invocation) throws Exception
>
> My question is: from the ActionInvocation how do I find out if the response
> has been committed?
>
> Can I get the HttpServletResponse? So I can call response.isCommitted() ?
>
> How?
>
> Thanks,
> Greg
>


Re: Obtain the ServletContext in Interceptor init method

2015-11-22 Thread Lukasz Lenart
2015-11-20 23:01 GMT+01:00 Christopher Schultz :
> Is it possible to get the ServletContext from an Interceptor's init()
> method? I'd like to use it for some one-time initialization rather than
> grabbing it during the interceptor's intercept() method and either
> attempt one-time initialization or repeated-initialization.

Use ServletActionContext.getServletContext()


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



Obtain the ServletContext in Interceptor init method

2015-11-20 Thread Christopher Schultz
All,

Is it possible to get the ServletContext from an Interceptor's init()
method? I'd like to use it for some one-time initialization rather than
grabbing it during the interceptor's intercept() method and either
attempt one-time initialization or repeated-initialization.

Thanks,
-chris

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



How to add a global interceptor

2015-10-13 Thread Jasper Rosenberg
Hi,


 
I work on a project with hundreds of struts actions manywith their own custom 
interceptor stacks specified.  


 
We have recently internationalized the site, and so I had aneed to add an i18n 
interceptor to the top of every action stack.  It would have been impractical 
(and difficultto enforce for future actions) to add the new interceptor to 
every actiondefinition.


 
My solution was to override the ActionProxyFactory to returnour own 
ActionInvocation, which in turn always prepends the i18n interceptor tothe 
interceptor stack during initialization. 


 
I submitted a patch to make this extension simpler: 
https://issues.apache.org/jira/browse/WW-4553


 
However, it was suggested in the comments for this JIRA thatthere might be 
alternative methods to achieve my goal and to ask on this emaillist.  Thanks in 
advance for any advice!


 
-Jasper



Re: How to add a global interceptor

2015-10-13 Thread Christoph Nenning
> From: Jasper Rosenberg <jasper_rosenb...@yahoo.com.INVALID>
> To: "user@struts.apache.org" <user@struts.apache.org>, 
> Date: 13.10.2015 13:26
> Subject: How to add a global interceptor
> 
> Hi,
> 
> 
>  
> I work on a project with hundreds of struts actions manywith their 
> own custom interceptor stacks specified.  
> 

Having actions with own interceptor stacks is quite special. Usually 
people have hundreds of actions but just a few interceptor stacks. And the 
few stacks are not created by copy-paste but by overriding configuration 
parameters and adding interceptors at the beginning or end of the stack.


> 
>  
> We have recently internationalized the site, and so I had aneed to 
> add an i18n interceptor to the top of every action stack.  It would 
> have been impractical (and difficultto enforce for future actions) 
> to add the new interceptor to every actiondefinition.
> 
> 
>  
> My solution was to override the ActionProxyFactory to returnour own 
> ActionInvocation, which in turn always prepends the i18n interceptor
> tothe interceptor stack during initialization. 
> 

In your case that sounds alright.


What are the reasons that you need so many different interceptor stacks?


Regards,
Christoph

This Email was scanned by Sophos Anti Virus


Re: How to add a global interceptor

2015-10-13 Thread Christoph Nenning
> From: Jasper Rosenberg <jasper_rosenb...@yahoo.com.INVALID>
> To: Struts Users Mailing List <user@struts.apache.org>, 
> Date: 13.10.2015 14:01
> Subject: Re: How to add a global interceptor
> 
> Thanks for the feedback!
> To be clear, we do have a number of interceptor stacks that are 
> shared and we follow a similar pattern to what you describe where we
> add additional interceptors where needed before or after a common 
> stack.  There are places that we might be able to reduce even that 
> pattern by switching to action mapping parameters, I will definitely
> revisit that.  
> The real problem is simply that there are so many actions at this 
> point that to make sure we didn't miss any outlier custom stacks, we
> would have to review each one.  We would then have to add a struts 
> configuration validation step to make sure no one introduced a new 
> stack missing the required one (which I suppose wouldn't be that big
> a deal since we already do other configuration checks in development
> mode in a DispatcherListener).  Definitely food for thought...
> Thanks,Jasper


Well, keeping so many stacks around surely is maintenance hell. And 
changing these stacks additonally in code does not make it better ;)



But as I said before: In your case I don't have a better idea.



Regards,
Christoph




>   From: Christoph Nenning <christoph.nenn...@lex-com.net>
>  To: Struts Users Mailing List <user@struts.apache.org> 
>  Sent: Tuesday, October 13, 2015 7:35 AM
>  Subject: Re: How to add a global interceptor
> 
> > From: Jasper Rosenberg <jasper_rosenb...@yahoo.com.INVALID>
> > To: "user@struts.apache.org" <user@struts.apache.org>, 
> > Date: 13.10.2015 13:26
> > Subject: How to add a global interceptor
> > 
> > Hi,
> > 
> > 
> >  
> > I work on a project with hundreds of struts actions manywith their 
> > own custom interceptor stacks specified.  
> > 
> 
> Having actions with own interceptor stacks is quite special. Usually 
> people have hundreds of actions but just a few interceptor stacks. And 
the 
> few stacks are not created by copy-paste but by overriding configuration 

> parameters and adding interceptors at the beginning or end of the stack.
> 
> 
> 
> 
> > 
> >  
> > We have recently internationalized the site, and so I had aneed to 
> > add an i18n interceptor to the top of every action stack.  It would 
> > have been impractical (and difficultto enforce for future actions) 
> > to add the new interceptor to every actiondefinition.
> > 
> > 
> >  
> > My solution was to override the ActionProxyFactory to returnour own 
> > ActionInvocation, which in turn always prepends the i18n interceptor
> > tothe interceptor stack during initialization. 
> > 
> 
> In your case that sounds alright.
> 
> 
> What are the reasons that you need so many different interceptor stacks?
> 
> 
> Regards,
> Christoph
> 
> This Email was scanned by Sophos Anti Virus
> 
> 
> 

This Email was scanned by Sophos Anti Virus


Re: How to add a global interceptor

2015-10-13 Thread Jasper Rosenberg
Thanks for the feedback!
To be clear, we do have a number of interceptor stacks that are shared and we 
follow a similar pattern to what you describe where we add additional 
interceptors where needed before or after a common stack.  There are places 
that we might be able to reduce even that pattern by switching to action 
mapping parameters, I will definitely revisit that.  
The real problem is simply that there are so many actions at this point that to 
make sure we didn't miss any outlier custom stacks, we would have to review 
each one.  We would then have to add a struts configuration validation step to 
make sure no one introduced a new stack missing the required one (which I 
suppose wouldn't be that big a deal since we already do other configuration 
checks in development mode in a DispatcherListener).  Definitely food for 
thought...
Thanks,Jasper
  From: Christoph Nenning <christoph.nenn...@lex-com.net>
 To: Struts Users Mailing List <user@struts.apache.org> 
 Sent: Tuesday, October 13, 2015 7:35 AM
 Subject: Re: How to add a global interceptor
   
> From: Jasper Rosenberg <jasper_rosenb...@yahoo.com.INVALID>
> To: "user@struts.apache.org" <user@struts.apache.org>, 
> Date: 13.10.2015 13:26
> Subject: How to add a global interceptor
> 
> Hi,
> 
> 
>  
> I work on a project with hundreds of struts actions manywith their 
> own custom interceptor stacks specified.  
> 

Having actions with own interceptor stacks is quite special. Usually 
people have hundreds of actions but just a few interceptor stacks. And the 
few stacks are not created by copy-paste but by overriding configuration 
parameters and adding interceptors at the beginning or end of the stack.




> 
>  
> We have recently internationalized the site, and so I had aneed to 
> add an i18n interceptor to the top of every action stack.  It would 
> have been impractical (and difficultto enforce for future actions) 
> to add the new interceptor to every actiondefinition.
> 
> 
>  
> My solution was to override the ActionProxyFactory to returnour own 
> ActionInvocation, which in turn always prepends the i18n interceptor
> tothe interceptor stack during initialization. 
> 

In your case that sounds alright.


What are the reasons that you need so many different interceptor stacks?


Regards,
Christoph

This Email was scanned by Sophos Anti Virus


  

Re: How to add a global interceptor

2015-10-13 Thread Jasper Rosenberg
No need for pity :)  It really hasn't really much maintenance overhead to this 
point.  Needing to do a change to all stacks is really the only case where I've 
seen it be problem.  Still, we have been pretty conservative in trying to keep 
our interceptor stacks thin.  It is probably worth the minor overhead of having 
more unused interceptors to allow more sharing of stacks.  Always more tech 
debt to work on!
-Jasper
  From: Christoph Nenning <christoph.nenn...@lex-com.net>
 To: Struts Users Mailing List <user@struts.apache.org> 
 Sent: Tuesday, October 13, 2015 8:13 AM
 Subject: Re: How to add a global interceptor
   
> From: Jasper Rosenberg <jasper_rosenb...@yahoo.com.INVALID>
> To: Struts Users Mailing List <user@struts.apache.org>, 
> Date: 13.10.2015 14:01
> Subject: Re: How to add a global interceptor
> 
> Thanks for the feedback!
> To be clear, we do have a number of interceptor stacks that are 
> shared and we follow a similar pattern to what you describe where we
> add additional interceptors where needed before or after a common 
> stack.  There are places that we might be able to reduce even that 
> pattern by switching to action mapping parameters, I will definitely
> revisit that.  
> The real problem is simply that there are so many actions at this 
> point that to make sure we didn't miss any outlier custom stacks, we
> would have to review each one.  We would then have to add a struts 
> configuration validation step to make sure no one introduced a new 
> stack missing the required one (which I suppose wouldn't be that big
> a deal since we already do other configuration checks in development
> mode in a DispatcherListener).  Definitely food for thought...
> Thanks,Jasper


Well, keeping so many stacks around surely is maintenance hell. And 
changing these stacks additonally in code does not make it better ;)



But as I said before: In your case I don't have a better idea.



Regards,
Christoph






>      From: Christoph Nenning <christoph.nenn...@lex-com.net>
>  To: Struts Users Mailing List <user@struts.apache.org> 
>  Sent: Tuesday, October 13, 2015 7:35 AM
>  Subject: Re: How to add a global interceptor
> 
> > From: Jasper Rosenberg <jasper_rosenb...@yahoo.com.INVALID>
> > To: "user@struts.apache.org" <user@struts.apache.org>, 
> > Date: 13.10.2015 13:26
> > Subject: How to add a global interceptor
> > 
> > Hi,
> > 
> > 
> >  
> > I work on a project with hundreds of struts actions manywith their 
> > own custom interceptor stacks specified.  
> > 
> 
> Having actions with own interceptor stacks is quite special. Usually 
> people have hundreds of actions but just a few interceptor stacks. And 
the 
> few stacks are not created by copy-paste but by overriding configuration 

> parameters and adding interceptors at the beginning or end of the stack.
> 
> 
> 
> 
> > 
> >  
> > We have recently internationalized the site, and so I had aneed to 
> > add an i18n interceptor to the top of every action stack.  It would 
> > have been impractical (and difficultto enforce for future actions) 
> > to add the new interceptor to every actiondefinition.
> > 
> > 
> >  
> > My solution was to override the ActionProxyFactory to returnour own 
> > ActionInvocation, which in turn always prepends the i18n interceptor
> > tothe interceptor stack during initialization. 
> > 
> 
> In your case that sounds alright.
> 
> 
> What are the reasons that you need so many different interceptor stacks?
> 
> 
> Regards,
> Christoph
> 
> This Email was scanned by Sophos Anti Virus
> 
> 
> 

This Email was scanned by Sophos Anti Virus


  

Re: Unable to change content-type with Interceptor?

2015-07-27 Thread Lukasz Lenart
2015-07-23 23:18 GMT+02:00 JOSE L MARTINEZ-AVIAL jlm...@gmail.com:
 Hello all,
I was just looking for this option to override the content-type of the
 json result. Is there any fix for this?

Not sure what I have been referring to but JsonResult has contentType
param defined
https://github.com/apache/struts/blob/master/plugins/json/src/main/java/org/apache/struts2/json/JSONResult.java#L101


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



Re: Unable to change content-type with Interceptor?

2015-07-23 Thread JOSE L MARTINEZ-AVIAL
Hello all,
   I was just looking for this option to override the content-type of the
json result. Is there any fix for this?

  Thanks

JL

2012-12-31 12:41 GMT-05:00 Lukasz Lenart lukaszlen...@apache.org:

 2012/12/30 Burton Rhodes burtonrho...@gmail.com:
  Lukasz -
 
  Thanks for all your help.  You got me on the right track and it appears
 the
  json Result was what was overriding and setting the content type.  As a
  result, I have overridden the JSONResult class to use the dynamic
  content-Type.

 You're welcome :-)

  /**
   * Custom json result type to set Content-Type response header
 dynamically
  to either 'application/json' or 'plain/text'
   * according to what the request header identifies in the Accept header
   *
   * (this is to fix browser wanting to download the json response on an
 ajax
  submit)
   *
   * @author Burton Rhodes
   *
   */
  public class JsonDynamicContentTypeResult extends JSONResult {
 
  private static final Logger LOG =
  LoggerFactory.getLogger(JsonDynamicContentTypeResult.class);
 
  @Override
  public void execute(ActionInvocation invocation) throws Exception {
 
  ActionContext actionContext = invocation.getInvocationContext();
  HttpServletRequest request = (HttpServletRequest)
  actionContext.get(StrutsStatics.HTTP_REQUEST);
  HttpServletResponse response = (HttpServletResponse)
  actionContext.get(StrutsStatics.HTTP_RESPONSE);
 
  // Set Content-Type according to what the request will accept
  if (request.getHeader(Accept)!=null 
  request.getHeader(Accept).toLowerCase().contains(application/json)) {
  this.setContentType(application/json);
  } else {
  // Default to text/plain
  this.setContentType(text/plain);
  }
 
  try {
  Object rootObject;
  rootObject = readRootObject(invocation);
  writeToResponse(response, createJSONString(request,
  rootObject), enableGzip(request));
  } catch (IOException exception) {
  LOG.error(exception.getMessage(), exception);
  throw exception;
  }
  }
 
 
  }

 Right now contentType isn't dynamically resolved, please register an
 issue and I'll add such option to JSONResult so you will be able to
 specify contentType via param/ tag, eg.

 result type=json
 param name=contentType${resolveContentType}/param
 /result

 and the action's resolvedContentType method will be called to obtain
 valid contentType


 Happy New Year :-)
 --
 Łukasz
 + 48 606 323 122 http://www.lenart.org.pl/

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




Change Action Method In Interceptor

2015-03-11 Thread R Veach
Hi,

I know it is possible to limit struts to specific methods using the
MethodFilterInterceptor, and to change the execute method in the config or
form declaration using the method attribute.

Is it possible to have an interceptor change which method would be executed
in the action? I see I can get the method name using
invocation.getProxy().getMethod(), but I can't find any setter.

One reason I want to do this is to build submit and first time in logic
without defining it everywhere for every page and have an interceptor do
the work for me.
I would identify if it is first time or submit based on request to see if
it is GET or POST.
I could call the methods directly from the interceptor since I have the
action instance, but that would bypass the rest of the interceptor chain
and would require this interceptor to always be last in the list.

Here is an example of what I was planning:

//
if (isFirstTime(request)) {
if (action instanceof FirstTimeLogic) {
   invocation.getProxy().setMethod(executeFirstTimeInLogic);
}
} else {
if (action instanceof SubmitLogic) {
invocation.getProxy().setMethod(executeSubmitLogic);
}
}

return invocation.invoke();


Re: Change Action Method In Interceptor

2015-03-11 Thread Lukasz Lenart
2015-03-11 16:29 GMT+01:00 R Veach rveac...@gmail.com:
 Hi,

 I know it is possible to limit struts to specific methods using the
 MethodFilterInterceptor, and to change the execute method in the config or
 form declaration using the method attribute.

 Is it possible to have an interceptor change which method would be executed
 in the action? I see I can get the method name using
 invocation.getProxy().getMethod(), but I can't find any setter.

There is a reason for that - other interceptors can based on that ;-)

 One reason I want to do this is to build submit and first time in logic
 without defining it everywhere for every page and have an interceptor do
 the work for me.
 I would identify if it is first time or submit based on request to see if
 it is GET or POST.
 I could call the methods directly from the interceptor since I have the
 action instance, but that would bypass the rest of the interceptor chain
 and would require this interceptor to always be last in the list.

 Here is an example of what I was planning:

 //
 if (isFirstTime(request)) {
 if (action instanceof FirstTimeLogic) {
invocation.getProxy().setMethod(executeFirstTimeInLogic);
 }
 } else {
 if (action instanceof SubmitLogic) {
 invocation.getProxy().setMethod(executeSubmitLogic);
 }
 }

 return invocation.invoke();

The best option is to implement your own version of ActionProxyFactory
and ActionProxy - and used them instead of default one.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



Re: Call a forward or a redirect inside an interceptor.

2015-03-09 Thread ersinghlovepr...@gmail.com
You can use dynamic url redirecting in this case :
This works like
in struts.xml you have to define result mapping.
result name=redirect type=redirect${url}/result

and in action you will define some getter setter like :
private String url;

public String getUrl() {
   return url;
}
 public void setUrl(String url) {
   this.url=url;
}

But in case of Interceptor getter setter is not working so You can just set
the value in stack like:
invocation.getStack().set(url, actionUrl);
and just return a redirect from interceptor instead of invocation.invoke()

BUT BE CAREFUL THIS WILL NOT LET ANY ACTION TO WORK IF YOU DOES NOT DEFINE
ANY CONDITION 
MAKE IF CONDITION TO ONLY THOSE ACTION WHICH YOU DON'T WANT TO EXECUTE AND
FOR REST MAKE INVOCATION.INVOKE() 
LIKE FOR EXAMPLE 

if(invocation.getProxy().getActionName().equals(DemoAction))
{
invocation.getStack().set(url, DemoAction2);
return redirect;
}
return invocation.invoke();
i have made this redirect only for action DemoAction , for rest i just
define invocation.invoke

For further clarification Please feel free to reply on this post 
enjoy 
Thanks and regards 
Lovepreet Singh



--
View this message in context: 
http://struts.1045723.n5.nabble.com/Call-a-forward-or-a-redirect-inside-an-interceptor-tp3484464p5717505.html
Sent from the Struts - User mailing list archive at Nabble.com.

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



Adding custom interceptor in struts2 rest project

2015-01-28 Thread Amol Ghotankar
Hi All,

I was trying to get more deep in struts2 rest plugin.

To better understand things I have created a struts2-rest-sample on github
https://github.com/amolghotankar/struts2-rest-sample

Issues I see here are

1. If we add a customer interceptor then index action is not getting called.

2. We cannot update to struts2.3.20 - I guess this is known issue :(

3. How do we call http://localhost:8080/employee/111/projects.json
something like cascading actions here?

4. How can we return customer json response as for eg
http://localhost:8080/employee.json should return employeeId but
http://localhost:8080/employee/111.json should not return employeeId

There are more to come and I hope this github repo will help many other
like me.

Specially when these days we have angularjs being used heavily, people like
me would love to see struts2 more of a restful mvc which will sit only on
server side, but doing a little more for detached clients.


-- 

*With Best Regards,*

Amol Ghotankar
Technical Lead
M: +91 9960 980 419 http://www.cursivetech.com


Re: How to setup includes/excludes in Chaining Interceptor

2015-01-22 Thread Lukasz Lenart
2015-01-17 5:11 GMT+01:00 Tenchi Masaki koouy...@gmail.com:
 Hi Lukasz,

 Thank you very much for your attention, it's really nice to have detailed
 examples in the docs.
 But unfortunately it's still not working for me. I've followed the example
 exactly as the docs, but all the properties from SomeAction are being
 copied. In the /result.jsp page I have this:

 s:textfield name=prop1 label=prop1 autocomplete=off/
 s:textfield name=prop2 label=prop2 autocomplete=off/
 s:textfield name=prop3 label=prop3 autocomplete=off/
 s:textfield name=prop4 label=prop4 autocomplete=off/
 s:textfield name=prop5 label=prop5 autocomplete=off/
 s:textfield name=prop6 label=prop6 autocomplete=off/
 s:textfield name=prop7 label=prop7 autocomplete=off/

 The SomeAction class has prop1 to prop5.
 The OtherAction class has prop6 and prop7.

 And I have the test.jsp with this:

 s:form action=someAction 
 s:textfield name=prop1 /
 s:textfield name=prop2 /
 s:textfield name=prop3 /
 s:textfield name=prop4 /
 s:textfield name=prop5 /
 s:submit /
 /s:form

 So my testing example is very simple: test.jsp calls someAction and
 populates prop1 to 5. Then it's chained into otherAction which populates
 prop6 and prop7 and finally we get the result into result.jsp.

 Whenever I chain someAction to otherAction, I can see all the values from
 prop1 to prop7 in the result.jsp page, even though I'm setting the
 chain.includes to be only prop1.
 In the other hand, whenever I redirectAction someAction to otherAction, I
 can only see the values from prop6 and prop7 in the result page, just as
 one expects (because whenever you redirect actions, the context from one
 action is not copied to the other, right?).

 Lukasz, please, do you have a Struts 2 project with a working example of
 the chaining includes/excludes? If anyone is interested, I think I can
 share my failing test project somewhere too.

 Regards,
 Masaki

Here you have a simple example
https://github.com/lukaszlenart/struts2-chain-demo

- clone it locally
- mvn jetty:run
- open http://localhost:8080/struts2-chain-demo/


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



Re: How to setup includes/excludes in Chaining Interceptor

2015-01-16 Thread Tenchi Masaki
Hi Lukasz,

Thank you very much for your attention, it's really nice to have detailed
examples in the docs.
But unfortunately it's still not working for me. I've followed the example
exactly as the docs, but all the properties from SomeAction are being
copied. In the /result.jsp page I have this:

s:textfield name=prop1 label=prop1 autocomplete=off/
s:textfield name=prop2 label=prop2 autocomplete=off/
s:textfield name=prop3 label=prop3 autocomplete=off/
s:textfield name=prop4 label=prop4 autocomplete=off/
s:textfield name=prop5 label=prop5 autocomplete=off/
s:textfield name=prop6 label=prop6 autocomplete=off/
s:textfield name=prop7 label=prop7 autocomplete=off/

The SomeAction class has prop1 to prop5.
The OtherAction class has prop6 and prop7.

And I have the test.jsp with this:

s:form action=someAction 
s:textfield name=prop1 /
s:textfield name=prop2 /
s:textfield name=prop3 /
s:textfield name=prop4 /
s:textfield name=prop5 /
s:submit /
/s:form

So my testing example is very simple: test.jsp calls someAction and
populates prop1 to 5. Then it's chained into otherAction which populates
prop6 and prop7 and finally we get the result into result.jsp.

Whenever I chain someAction to otherAction, I can see all the values from
prop1 to prop7 in the result.jsp page, even though I'm setting the
chain.includes to be only prop1.
In the other hand, whenever I redirectAction someAction to otherAction, I
can only see the values from prop6 and prop7 in the result page, just as
one expects (because whenever you redirect actions, the context from one
action is not copied to the other, right?).

Lukasz, please, do you have a Struts 2 project with a working example of
the chaining includes/excludes? If anyone is interested, I think I can
share my failing test project somewhere too.

Regards,
Masaki





On Wed, Jan 14, 2015 at 8:28 AM, Lukasz Lenart lukaszlen...@apache.org
wrote:

 Here is the proper configuration, see my comments below

 action name=chain1 class=example.Login
 interceptor-ref name=basicStack/
 result name=success type=chain
 param name=actionNamechain2/param
 /result
 /action
 action name=chain2 class=example.HelloWorld 
 interceptor-ref name=chainStack
 param name=chain.includesusername/param
 /interceptor-ref
 result/WEB-INF/jsp/example/HelloWorld.jsp/result
 /action

 2015-01-13 3:39 GMT+01:00 Tenchi Masaki koouy...@gmail.com:
  Yes, at first I thought that I was supposed to pass the includes param
  into the chain result like this:
 
  action name=someAction class=com.examples.SomeAction
 interceptor-ref name=basicStack/
  result name=success type=chain
  param name=actionNameotherAction/param
  param name=includesprop1/param
  /result
  /action

 ChainResult doesn't contain includes - it must be defined on
 ChainInterceptor

  action name=otherAction class=com.examples.OtherAction 
  interceptor-ref name=chain /
  interceptor-ref name=basicStack/
  result name=success/result.jsp/result
  /action

 There is chainStack which you can use instead of chain  basicStack

  But it doesn't work.

 Yes as you must define includes for the result action (it strange
 for me too and sorry for misleading you ... but it makes sense :) )

  I've tried this too and no success (actually it doesn't make sense at
 all,
  so it's good that it does not work.. lol):
 
  action name=someAction class=com.examples.SomeAction
  interceptor-ref name=basicStack
  param name=includesprop1/param

 basicStack doesn't include chain interceptor, it won't work
 either, instead you can do it like this

 interceptor-ref name=chainStack
 param name=chain.includesprop1/param
 /interceptor-ref

  /interceptor-ref
  result name=success type=chain
  param name=actionNameotherAction/param
  /result
  /action
  action name=otherAction class=com.examples.OtherAction 
  interceptor-ref name=chain /
  interceptor-ref name=basicStack/
  result name=success/result.jsp/result
  /action
 
  And last:
 
  action name=someAction class=com.examples.SomeAction
  interceptor-ref name=chain 
  param name=includesprop1/param
  /interceptor-ref
  interceptor-ref name=basicStack/
  result name=success type=chain
  param name=actionNameotherAction/param
  /result
  /action
  action name=otherAction class=com.examples.OtherAction 
  result name=success/result.jsp/result
  /action

 Almost there, but just move interceptor-ref name=chain  to the second
 action

 And to close this issue I have updated the docs - thanks for support!
 https://cwiki.apache.org/confluence/display/WW/Chaining+Interceptor



 Regards
 --
 Łukasz
 + 48 606 323 122 http://www.lenart.org.pl/

 -
 To unsubscribe

Re: How to setup includes/excludes in Chaining Interceptor

2015-01-14 Thread Lukasz Lenart
Here is the proper configuration, see my comments below

action name=chain1 class=example.Login
interceptor-ref name=basicStack/
result name=success type=chain
param name=actionNamechain2/param
/result
/action
action name=chain2 class=example.HelloWorld 
interceptor-ref name=chainStack
param name=chain.includesusername/param
/interceptor-ref
result/WEB-INF/jsp/example/HelloWorld.jsp/result
/action

2015-01-13 3:39 GMT+01:00 Tenchi Masaki koouy...@gmail.com:
 Yes, at first I thought that I was supposed to pass the includes param
 into the chain result like this:

 action name=someAction class=com.examples.SomeAction
interceptor-ref name=basicStack/
 result name=success type=chain
 param name=actionNameotherAction/param
 param name=includesprop1/param
 /result
 /action

ChainResult doesn't contain includes - it must be defined on ChainInterceptor

 action name=otherAction class=com.examples.OtherAction 
 interceptor-ref name=chain /
 interceptor-ref name=basicStack/
 result name=success/result.jsp/result
 /action

There is chainStack which you can use instead of chain  basicStack

 But it doesn't work.

Yes as you must define includes for the result action (it strange
for me too and sorry for misleading you ... but it makes sense :) )

 I've tried this too and no success (actually it doesn't make sense at all,
 so it's good that it does not work.. lol):

 action name=someAction class=com.examples.SomeAction
 interceptor-ref name=basicStack
 param name=includesprop1/param

basicStack doesn't include chain interceptor, it won't work
either, instead you can do it like this

interceptor-ref name=chainStack
param name=chain.includesprop1/param
/interceptor-ref

 /interceptor-ref
 result name=success type=chain
 param name=actionNameotherAction/param
 /result
 /action
 action name=otherAction class=com.examples.OtherAction 
 interceptor-ref name=chain /
 interceptor-ref name=basicStack/
 result name=success/result.jsp/result
 /action

 And last:

 action name=someAction class=com.examples.SomeAction
 interceptor-ref name=chain 
 param name=includesprop1/param
 /interceptor-ref
 interceptor-ref name=basicStack/
 result name=success type=chain
 param name=actionNameotherAction/param
 /result
 /action
 action name=otherAction class=com.examples.OtherAction 
 result name=success/result.jsp/result
 /action

Almost there, but just move interceptor-ref name=chain  to the second action

And to close this issue I have updated the docs - thanks for support!
https://cwiki.apache.org/confluence/display/WW/Chaining+Interceptor



Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



Re: How to setup includes/excludes in Chaining Interceptor

2015-01-12 Thread Tenchi Masaki
Yes, at first I thought that I was supposed to pass the includes param
into the chain result like this:

action name=someAction class=com.examples.SomeAction
   interceptor-ref name=basicStack/
result name=success type=chain
param name=actionNameotherAction/param
param name=includesprop1/param
/result
/action
action name=otherAction class=com.examples.OtherAction 
interceptor-ref name=chain /
interceptor-ref name=basicStack/
result name=success/result.jsp/result
/action

But it doesn't work.

I've tried this too and no success (actually it doesn't make sense at all,
so it's good that it does not work.. lol):

action name=someAction class=com.examples.SomeAction
interceptor-ref name=basicStack
param name=includesprop1/param
/interceptor-ref
result name=success type=chain
param name=actionNameotherAction/param
/result
/action
action name=otherAction class=com.examples.OtherAction 
interceptor-ref name=chain /
interceptor-ref name=basicStack/
result name=success/result.jsp/result
/action

And last:

action name=someAction class=com.examples.SomeAction
interceptor-ref name=chain 
param name=includesprop1/param
/interceptor-ref
interceptor-ref name=basicStack/
result name=success type=chain
param name=actionNameotherAction/param
/result
/action
action name=otherAction class=com.examples.OtherAction 
result name=success/result.jsp/result
/action

All in vain. :(
They all copy all the parameters. I want to pass just a few parameters from
SomeAction into OtherAction.

On Thu, Jan 8, 2015 at 4:43 AM, Lukasz Lenart lukaszlen...@apache.org
wrote:

 2015-01-07 20:46 GMT+01:00 Tenchi Masaki koouy...@gmail.com:
  Hi Lukasz,
 
  I've tried setting up a new project just to test the chained action and
 now
  I'm a bit confused. It's exactly the same configuration on struts.xml:
 
  action name=someAction class=com.examples.SomeAction
  interceptor-ref name=basicStack/

 Can you move the props config here? As you want pass only few props of
 someAction to the otherAction, right?

  result name=success type=chainotherAction/result
  /action
  action name=otherAction class=com.examples.OtherAction
  interceptor-ref name=chain
  param name=includesprop1,prop2,prop3/param

 This param doesn't make sense here as you don't use chain result here

  /interceptor-ref
  interceptor-ref name=basicStack/
  result name=successgood_result.ftl/result
  /action


 Regards
 --
 Łukasz
 + 48 606 323 122 http://www.lenart.org.pl/

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




Re: How to setup includes/excludes in Chaining Interceptor

2015-01-07 Thread Lukasz Lenart
2015-01-07 20:46 GMT+01:00 Tenchi Masaki koouy...@gmail.com:
 Hi Lukasz,

 I've tried setting up a new project just to test the chained action and now
 I'm a bit confused. It's exactly the same configuration on struts.xml:

 action name=someAction class=com.examples.SomeAction
 interceptor-ref name=basicStack/

Can you move the props config here? As you want pass only few props of
someAction to the otherAction, right?

 result name=success type=chainotherAction/result
 /action
 action name=otherAction class=com.examples.OtherAction
 interceptor-ref name=chain
 param name=includesprop1,prop2,prop3/param

This param doesn't make sense here as you don't use chain result here

 /interceptor-ref
 interceptor-ref name=basicStack/
 result name=successgood_result.ftl/result
 /action


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



Re: How to setup includes/excludes in Chaining Interceptor

2015-01-07 Thread Tenchi Masaki
Hi Lukasz,

I've tried setting up a new project just to test the chained action and now
I'm a bit confused. It's exactly the same configuration on struts.xml:

action name=someAction class=com.examples.SomeAction
interceptor-ref name=basicStack/
result name=success type=chainotherAction/result
/action
action name=otherAction class=com.examples.OtherAction
interceptor-ref name=chain
param name=includesprop1,prop2,prop3/param
/interceptor-ref
interceptor-ref name=basicStack/
result name=successgood_result.ftl/result
/action

but now I noticed that all the parameters from SomeAction are being
copied. I was expecting that only prop1, prop2 and prop3 would be available
for the OtherAction.
I've tried setting only one prop and also using the expression
${'prop1','prop2','prop3'}.
It's all the same, all properties from SomeAction become available to the
OtherAction.
Is it supposed to be like this? Or am I doing something wrong?

Regards,
Masaki






On Wed, Jan 7, 2015 at 5:56 AM, Lukasz Lenart lukaszlen...@apache.org
wrote:

 2015-01-06 3:47 GMT+01:00 Tenchi Masaki koouy...@gmail.com:
  Hi,
 
  I'm trying to configure a list of parameters to be passed into a chained
  action, but I can't make it work. I've tried the following configuration
 in
  my struts.xml:
 
  action name=someAction class=com.examples.SomeAction
  interceptor-ref name=basicStack/
  result name=success type=chainotherAction/result
  /action
  action name=otherAction class=com.examples.OtherAction
  interceptor-ref name=chain
  param name=includesprop1,prop2,prop3/param

 Can you try with just one prop here? or use expression like this:
 ${'prop1','prop2','prop3'} ?


 Regards
 --
 Łukasz
 + 48 606 323 122 http://www.lenart.org.pl/

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




Re: How to setup includes/excludes in Chaining Interceptor

2015-01-06 Thread Lukasz Lenart
2015-01-06 3:47 GMT+01:00 Tenchi Masaki koouy...@gmail.com:
 Hi,

 I'm trying to configure a list of parameters to be passed into a chained
 action, but I can't make it work. I've tried the following configuration in
 my struts.xml:

 action name=someAction class=com.examples.SomeAction
 interceptor-ref name=basicStack/
 result name=success type=chainotherAction/result
 /action
 action name=otherAction class=com.examples.OtherAction
 interceptor-ref name=chain
 param name=includesprop1,prop2,prop3/param

Can you try with just one prop here? or use expression like this:
${'prop1','prop2','prop3'} ?


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



How to setup includes/excludes in Chaining Interceptor

2015-01-05 Thread Tenchi Masaki
Hi,

I'm trying to configure a list of parameters to be passed into a chained
action, but I can't make it work. I've tried the following configuration in
my struts.xml:

action name=someAction class=com.examples.SomeAction
interceptor-ref name=basicStack/
result name=success type=chainotherAction/result
/action
action name=otherAction class=com.examples.OtherAction
interceptor-ref name=chain
param name=includesprop1,prop2,prop3/param
/interceptor-ref
interceptor-ref name=basicStack/
result name=successgood_result.ftl/result
/action

so I was expecting that prop1, prop2, prop3 would be copied into
otherAction, but none of the someAction properties are being copied.
I've tried the other way around setting the excludes instead, but didn't
work either.
What's the correct syntax to setup the includes/excludes params for the
Chaining interceptor? Thanks in advance!

Masaki


Rppe: What is the effect of Params Interceptor?

2014-09-23 Thread Vineesh Anand
On Nov 25, 2012 4:37 PM, Wu Ming rdyf4e...@gmail.com wrote:

 I read this tutorial
 http://www.tutorialspoint.com/struts_2/struts_interceptors.htm,
 but I don't understand what Params Interceptor is used for?

 Example:

 action name=someAction class=com.examples.SomeAction
 interceptor-ref name=params/
 result name=successresult.jsp/result
 /action


 If the timer interceptor being used, we will see this kind of message:

 *INFO: Executed action [//hello!execute] took 109 ms.*


 But what about params interceptor? What would happened if it's used? I
 tried and don't see anything.



Re: Rppe: What is the effect of Params Interceptor?

2014-09-23 Thread Manoj . Sharma
Dear Vineesh,

The params interceptor also known as parameters interceptor is used to set 
all parameters on the valuestack.It is found in the default stack 
bydefault. So you don't need to specify it explicitely. It gets all 
parameters by calling the getParameters() method of ActionContext and sets 
it on the valuestack by calling the setValue() method of ValueStack. 

Note: If you specify any interceptor for the action explicitely, default 
interceptors will not be available for the action class.

Please refer to these URLs: 
http://struts.apache.org/release/2.0.x/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ParametersInterceptor.html
, http://struts.apache.org/release/2.3.x/docs/parameters-interceptor.html.

Thanks  Regards
Manoj Kumar Sharma





Rppe: What is the effect of Params Interceptor?

Vineesh Anand 
to:
Struts Users Mailing List
09/23/2014 12:33 PM

Please respond to Struts Users Mailing List






On Nov 25, 2012 4:37 PM, Wu Ming rdyf4e...@gmail.com wrote:

 I read this tutorial
 http://www.tutorialspoint.com/struts_2/struts_interceptors.htm,
 but I don't understand what Params Interceptor is used for?

 Example:

 action name=someAction class=com.examples.SomeAction
 interceptor-ref name=params/
 result name=successresult.jsp/result
 /action


 If the timer interceptor being used, we will see this kind of message:

 *INFO: Executed action [//hello!execute] took 109 ms.*


 But what about params interceptor? What would happened if it's used? I
 tried and don't see anything.




Re: paramsPrepareParamsStack and token interceptor

2014-08-21 Thread Fabian Richter

Done, see WW-4390

Am 20.08.2014 um 21:09 schrieb Lukasz Lenart:

2014-08-19 17:09 GMT+02:00 Fabian Richter frich...@mtg.de:

Hi,

when using paramsPrepareParamsStack with the convention plugin I'm getting
multiple errors/warnings in devMode=true:

Error setting expression 'token' with value
['5UVO47K811DQ15DUZF4QV2NQ8DHIHSUY', ]
Error setting expression 'token' with value
['5UVO47K811DQ15DUZF4QV2NQ8DHIHSUY', ]

At least one I got rid of by excluding these params (important is 'token'):

@InterceptorRefs({@InterceptorRef(value = paramsPrepareParamsStack, params
= {params.excludeParams,
struts.token,struts.token.name,token})})

But apparently only the first params interceptor in the stack uses these
params. The second one (the one after the prepare interceptor) only uses the
built-in excludeParams. So one of the above mentioned errors persists, which
is rather uncool :/

Bug or feature?


Feature and bug ;-) This kind of error report was introduced to inform
developer about possible typo in setter or value name in JSP, but you
are right, it's a bit annoying when something stupid like this clutter
the logs. Please fill an issue in JIRA.


Regards





smime.p7s
Description: S/MIME Cryptographic Signature


Re: paramsPrepareParamsStack and token interceptor

2014-08-21 Thread Lukasz Lenart
Great! Thanks!

2014-08-21 10:31 GMT+02:00 Fabian Richter frich...@mtg.de:
 Done, see WW-4390

 Am 20.08.2014 um 21:09 schrieb Lukasz Lenart:

 2014-08-19 17:09 GMT+02:00 Fabian Richter frich...@mtg.de:

 Hi,

 when using paramsPrepareParamsStack with the convention plugin I'm
 getting
 multiple errors/warnings in devMode=true:

 Error setting expression 'token' with value
 ['5UVO47K811DQ15DUZF4QV2NQ8DHIHSUY', ]
 Error setting expression 'token' with value
 ['5UVO47K811DQ15DUZF4QV2NQ8DHIHSUY', ]

 At least one I got rid of by excluding these params (important is
 'token'):

 @InterceptorRefs({@InterceptorRef(value = paramsPrepareParamsStack,
 params
 = {params.excludeParams,
 struts.token,struts.token.name,token})})

 But apparently only the first params interceptor in the stack uses these
 params. The second one (the one after the prepare interceptor) only uses
 the
 built-in excludeParams. So one of the above mentioned errors persists,
 which
 is rather uncool :/

 Bug or feature?


 Feature and bug ;-) This kind of error report was introduced to inform
 developer about possible typo in setter or value name in JSP, but you
 are right, it's a bit annoying when something stupid like this clutter
 the logs. Please fill an issue in JIRA.


 Regards



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



Re: paramsPrepareParamsStack and token interceptor

2014-08-20 Thread Lukasz Lenart
2014-08-19 17:09 GMT+02:00 Fabian Richter frich...@mtg.de:
 Hi,

 when using paramsPrepareParamsStack with the convention plugin I'm getting
 multiple errors/warnings in devMode=true:

 Error setting expression 'token' with value
 ['5UVO47K811DQ15DUZF4QV2NQ8DHIHSUY', ]
 Error setting expression 'token' with value
 ['5UVO47K811DQ15DUZF4QV2NQ8DHIHSUY', ]

 At least one I got rid of by excluding these params (important is 'token'):

 @InterceptorRefs({@InterceptorRef(value = paramsPrepareParamsStack, params
 = {params.excludeParams,
 struts.token,struts.token.name,token})})

 But apparently only the first params interceptor in the stack uses these
 params. The second one (the one after the prepare interceptor) only uses the
 built-in excludeParams. So one of the above mentioned errors persists, which
 is rather uncool :/

 Bug or feature?

Feature and bug ;-) This kind of error report was introduced to inform
developer about possible typo in setter or value name in JSP, but you
are right, it's a bit annoying when something stupid like this clutter
the logs. Please fill an issue in JIRA.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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



paramsPrepareParamsStack and token interceptor

2014-08-19 Thread Fabian Richter

Hi,

when using paramsPrepareParamsStack with the convention plugin I'm 
getting multiple errors/warnings in devMode=true:


Error setting expression 'token' with value 
['5UVO47K811DQ15DUZF4QV2NQ8DHIHSUY', ]
Error setting expression 'token' with value 
['5UVO47K811DQ15DUZF4QV2NQ8DHIHSUY', ]


At least one I got rid of by excluding these params (important is 'token'):

@InterceptorRefs({@InterceptorRef(value = paramsPrepareParamsStack, 
params = {params.excludeParams, 


struts.token,struts.token.name,token})})

But apparently only the first params interceptor in the stack uses these 
params. The second one (the one after the prepare interceptor) only uses 
the built-in excludeParams. So one of the above mentioned errors 
persists, which is rather uncool :/


Bug or feature?

Thanks and best
Fabian



smime.p7s
Description: S/MIME Cryptographic Signature


dynamic interceptor insertion

2014-06-26 Thread Gildas de Cadoudal
Hi all,

I would like to dynamically insert an interceptor to a specific place
in existing stack.
Of course I also like the stacks referencing the one where I insert
the interceptor also take advantage of this configuration change.

Practicable to do this? I started to look on the side of
PackageProvider, but I can not find sufficiently complete
documentation allowing me to do this.

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



Re: dynamic interceptor insertion

2014-06-26 Thread Paul Benedict
I have asked for that feature myself :-) No, that's not possible today. But
if you have the time, you can code the solution and share it with everyone!


Cheers,
Paul


On Thu, Jun 26, 2014 at 9:51 AM, Gildas de Cadoudal 
gildas.de.cadou...@gmail.com wrote:

 Hi all,

 I would like to dynamically insert an interceptor to a specific place
 in existing stack.
 Of course I also like the stacks referencing the one where I insert
 the interceptor also take advantage of this configuration change.

 Practicable to do this? I started to look on the side of
 PackageProvider, but I can not find sufficiently complete
 documentation allowing me to do this.

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




Re: Find action method in interceptor ( One action class with lots of action methods in it)

2014-06-11 Thread Christoph Nenning
 Please consider below action class:
 
  public class MyAction extends ActionSupport{
 
   @Action(action1)
   public String action1(){
 
   }
 
   @Action(action2)
public String action2(){
 }
 
   @Action(action3)
   public String action3(){
 
   }
 }
  
 Is there any way in an inerceptor which I can find which method was 
 really executed. I can find the class with
 
 myActionClass = invocation.getAction().getClass(); As I have many 
 action methods in one class, how can I found which method was executed
 
  
 ~Regards,
 ~~Alireza Fattahi



You can do this:

actionInvocation.getInvocationContext().getName()



Regards,
Christoph

This Email was scanned by Sophos Anti Virus


Re: Find action method in interceptor ( One action class with lots of action methods in it)

2014-06-07 Thread Antonios Gkogkakis
Hi Alireza,

I believe you can have the method name of the executed action like this
actionInvocation.getProxy().getMethod()


Antonios




On 7 June 2014 06:29, Alireza Fattahi afatt...@yahoo.com.invalid wrote:

 Please consider below action class:

  public class MyAction extends ActionSupport{

   @Action(action1)
   public String action1(){

   }

   @Action(action2)
public String action2(){
 }

   @Action(action3)
   public String action3(){

   }
 }

 Is there any way in an inerceptor which I can find which method was really
 executed. I can find the class with

 myActionClass = invocation.getAction().getClass(); As I have many action
 methods in one class, how can I found which method was executed


 ~Regards,
 ~~Alireza Fattahi


Find action method in interceptor ( One action class with lots of action methods in it)

2014-06-06 Thread Alireza Fattahi
Please consider below action class:

 public class MyAction extends ActionSupport{
    
      @Action(action1)
      public String action1(){    

      }    
    
      @Action(action2)
       public String action2(){    
        }

      @Action(action3)
      public String action3(){    

      }    
    }
     
Is there any way in an inerceptor which I can find which method was really 
executed. I can find the class with

myActionClass = invocation.getAction().getClass(); As I have many action 
methods in one class, how can I found which method was executed

 
~Regards,
~~Alireza Fattahi

S2 how to determine if a session exists from an Interceptor

2014-02-06 Thread Greg Lindholm
I have an Interceptor that wants to put something in the session after the
action has executed.

But if the session doesn't already exist I get an exception:

java.lang.IllegalStateException: Cannot create a session after the response
has been committed
How can I determine if the session already exists from within an
Interceptor?

 public String doIntercept(ActionInvocation invocation) throws Exception
 {
   String result = invocation.invoke();
   MapString, Object session =
invocation.getInvocationContext().getSession();
   session.put(key, value); // throws exception if session doesn't exist
   return result;
 }

Thanks
Greg


Re: S2 how to determine if a session exists from an Interceptor

2014-02-06 Thread Maurizio Cucchiara
Hi Greg,
I seem to recall that this is not the best way to handle the session and
generally speaking, it always better to abstract as much as possible http's
details

I could be wrong, but It would be better if your action implements a
specific interface (SessionAware or HttpSessionAware)

Twitter :http://www.twitter.com/m_cucchiara
G+  :https://plus.google.com/107903711540963855921
Linkedin:http://www.linkedin.com/in/mauriziocucchiara
VisualizeMe: http://vizualize.me/maurizio.cucchiara?r=maurizio.cucchiara

Maurizio Cucchiara


On 6 February 2014 14:14, Greg Lindholm greg.lindh...@gmail.com wrote:

 I have an Interceptor that wants to put something in the session after the
 action has executed.

 But if the session doesn't already exist I get an exception:

 java.lang.IllegalStateException: Cannot create a session after the response
 has been committed
 How can I determine if the session already exists from within an
 Interceptor?

  public String doIntercept(ActionInvocation invocation) throws Exception
  {
String result = invocation.invoke();
MapString, Object session =
 invocation.getInvocationContext().getSession();
session.put(key, value); // throws exception if session doesn't exist
return result;
  }

 Thanks
 Greg



Re: S2 how to determine if a session exists from an Interceptor

2014-02-06 Thread Ken McWilliams
The OP has abstracted away most of the details, he is working with
MapString, Object! The session is not generally struts2s responsibility
it, generally it is maintained by the web container. Tomcat/Glassfish, etc.
And generally you would consider it in such an environment to always exist.
What kind of container are you deploying your application in? I recall
there being an interceptor that will attempt to create a session for light
weight containers, however if struts needs to create such a session object
it is doubtful that the container will be able to use it in a meaningful
way.


On Thu, Feb 6, 2014 at 9:58 AM, Maurizio Cucchiara mcucchi...@apache.orgwrote:

 Hi Greg,
 I seem to recall that this is not the best way to handle the session and
 generally speaking, it always better to abstract as much as possible http's
 details

 I could be wrong, but It would be better if your action implements a
 specific interface (SessionAware or HttpSessionAware)

 Twitter :http://www.twitter.com/m_cucchiara
 G+  :https://plus.google.com/107903711540963855921
 Linkedin:http://www.linkedin.com/in/mauriziocucchiara
 VisualizeMe: http://vizualize.me/maurizio.cucchiara?r=maurizio.cucchiara

 Maurizio Cucchiara


 On 6 February 2014 14:14, Greg Lindholm greg.lindh...@gmail.com wrote:

  I have an Interceptor that wants to put something in the session after
 the
  action has executed.
 
  But if the session doesn't already exist I get an exception:
 
  java.lang.IllegalStateException: Cannot create a session after the
 response
  has been committed
  How can I determine if the session already exists from within an
  Interceptor?
 
   public String doIntercept(ActionInvocation invocation) throws Exception
   {
 String result = invocation.invoke();
 MapString, Object session =
  invocation.getInvocationContext().getSession();
 session.put(key, value); // throws exception if session doesn't exist
 return result;
   }
 
  Thanks
  Greg
 



  1   2   3   4   5   6   7   8   9   10   >