Re: Problem with result returning from interceptor
Hi, Sorry for my late reply. Yes I m setting the parent package property to the default s2 package (not class package). *struts.xml* struts !--= Struts2 Configuration details =-- constant name=struts.enable.DynamicMethodInvocation value=false / constant name=struts.devMode value=false / constant name=struts.multipart.maxSize value=-1/constant !-- Set java templates as default theme -- constant name=struts.ui.templateSuffix value=java / constant name=struts.ui.theme value=simple / !-- Other config -- constant name=struts.multipart.saveDir value=. / constant name=struts.custom.i18n.resources value=global-messages / !--= Convention plug-in config =-- !-- list of action packages -- constant name=struts.convention.action.packages value=com.sify.s2.action / constant name=struts.convention.default.parent.package value=s2-conv-default / !-- Set to scan only packages that start with the below value -- constant name=struts.convention.package.locators.basePackage value=com.sify.s2.action / !-- constant name=struts.convention.result.path value=/jsp / -- !--= FullHibernateSession plug-in config =-- constant name=hibernatePlugin.configurationFiles value=hibernate.cfg.xml / !--= Application' action config's =-- include file=s2-default.xml / /struts *s2-default.xml* struts package name=eawedan-conv-default extends=convention-default result-types result-type name=tiles class=org.apache.struts2.views.tiles.TilesResult default=true / /result-types !-- interceptors interceptor-stack configuration -- interceptors interceptor name=auth class=com.sify.s2.interceptor.AuthInterceptor / !-- interceptor-stack with authentication -- interceptor-stack name=userStack interceptor-ref name=auth / interceptor-ref name=params / interceptor-ref name=defaultStack/ /interceptor-stack !-- interceptor-stack with out authentication -- interceptor-stack name=guestStack interceptor-ref name=defaultStack / /interceptor-stack /interceptors default-interceptor-ref name=userStack / !-- when an interceptor returns, the corresponding result in the global-results will be selected, if present -- global-results result name=ngo-login type=redirectActionngo-login/result result name=no-privilege type=redirectActionno-privilege/result result name=no-admin-privilege type=redirectActionno-admin-privilege/result result name=error type=dispatcher/WEB-INF/content/error/excep.jsp/result result name=invalid.token/WEB-INF/content/error/error.jsp/result /global-results !-- global exceptions -- global-exception-mappings exception-mapping result=error exception=java.lang.Throwable/ /global-exception-mappings action name=ngo-login result type=dispatcher/WEB-INF/content/ngo-login.jsp/result /action /package /struts Please help. Regards, ManiKanta G twitter.com/manikantag On Fri, Aug 21, 2009 at 7:32 PM, musom...@aol.com wrote: Check it out with the config-browser -- you should see on the results tab if your login result is really there. Chris -Original Message- From: ManiKanta G go4m...@gmail.com To: Struts-User user@struts.apache.org Sent: Fri, Aug 21, 2009 3:36 am Subject: Problem with result returning from interceptor Hi, In my application actions are distributed into several namespaces using Conventions plugin. When a request come for an action in a namespace (other than default one, say, myapp/admin/action-name), and when there is no user session found, I m returning 'login', which is configured as global-result in the default namespace. But I m getting exception saying 'No result found with name...'. Result config: global-results result name=login type=redirectActionlogin/result /global-results Intercept() of interceptor: public String intercept(ActionInvocation invocation) throws Exception { MapString, Object session = invocation.getInvocationContext().getSession(); User user = (User) session.get(Constants.USER_HANDLE); if(user == null) { return login; }else{ invocation.invoke(); } } Action is in other namespace (package) and so jsp. But the result is configured in default namespace, as login result should be accessible from any namespace. I m not getting what is the mistake I m doing. Is there any this kind of problem with conventions plugin? Some one please help. Regards, ManiKanta G twitter.com/manikantag
Interceptor Stacks [Was: Re: File upload in Struts 2]
Greg Lindholm wrote: Here [1] is where I found the doc on Interceptor Parameter Overriding. [1] http://struts.apache.org/2.1.6/docs/interceptors.html#Interceptors-InterceptorParameterOverriding I'm confused. With Method 2 is there one instantiated interceptor stack, or two? These are supposed to be reentrant, right? Is the one stack tweaked to and fro every time a request comes in, depending upon the specific action's configuration? That seems like it would cause problems... -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [SOLVED]: Need to disable session interceptor
Rajeev Sharma wrote: I am not using session or cookies at all in my application right now. So I guess adding cookie listener doesn't make any sense to be added to JMeter test case. I shall use cookies later and shall add cookie listener to test my application. I don't want to store any data in web server so will not use sessions, rather shall store userid in cookie and fetch users data from memcache from cache machine based on the cookie. So you might as well have JMeter have a cookie listener so it simulates the browser. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Need to disable session interceptor
Hi, I am new to struts2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. -- Rajeev - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Need to disable session interceptor
Rajeev Sharma wrote: I am new to struts2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. There isn't a session created for each request, there's a session per client conversation. Also, AFAIK, Struts 2 doesn't do anything in particular regarding session creation--that is handled by the container. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Need to disable session interceptor
From the JMeter FAQ: How do I ensure each http request for jsp is within one jsessionid ? http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#head-114aca8407cf0eaff55b7ae5955eda46b1e2cecb Nils-H On Tue, Sep 1, 2009 at 1:15 PM, Dave Newtonnewton.d...@yahoo.com wrote: Rajeev Sharma wrote: I am new to struts2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. There isn't a session created for each request, there's a session per client conversation. Also, AFAIK, Struts 2 doesn't do anything in particular regarding session creation--that is handled by the container. Dave - 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: Need to disable session interceptor
Nils- doc suggests implementing a HttpCookieManager to handle the session any suggestions on which HttpCookieManager to implement and possible configurations? (i think JMeter is O/T so please ping offline) thanks Martin Gainty __ Note de déni et de confidentialité Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 1 Sep 2009 13:19:22 +0200 Subject: Re: Need to disable session interceptor From: nil...@gmail.com To: user@struts.apache.org From the JMeter FAQ: How do I ensure each http request for jsp is within one jsessionid ? http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#head-114aca8407cf0eaff55b7ae5955eda46b1e2cecb Nils-H On Tue, Sep 1, 2009 at 1:15 PM, Dave Newtonnewton.d...@yahoo.com wrote: Rajeev Sharma wrote: I am new to struts2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. There isn't a session created for each request, there's a session per client conversation. Also, AFAIK, Struts 2 doesn't do anything in particular regarding session creation--that is handled by the container. Dave - 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 _ Get back to school stuff for them and cashback for you. http://www.bing.com/cashback?form=MSHYCBpubl=WLHMTAGcrea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1
[OT] Re: Need to disable session interceptor
Hm... I don't know... Maybe read the documentation? http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Cookie_Manager Sorry for pinging you online. Hope that's not too much trouble... Nils-H On Tue, Sep 1, 2009 at 3:23 PM, Martin Gaintymgai...@hotmail.com wrote: Nils- doc suggests implementing a HttpCookieManager to handle the session any suggestions on which HttpCookieManager to implement and possible configurations? (i think JMeter is O/T so please ping offline) thanks Martin Gainty __ Note de déni et de confidentialité Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 1 Sep 2009 13:19:22 +0200 Subject: Re: Need to disable session interceptor From: nil...@gmail.com To: user@struts.apache.org From the JMeter FAQ: How do I ensure each http request for jsp is within one jsessionid ? http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#head-114aca8407cf0eaff55b7ae5955eda46b1e2cecb Nils-H On Tue, Sep 1, 2009 at 1:15 PM, Dave Newtonnewton.d...@yahoo.com wrote: Rajeev Sharma wrote: I am new to struts2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. There isn't a session created for each request, there's a session per client conversation. Also, AFAIK, Struts 2 doesn't do anything in particular regarding session creation--that is handled by the container. Dave - 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 _ Get back to school stuff for them and cashback for you. http://www.bing.com/cashback?form=MSHYCBpubl=WLHMTAGcrea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Need to disable session interceptor
I googled this and the struts2 performance tuning page says this Struts 2 does not create sessions unless asked to (for example, by having the createSession interceptor in your interceptor stack). Note that when you use SiteMesh however, a session will always be created I am never creating the session in my code directly and AFAIK I am not using SiteMesh (I don't even know what exactly is this). I have written code using JSP/Servlet and my knowledge says that unless the session is created explicitly it wont be created. Is there any interceptor in the defaultStack which creates it? (is the createSession part or defaultStack?) or I am doing something wrong. I opened some pages on my application and found there was one session created for my browser and others for other clients, So I guess this has nothing to do with JMeter. Sessions are being created for every client. I am trying to find out why is the session created when I did not create the session in my code. -- Rajeev -Original Message- From: Martin Gainty mgai...@hotmail.com Reply-to: Struts Users Mailing List user@struts.apache.org To: Struts Users Mailing List user@struts.apache.org Subject: RE: Need to disable session interceptor Date: Tue, 1 Sep 2009 09:23:58 -0400 Nils- doc suggests implementing a HttpCookieManager to handle the session any suggestions on which HttpCookieManager to implement and possible configurations? (i think JMeter is O/T so please ping offline) thanks Martin Gainty __ Note de déni et de confidentialité Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 1 Sep 2009 13:19:22 +0200 Subject: Re: Need to disable session interceptor From: nil...@gmail.com To: user@struts.apache.org From the JMeter FAQ: How do I ensure each http request for jsp is within one jsessionid ? http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#head-114aca8407cf0eaff55b7ae5955eda46b1e2cecb Nils-H On Tue, Sep 1, 2009 at 1:15 PM, Dave Newtonnewton.d...@yahoo.com wrote: Rajeev Sharma wrote: I am new to struts2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. There isn't a session created for each request, there's a session per client conversation. Also, AFAIK, Struts 2 doesn't do anything in particular regarding session creation--that is handled by the container. Dave - 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 _ Get back to school stuff for them and cashback for you. http://www.bing.com/cashback?form=MSHYCBpubl=WLHMTAGcrea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: [OT] Re: Need to disable session interceptor
there is a mention of cookies being grouped by ThreadGroup can i assume ThreadGroup is defined by the container? thx, Martin Gainty __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 1 Sep 2009 15:40:42 +0200 Subject: [OT] Re: Need to disable session interceptor From: nil...@gmail.com To: user@struts.apache.org Hm... I don't know... Maybe read the documentation? http://jakarta.apache.org/jmeter/usermanual/component_reference.html#HTTP_Cookie_Manager Sorry for pinging you online. Hope that's not too much trouble... Nils-H On Tue, Sep 1, 2009 at 3:23 PM, Martin Gaintymgai...@hotmail.com wrote: Nils- doc suggests implementing a HttpCookieManager to handle the session any suggestions on which HttpCookieManager to implement and possible configurations? (i think JMeter is O/T so please ping offline) thanks Martin Gainty __ Note de déni et de confidentialité Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 1 Sep 2009 13:19:22 +0200 Subject: Re: Need to disable session interceptor From: nil...@gmail.com To: user@struts.apache.org From the JMeter FAQ: How do I ensure each http request for jsp is within one jsessionid ? http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#head-114aca8407cf0eaff55b7ae5955eda46b1e2cecb Nils-H On Tue, Sep 1, 2009 at 1:15 PM, Dave Newtonnewton.d...@yahoo.com wrote: Rajeev Sharma wrote: I am new to struts2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. There isn't a session created for each request, there's a session per client conversation. Also, AFAIK, Struts 2 doesn't do anything in particular regarding session creation--that is handled by the container. Dave - 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 _ Get back to school stuff for them and cashback for you. http://www.bing.com/cashback?form=MSHYCBpubl=WLHMTAGcrea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ Windows Live: Keep your friends up to date with what you do online. http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_online:082009
Re: Need to disable session interceptor
I am trying to find out why is the session created when I did not create the session in my code. -- Rajeev Well, I believe Struts 2 internally does request.getSession(false) to prevent creating sessions when there isn't one... Which interceptor stack are you using? You could also try adding % @page session=false % in your JSPs and see if that helps. Nils-H - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Need to disable session interceptor
JSP create sessions by default. It is servlets that don't create a session unless you call getSession(). Do you have something like %@ page session=false at the top of your JSPs? Chris -Original Message- From: Rajeev Sharma rajeev1...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Tue, Sep 1, 2009 9:49 am Subject: RE: Need to disable session interceptor I googled this and the struts2 performance tuning page says this Struts 2 does not create sessions unless asked to (for example, by having the createSession interceptor in your interceptor stack). Note that when you use SiteMesh however, a session will always be created I am never creating the session in my code directly and AFAIK I am not using SiteMesh (I don't even know what exactly is this). I have written code using JSP/Servlet and my knowledge says that unless the session is created explicitly it wont be created. Is there any interceptor in the defaultStack which creates it? (is the createSession part or defaultStack?) or I am doing something wrong. I opened some pages on my application and found there was one session created for my browser and others for other clients, So I guess this has nothing to do with JMeter. Sessions are being created for every client. I am trying to find out why is the session created when I did not create the session in my code. -- Rajeev -Original Message- From: Martin Gainty mgai...@hotmail.com Reply-to: Struts Users Mailing List user@struts.apache.org To: Struts Users Mailing List user@struts.apache.org Subject: RE: Need to disable session interceptor Date: Tue, 1 Sep 2009 09:23:58 -0400 Nils- doc suggests implementing a HttpCookieManager to handle the session any suggestions on which HttpCookieManager to implement and possible configurations? (i think JMeter is O/T so please ping offline) thanks Martin Gainty __ Note de déni et de confidentialité Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 1 Sep 2009 13:19:22 +0200 Subject: Re: Need to disable session interceptor From: nil...@gmail.com To: user@struts.apache.org From the JMeter FAQ: How do I ensure each http request for jsp is within one jsessionid ? http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#head-114aca8407cf0eaff55b7ae5955eda46b1e2cecb Nils-H On Tue, Sep 1, 2009 at 1:15 PM, Dave Newtonnewton.d...@yahoo.com wrote: Rajeev Sharma wrote: I am new to struts 2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. There isn't a session created for each request, there's a session per client conversation. Also, AFAIK, Struts 2 doesn't do anything in particular regarding session creation--that is handled by the container. Dave - 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 _ Get back to school stuff for them and cashback for you. http://www.bing.com/cashback?form=MSHYCBpubl=WLHMTAGcrea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Need to disable session interceptor
When I upgraded from 2.0.x to 2.1.7 I found that the i18n interceptor now always creates a session too. The way I normally track down rogue session creations is to debug tomcat in Eclipse and add breakpoints to the javax.servlet.http.HttpServletRequest.getSession() and javax.servlet.http.HttpServletRequest.getSession(boolean) methods. That way you will find out exactly what the culprit is. Peter. 2009/9/1 musom...@aol.com: JSP create sessions by default. It is servlets that don't create a session unless you call getSession(). Do you have something like %@ page session=false at the top of your JSPs? Chris -Original Message- From: Rajeev Sharma rajeev1...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Tue, Sep 1, 2009 9:49 am Subject: RE: Need to disable session interceptor I googled this and the struts2 performance tuning page says this Struts 2 does not create sessions unless asked to (for example, by having the createSession interceptor in your interceptor stack). Note that when you use SiteMesh however, a session will always be created I am never creating the session in my code directly and AFAIK I am not using SiteMesh (I don't even know what exactly is this). I have written code using JSP/Servlet and my knowledge says that unless the session is created explicitly it wont be created. Is there any interceptor in the defaultStack which creates it? (is the createSession part or defaultStack?) or I am doing something wrong. I opened some pages on my application and found there was one session created for my browser and others for other clients, So I guess this has nothing to do with JMeter. Sessions are being created for every client. I am trying to find out why is the session created when I did not create the session in my code. -- Rajeev -Original Message- From: Martin Gainty mgai...@hotmail.com Reply-to: Struts Users Mailing List user@struts.apache.org To: Struts Users Mailing List user@struts.apache.org Subject: RE: Need to disable session interceptor Date: Tue, 1 Sep 2009 09:23:58 -0400 Nils- doc suggests implementing a HttpCookieManager to handle the session any suggestions on which HttpCookieManager to implement and possible configurations? (i think JMeter is O/T so please ping offline) thanks Martin Gainty __ Note de déni et de confidentialité Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 1 Sep 2009 13:19:22 +0200 Subject: Re: Need to disable session interceptor From: nil...@gmail.com To: user@struts.apache.org From the JMeter FAQ: How do I ensure each http request for jsp is within one jsessionid ? http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#head-114aca8407cf0eaff55b7ae5955eda46b1e2cecb Nils-H On Tue, Sep 1, 2009 at 1:15 PM, Dave Newtonnewton.d...@yahoo.com wrote: Rajeev Sharma wrote: I am new to struts 2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. There isn't a session created for each request, there's a session per client conversation. Also, AFAIK, Struts 2 doesn't do anything in particular regarding session creation--that is handled by the container. Dave - 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 _ Get back to school stuff for them and cashback for you. http://www.bing.com/cashback?form=MSHYCBpubl=WLHMTAGcrea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e
Re: Need to disable session interceptor
In any case, Nils' thing about JMeter needing a cookie doodad so it keeps the same session per simulated client. Dave Peter Phillips wrote: When I upgraded from 2.0.x to 2.1.7 I found that the i18n interceptor now always creates a session too. The way I normally track down rogue session creations is to debug tomcat in Eclipse and add breakpoints to the javax.servlet.http.HttpServletRequest.getSession() and javax.servlet.http.HttpServletRequest.getSession(boolean) methods. That way you will find out exactly what the culprit is. Peter. 2009/9/1 musom...@aol.com: JSP create sessions by default. It is servlets that don't create a session unless you call getSession(). Do you have something like %@ page session=false at the top of your JSPs? Chris -Original Message- From: Rajeev Sharma rajeev1...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Tue, Sep 1, 2009 9:49 am Subject: RE: Need to disable session interceptor I googled this and the struts2 performance tuning page says this Struts 2 does not create sessions unless asked to (for example, by having the createSession interceptor in your interceptor stack). Note that when you use SiteMesh however, a session will always be created I am never creating the session in my code directly and AFAIK I am not using SiteMesh (I don't even know what exactly is this). I have written code using JSP/Servlet and my knowledge says that unless the session is created explicitly it wont be created. Is there any interceptor in the defaultStack which creates it? (is the createSession part or defaultStack?) or I am doing something wrong. I opened some pages on my application and found there was one session created for my browser and others for other clients, So I guess this has nothing to do with JMeter. Sessions are being created for every client. I am trying to find out why is the session created when I did not create the session in my code. -- Rajeev -Original Message- From: Martin Gainty mgai...@hotmail.com Reply-to: Struts Users Mailing List user@struts.apache.org To: Struts Users Mailing List user@struts.apache.org Subject: RE: Need to disable session interceptor Date: Tue, 1 Sep 2009 09:23:58 -0400 Nils- doc suggests implementing a HttpCookieManager to handle the session any suggestions on which HttpCookieManager to implement and possible configurations? (i think JMeter is O/T so please ping offline) thanks Martin Gainty __ Note de déni et de confidentialité Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 1 Sep 2009 13:19:22 +0200 Subject: Re: Need to disable session interceptor From: nil...@gmail.com To: user@struts.apache.org From the JMeter FAQ: How do I ensure each http request for jsp is within one jsessionid ? http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#head-114aca8407cf0eaff55b7ae5955eda46b1e2cecb Nils-H On Tue, Sep 1, 2009 at 1:15 PM, Dave Newtonnewton.d...@yahoo.com wrote: Rajeev Sharma wrote: I am new to struts 2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. There isn't a session created for each request, there's a session per client conversation. Also, AFAIK, Struts 2 doesn't do anything in particular regarding session creation--that is handled by the container. Dave - 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 _ Get back to school stuff for them and cashback for you. http://www.bing.com/cashback?form=MSHYCBpubl=WLHMTAGcrea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
[SOLVED]: Need to disable session interceptor
I did not have %@ page session=false in the jsps which were included in other jsps using s:include. I put %@ page session=false in all the jsp pages and there are no more sessions created. Thank you guys for the quick help. Peter, I am using 2.1.6 and don't have sessions created any more. Are you sure i18n interceptor in 2.1.7 creates the session for every client? Should 2.1.6 and 2.1.7 have differences like this? it should be a minor release with no major changes. That's just my guess and interested to know your opinion. -- Rajeev Sharma Sr. Software Engineer Yahoo! Inc -Original Message- From: Peter Phillips petergphill...@googlemail.com Reply-to: Struts Users Mailing List user@struts.apache.org To: Struts Users Mailing List user@struts.apache.org Subject: Re: Need to disable session interceptor Date: Tue, 1 Sep 2009 19:20:17 +0100 When I upgraded from 2.0.x to 2.1.7 I found that the i18n interceptor now always creates a session too. The way I normally track down rogue session creations is to debug tomcat in Eclipse and add breakpoints to the javax.servlet.http.HttpServletRequest.getSession() and javax.servlet.http.HttpServletRequest.getSession(boolean) methods. That way you will find out exactly what the culprit is. Peter. 2009/9/1 musom...@aol.com: JSP create sessions by default. It is servlets that don't create a session unless you call getSession(). Do you have something like %@ page session=false at the top of your JSPs? Chris -Original Message- From: Rajeev Sharma rajeev1...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Tue, Sep 1, 2009 9:49 am Subject: RE: Need to disable session interceptor I googled this and the struts2 performance tuning page says this Struts 2 does not create sessions unless asked to (for example, by having the createSession interceptor in your interceptor stack). Note that when you use SiteMesh however, a session will always be created I am never creating the session in my code directly and AFAIK I am not using SiteMesh (I don't even know what exactly is this). I have written code using JSP/Servlet and my knowledge says that unless the session is created explicitly it wont be created. Is there any interceptor in the defaultStack which creates it? (is the createSession part or defaultStack?) or I am doing something wrong. I opened some pages on my application and found there was one session created for my browser and others for other clients, So I guess this has nothing to do with JMeter. Sessions are being created for every client. I am trying to find out why is the session created when I did not create the session in my code. -- Rajeev -Original Message- From: Martin Gainty mgai...@hotmail.com Reply-to: Struts Users Mailing List user@struts.apache.org To: Struts Users Mailing List user@struts.apache.org Subject: RE: Need to disable session interceptor Date: Tue, 1 Sep 2009 09:23:58 -0400 Nils- doc suggests implementing a HttpCookieManager to handle the session any suggestions on which HttpCookieManager to implement and possible configurations? (i think JMeter is O/T so please ping offline) thanks Martin Gainty __ Note de déni et de confidentialité Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 1 Sep 2009 13:19:22 +0200 Subject: Re: Need to disable session interceptor From: nil...@gmail.com To: user@struts.apache.org From the JMeter FAQ: How do I ensure each http request for jsp is within one jsessionid ? http://wiki.apache.org/jakarta-jmeter/JMeterFAQ#head-114aca8407cf0eaff55b7ae5955eda46b1e2cecb Nils-H On Tue, Sep 1, 2009 at 1:15 PM, Dave Newtonnewton.d...@yahoo.com wrote: Rajeev Sharma wrote: I am new to struts 2 (I mean struts). I am developing an application which does not need to use sessions at all. When I tested my application with jmeter, I got 18000 sessions created (tomcat showed me this). Looks like for every individual request there is one session created. How can I remove the session interceptor at all (and other components related to sessions), so that there are no sessions created in my application. There isn't a session created for each request, there's a session per client conversation. Also, AFAIK, Struts 2 doesn't do anything in particular regarding session creation--that is handled by the container. Dave
Re: [SOLVED]: Need to disable session interceptor
Rajeev Sharma wrote: I did not have %@ page session=false in the jsps which were included in other jsps using s:include. I put %@ page session=false in all the jsp pages and there are no more sessions created. Thank you guys for the quick help. That's not the correct solution: if you expect the JMeter tests to run as they would if they were a real client you need to add the cookie listener in JMeter. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [SOLVED]: Need to disable session interceptor
From Rajeev's earlier emails: I am developing an application which does not need to use sessions at all. I opened some pages on my application and found there was one session created for my browser and others for other clients, So I guess this has nothing to do with JMeter. Sessions are being created for every client. Therefore I think adding page session=false is the correct solution in his case and he has no need for the cookie listener in JMeter as no cookies will be created! Peter. 2009/9/1 Dave Newton newton.d...@yahoo.com: Rajeev Sharma wrote: I did not have %@ page session=false in the jsps which were included in other jsps using s:include. I put %@ page session=false in all the jsp pages and there are no more sessions created. Thank you guys for the quick help. That's not the correct solution: if you expect the JMeter tests to run as they would if they were a real client you need to add the cookie listener in JMeter. Dave - 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: [SOLVED]: Need to disable session interceptor
Peter Phillips wrote: From Rajeev's earlier emails: I am developing an application which does not need to use sessions at all. I opened some pages on my application and found there was one session created for my browser and others for other clients, So I guess this has nothing to do with JMeter. Sessions are being created for every client. Therefore I think adding page session=false is the correct solution in his case and he has no need for the cookie listener in JMeter as no cookies will be created! While I did misunderstand the original post, my statement still stands--if you want the JMeter tests to run as a real client would, the tests need to emulate the client. Unless every user has cookies disabled then the tests won't (necessarily) run the same way. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [SOLVED]: Need to disable session interceptor
I am not using session or cookies at all in my application right now. So I guess adding cookie listener doesn't make any sense to be added to JMeter test case. I shall use cookies later and shall add cookie listener to test my application. I don't want to store any data in web server so will not use sessions, rather shall store userid in cookie and fetch users data from memcache from cache machine based on the cookie. -- Rajeev Sharma Sr. Software Engineer Yahoo! Inc -Original Message- From: Dave Newton newton.d...@yahoo.com Reply-to: Struts Users Mailing List user@struts.apache.org To: Struts Users Mailing List user@struts.apache.org Subject: Re: [SOLVED]: Need to disable session interceptor Date: Tue, 01 Sep 2009 16:10:28 -0400 Peter Phillips wrote: From Rajeev's earlier emails: I am developing an application which does not need to use sessions at all. I opened some pages on my application and found there was one session created for my browser and others for other clients, So I guess this has nothing to do with JMeter. Sessions are being created for every client. Therefore I think adding page session=false is the correct solution in his case and he has no need for the cookie listener in JMeter as no cookies will be created! While I did misunderstand the original post, my statement still stands--if you want the JMeter tests to run as a real client would, the tests need to emulate the client. Unless every user has cookies disabled then the tests won't (necessarily) run the same way. Dave - 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
Problem with result returning from interceptor
Hi, In my application actions are distributed into several namespaces using Conventions plugin. When a request come for an action in a namespace (other than default one, say, myapp/admin/action-name), and when there is no user session found, I m returning 'login', which is configured as global-result in the default namespace. But I m getting exception saying 'No result found with name...'. Result config: global-results result name=login type=redirectActionlogin/result /global-results Intercept() of interceptor: public String intercept(ActionInvocation invocation) throws Exception { MapString, Object session = invocation.getInvocationContext().getSession(); User user = (User) session.get(Constants.USER_HANDLE); if(user == null) { return login; }else{ invocation.invoke(); } } Action is in other namespace (package) and so jsp. But the result is configured in default namespace, as login result should be accessible from any namespace. I m not getting what is the mistake I m doing. Is there any this kind of problem with conventions plugin? Some one please help. Regards, ManiKanta G twitter.com/manikantag
Re: Problem with result returning from interceptor
The conventions plugin reads a property called - struts.convention.default.parent.package Are you setting this property to the package that declares the global-result? -Wes On Fri, Aug 21, 2009 at 3:36 AM, ManiKanta Ggo4m...@gmail.com wrote: Hi, In my application actions are distributed into several namespaces using Conventions plugin. When a request come for an action in a namespace (other than default one, say, myapp/admin/action-name), and when there is no user session found, I m returning 'login', which is configured as global-result in the default namespace. But I m getting exception saying 'No result found with name...'. Result config: global-results result name=login type=redirectActionlogin/result /global-results Intercept() of interceptor: public String intercept(ActionInvocation invocation) throws Exception { MapString, Object session = invocation.getInvocationContext().getSession(); User user = (User) session.get(Constants.USER_HANDLE); if(user == null) { return login; }else{ invocation.invoke(); } } Action is in other namespace (package) and so jsp. But the result is configured in default namespace, as login result should be accessible from any namespace. I m not getting what is the mistake I m doing. Is there any this kind of problem with conventions plugin? Some one please help. Regards, ManiKanta G twitter.com/manikantag -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem with result returning from interceptor
Check it out with the config-browser -- you should see on the results tab if your login result is really there. Chris -Original Message- From: ManiKanta G go4m...@gmail.com To: Struts-User user@struts.apache.org Sent: Fri, Aug 21, 2009 3:36 am Subject: Problem with result returning from interceptor Hi, In my application actions are distributed into several namespaces using Conventions plugin. When a request come for an action in a namespace (other than default one, say, myapp/admin/action-name), and when there is no user session found, I m returning 'login', which is configured as global-result in the default namespace. But I m getting exception saying 'No result found with name...'. Result config: global-results result name=login type=redirectActionlogin/result /global-results Intercept() of interceptor: public String intercept(ActionInvocation invocation) throws Exception { MapString, Object session = invocation.getInvocationContext().getSession(); User user = (User) session.get(Constants.USER_HANDLE); if(user == null) { return login; }else{ invocation.invoke(); } } Action is in other namespace (package) and so jsp. But the result is configured in default namespace, as login result should be accessible from any namespace. I m not getting what is the mistake I m doing. Is there any this kind of problem with conventions plugin? Some one please help. Regards, ManiKanta G twitter.com/manikantag
Problem using scope interceptor
I am trying apress book example chapter06. Here is my struts.xml file struts constant name=struts.codebehind.defaultPackage value=base-package/ constant name=struts.codebehind.pathPrefix value=/WEB-INF/jsp// package name=base-package extends=struts-default default-interceptor-ref name=paramsPrepareParamsStack / global-results result name=unknownError/WEB-INF/jsp/error.jsp/result result name=dupPK/WEB-INF/jsp/user/findUser-success.jsp/result /global-results global-exception-mappings exception-mapping exception=org.hibernate.exception.ConstraintViolationException result=dupPK / exception-mapping exception=java.lang.Exception result=unknownError / /global-exception-mappings action name=index class=org.xinus.actions.BaseAction result name=success/WEB-INF/jsp/index.jsp/result /action /package package name=enterEvent namespace=/event extends=base-package interceptors interceptor name=flash class=com.opensymphony.webwork.interceptor.FlashInterceptor / interceptor-stack name=eventStack interceptor-ref name=scope model partialEvent /interceptor-ref interceptor-ref name=paramsPrepareParamsStack/ /interceptor-stack /interceptors default-interceptor-ref name=eventStack/ action name=addEventFlow class=org.xinus.actions.event.BaseEventAction interceptor-ref name=eventStack start /interceptor-ref result/WEB-INF/jsp/event/enterEventDetails-input.jsp/result /action action name=endEventFlow class=org.xinus.actions.event.BaseEventAction interceptor-ref name=eventStack end /interceptor-ref result/WEB-INF/jsp/event/eventReview.jsp/result /action action name=flashedSelectEventType class=org.xinus.actions.event.SelectLocationTypeAction interceptor-ref name=flash Retrieve /interceptor-ref interceptor-ref name=eventStack / result/WEB-INF/jsp/event/selectLocationType-input.jsp/result /action /package /struts Here is my BaseEventAction.java public class BaseEventAction extends BaseAction implements ModelDrivenEvent { protected Event event = null; public Event getModel() { return event; } public void setModel(Event model) { this.event = model; } } Here is my EnterEventDetailsAction.java @ParentPackage(enterEvent) @Result(type= ServletActionRedirectResult.class,value=selectLocationType,params={method,input}) @Validation public class EnterEventDetailsAction extends BaseEventAction implements Preparable { private Date partialStartDate; private String patialStartTime; private String partialVotingStartTime; public void prepare() throws Exception { event = new Event(); event.setStatus(Progress.NOT_STARTED); event.setLastUpdateTime( Calendar.getInstance().getTime() ); } public Date getPartialStartDate() { return partialStartDate; } @RequiredFieldValidator(message=Validation Error, key=validate.notEmpty) public void setPartialStartDate(Date partialStartDate) { this.partialStartDate = partialStartDate; } public String getPatialStartTime() { return patialStartTime; } @CustomValidator(type =timeValidator, key=validate.timeOfDay) public void setPatialStartTime(String patialStartTime) { this.patialStartTime = patialStartTime; } public String getPartialVotingStartTime() { return partialVotingStartTime; } @CustomValidator(type =timeValidator, key=validate.timeOfDay) public void setPartialVotingStartTime(String partialVotingStartTime) { this.partialVotingStartTime = partialVotingStartTime; } @VisitorFieldValidator(message=Default message, fieldName=model, shortCircuit=false, appendPrefix=false) public String execute() throws Exception { Calendar cal = Calendar.getInstance(); cal.setTime(partialStartDate); TimeUtil timeUtil = new TimeUtil(patialStartTime); event.setStartTime( timeUtil.resolveDate( partialStartDate, event.getTimeZoneOffset() ) ); cal = Calendar.getInstance(); cal.setTime(partialStartDate); timeUtil = new TimeUtil(partialVotingStartTime); event.setVotingStartTime( timeUtil.resolveDate( partialStartDate, event.getTimeZoneOffset() ) ); return SUCCESS; } } Here is my SelectLocationTypeAction.java @ParentPackage(enterEvent) @Result(type= ServletActionRedirectResult.class,value=enterLocationDetails) public class SelectLocationTypeAction extends BaseEventAction implements Preparable { private Integer typeId; private
Re: How to use workflow interceptor??
spsarolkar wrote: I want to write simple program using workflow interceptor where can i find information about workflow interceptor I'd start with the workflow interceptor docs: http://struts.apache.org/2.x/docs/workflow-interceptor.html That said, I'm not sure what you mean; any app that uses validation is using the workflow interceptor; what is your intent? Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
How to use workflow interceptor??
Hello everyone, I want to write simple program using workflow interceptor where can i find information about workflow interceptor thanks -- View this message in context: http://www.nabble.com/How-to-use-workflow-interceptor---tp24970880p24970880.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
Re: Scope interceptor / Practical Apache Struts 2
Hello Ian, I am facing the same problem. I tried adding dependency as selkin said as follows dependencies dependency groupIdcom.googlecode.struts2scopeplugin/groupId artifactIdstruts2-scope-plugin/artifactId version1.0.3/version /dependency /dependencies But printing the same error Can you please supply me another copy of the code . My email address is spsarol...@gmail.com Thanks, Sunil Ian Roughley wrote: I just re-ran my local version of the code without problems, and verified that the base class does have a getModel() and setModel() methods. If you contact me off-list I can supply another copy of the code, that might be a resolution. Did you have any problems running the code from chapter 5? /Ian -- Ian Roughley From Down Around, Inc. Consulting * Training / Mentoring * Agile Process * Open Source web: http://www.fdar.com - email: i...@fdar.com Selckin wrote: Hello, In Chapter 6 of Practical Apache Struts 2 Web 2.0 Projects, It explains how to use the scope interceptor to create sort of wizard pages. I've been trying to figure these out, but cannot get this to work. Even the included example (downloadable from http://www.apress.com/book/view/1590599039 ) do not work for me. I was hoping someone could try them and tell me if they are indeed broken or if i am doing something wrong. And what that might be? Running the examples with no changes and when going to the second step in the workflow I get the following error: HTTP ERROR: 500 Error setting expression 'model' with value 'com.fdar.apress.s2.domain.ev...@2a163765' RequestURI=/app/event/selectLocation!input.action Caused by: Error setting expression 'model' with value 'com.fdar.apress.s2.domain.ev...@2a163765' - [unknown location] at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java:171) at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java:146) at org.apache.struts2.interceptor.ScopeInterceptor.before(ScopeInterceptor.java:321) at org.apache.struts2.interceptor.ScopeInterceptor.intercept(ScopeInterceptor.java:424) cut Caused by: No object in the CompoundRoot has a publicly accessible property named 'model' (no setter could be found). - [unknown location] at com.opensymphony.xwork2.util.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:68) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1656) at ognl.ASTProperty.setValueBody(ASTProperty.java:101) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) cut Can provide full stack trace if needed The following is also outputted from the example. SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'duration' on 'class com.fdar.apress.s2.actions.event.EnterEventDetailsAction: Error setting expression 'duration' with value '[Ljava.lang.String;@602f892f' 14-feb-2008 20:10:30 com.opensymphony.xwork2.interceptor.ParametersInterceptor setParameters SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'name' on 'class com.fdar.apress.s2.actions.event.EnterEventDetailsAction: Error setting expression 'name' with value '[Ljava.lang.String;@50d79dfe' 14-feb-2008 20:10:30 com.opensymphony.xwork2.interceptor.ParametersInterceptor setParameters SEVERE: ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'timeZoneOffset' on 'class com.fdar.apress.s2.actions.event.EnterEventDetailsAction: Error setting expression 'timeZoneOffset' with value '[Ljava.lang.String;@52a53948' 14-feb-2008 20:10:30 com.opensymphony.xwork2.interceptor.ParametersInterceptor setParameters Thanks. - 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 -- View this message in context: http://www.nabble.com/Scope-interceptor---Practical-Apache-Struts-2-tp15487610p24971259.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
Struts - 2.1.6 - Prepare Interceptor
Hi Folks, I have a problem as below: 1) public abstract class AbstractBaseAction implements Preparable { public void prepare() { populateSomething(); } } 2) public class MyAction1 extends AbstractBaseAction { ……… } 3) public abstract class MyAction2 extends AbstractBaseAction implements Preparable { public void prepare() { doSomething(); } } 4) public class MyAction3 extends MyAction2 { ……… } I have a design as above. The prepare() in AbstractBaseAction will do some common logic for MyAction1, MyAction2 MyAction3. The prepare() in MyAction2 will do some common logic only for MyAction3. Only the prepare() in MyAction2 is being called for MyAction3. Since it’s being overridden. I want both the prepare() in AbstractBaseAction MyAction2 to be called one after the other in the same order for MyAction3. How to achieve this? Please advice. Thank you. Regards, Kishan.G -- View this message in context: http://www.nabble.com/Struts---2.1.6---Prepare-Interceptor-tp24950462p24950462.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
Re: Struts - 2.1.6 - Prepare Interceptor
super.prepare()? Nils-H On Thu, Aug 13, 2009 at 9:51 AM, Kishan Paandykishanchellapaand...@spanservices.com wrote: Hi Folks, I have a problem as below: 1) public abstract class AbstractBaseAction implements Preparable { public void prepare() { populateSomething(); } } 2) public class MyAction1 extends AbstractBaseAction { ……… } 3) public abstract class MyAction2 extends AbstractBaseAction implements Preparable { public void prepare() { doSomething(); } } 4) public class MyAction3 extends MyAction2 { ……… } I have a design as above. The prepare() in AbstractBaseAction will do some common logic for MyAction1, MyAction2 MyAction3. The prepare() in MyAction2 will do some common logic only for MyAction3. Only the prepare() in MyAction2 is being called for MyAction3. Since it’s being overridden. I want both the prepare() in AbstractBaseAction MyAction2 to be called one after the other in the same order for MyAction3. How to achieve this? Please advice. Thank you. Regards, Kishan.G -- View this message in context: http://www.nabble.com/Struts---2.1.6---Prepare-Interceptor-tp24950462p24950462.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 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts 2 portlet interceptor issue
Instead of writing interceptors I decided to go with the suggestion you made, which is use the raw session with the use of portlet:defineObjects/ but what I want to know is how can I access the jsp expression variables inside the s:property and s:if tags. We primarily use struts tags, because of this I thought of use s:set tag to assign the portlet application scope variable and use there after but it failed pls see the below failed attempt. portlet:defineObjects/ % UserSession userSession =(UserSession)renderRequest.getPortletSession().getAttribute(UserSessionForApplication,PortletSession.APPLICATION_SCOPE); String loginId= userSession.getLoginId(); % s:set name=studentId value='%=loginId%' / s:set name=studentId2 value=#attri.loginId / s:property value=studentId/ br s:property value=studentId2/ br none of the above printed the value, how to proceed on this Note: UserSession is one of our custom classes Nils-Helge Garli wrote: action name=testAction class=test.MyAction interceptor-ref name=sessionScopeHandler/interceptor-ref result/jsp/test/test.jsp/result /action With this configuration, your sessionScopeHandler will be the only interceptor running for this action. You either need to include the portletDefaultStack or set up your own stack that also includes the framework interceptors that does the introspection magic. Nils-H - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- View this message in context: http://www.nabble.com/struts-2-portlet-interceptor-issue-tp24799881p24819616.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
struts 2 portlet interceptor issue
Hi, I wrote a interceptor as follows but looks like variables/parameters in the action class are not populated as part of the form submission. Which means introspection does not seem to work it gives null values, I only defined the interceptor not modified the default stack, pls advice how to get the introspection also working, my interceptor and struts.xml roughly looks as follows. public class PortletApplicationScopeHandler extends AbstractInterceptor { public String intercept(ActionInvocation invocation) throws Exception { invocation.addPreResultListener(new PreResultListener(){ @SuppressWarnings(unchecked) public void beforeResult(ActionInvocation invocation, String resultCode) { //some logic here before it goes to the target jsp // } } ); return invocation.invoke(); } } and in my struts.xml the interceptor looks as follows package name=myStuff extends=struts-portlet-default namespace=/myStuff interceptors interceptor name=sessionScopeHandler class=test.interceptor.PortletApplicationScopeHandler / /interceptors action name=testAction class=test.MyAction interceptor-ref name=sessionScopeHandler/interceptor-ref result/jsp/test/test.jsp/result /action ... .. -- View this message in context: http://www.nabble.com/struts-2-portlet-interceptor-issue-tp24799881p24799881.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
Re: struts 2 portlet interceptor issue
action name=testAction class=test.MyAction interceptor-ref name=sessionScopeHandler/interceptor-ref result/jsp/test/test.jsp/result /action With this configuration, your sessionScopeHandler will be the only interceptor running for this action. You either need to include the portletDefaultStack or set up your own stack that also includes the framework interceptors that does the introspection magic. Nils-H - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: EJB Injection in Interceptor
Wow! Thanks for all this great feedback and ideas regards this problem. I'm sorry I cannot add any useful prompts to help you develop a plugin Wes as Spring and it's methods for injection are something I know nothing about. I have to admit, injection is not something I fully understand and anything I offered as a solution would likely be incorrect. However, my only real requirement (currently) is to obtain local references to both stateless and stateful session beans in Glassfish 2.1 from within Struts 2 action classes. Looking at Haroons' examples, this would seem to be exactly the solution I'm looking for and I will try and implement this. Can I just ask two further small questions to Haroon? Is the EJBInvokerServlet set to initialise at app startup via the web.xml definition? Does the EJBInvokerServlet approach work for stateful session bean references as well as stateless? Again, thank you for the time and effort everyone has gone through in providing ideas and solutions to this problem. It is good to know that this kind of expert help is available via the forum. Many thanks, Robin Wes Wannemacher wrote: On Thu, Jul 30, 2009 at 10:34 AM, Haroon Rafiqueharoon.rafi...@utoronto.ca wrote: Hi Wes, I don't know much of the details about the JEE spec, however, I can share my implementation with you. The code is not in production yet, so caveat emptor (it works for us, for now in development). I use glassfish as my app server. To expose local EJB interfaces within our entire application, I use an EJBInvokerServlet (uses the @EJB and @EJBs annotations). The listing is as follows (took out package and import statements and anonymized): @EJBs( value = { @EJB(beanInterface = Local1.class, name = ejb/local1), @EJB(beanInterface = Local2.class, name = ejb/local2), } ) /** * Used to make local interfaces of listed EJBs available within the whole * web application. */ public class EJBInvokerServlet extends HttpServlet { } The other way to inject beans is by specifying ejb-local-ref inside web.xml. ejb-local-ref ejb-ref-nameLocal1Bean/ejb-ref-name ejb-ref-typeSession/ejb-ref-type localLocal1/local /ejb-local-ref I prefer the Servlet approach as its simpler. Wherever we need the EJBs to be automagically injected (the container does its part because of EJBInvokerServlet), we then use the @Resource annotation, e.g., to inject the Local1 interface, I would use: @Resource(mappedName = ejb/local1) private Local1 local1; Hope that helps. Haroon, it does and it doesn't. @EJB/@EJBs and @Resource aren't the only DI annotations that are part of the EE specs. This is the problem Robin has with the existing integration plugins. My understanding of what he wants is that he wants to be able to use other annotations (like @PersistenceContext) on fields in a struts action and have those fields injected. To turn it around and consider it compared to another similar plugin... In the spring plugin, we delegate the class instantiation to spring, then spring can decide what needs injected, etc. based on spring configuration. What I'd like to do is apply the same concept to EE. To do this in spring, there is an implementation of the ObjectFactory that first tries to instantiate objects using spring, and when that fails, it falls back on traditional xwork instantiation (reflection-based). Once the object is created, the spring object factory then checks to see if it can autowire the instance (based on plugin configuration). I'd like to try a similar approach with EE. The hard part is that I don't know what API, or where to look for an API that instantiates EE objects. Spring has 'applicationContext.getBean', is there something similar for EE? Even if it's not as easy as Spring, I'm still willing to wade through it for a bit since it seems like it would be useful to at least a few users. The advantage to an object factory based EE plugin is that I don't need to be aware of the annotations at all, I'd be delegating that sort of thing to the EE app server's own mechanisms. -Wes No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.37/2273 - Release Date: 07/30/09 18:09:00
Re: EJB Injection in Interceptor
Hi Robin, see comments inline: On Today at 7:25pm, RM=Robin Mannering ro...@mtndesigns.co.uk wrote: RM [..snip..] RM RM Can I just ask two further small questions to Haroon? RM RM Is the EJBInvokerServlet set to initialise at app startup via the RM web.xml definition? RM Nope. Its not mentioned anywhere else in the app. Its just packaged in the .war file (which is inside the .ear). Glassfish does the right thing when it sees a servlet marked with the @EJB annotations. You can use the Glassfish Admin Console (usually http://localhost:4848/): Application Server - General tab - JNDI Browsing and you should find your EJBs under the ejb tree (the path to JNDI browsing is from memory). RM RM Does the EJBInvokerServlet approach work for stateful session bean RM references as well as stateless? RM Dunno. We have only done @Stateless. RM RM Again, thank you for the time and effort everyone has gone through in RM providing ideas and solutions to this problem. It is good to know RM that this kind of expert help is available via the forum. RM RM Many thanks, Robin RM Cheers, -- Haroon Rafique haroon.rafi...@utoronto.ca - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: EJB Injection in Interceptor
On Today at 2:02pm, HR=Haroon Rafique haroon.rafi...@utoronto.ca wrote: HR [..snip..] HR HR Nope. Its not mentioned anywhere else in the app. Its just packaged in HR the .war file (which is inside the .ear). Glassfish does the right thing HR when it sees a servlet marked with the @EJB annotations. You can use the HR Glassfish Admin Console (usually http://localhost:4848/): HR Application Server - General tab - JNDI Browsing HR and you should find your EJBs under the ejb tree (the path to JNDI HR browsing is from memory). HR Scratch that. The above only applies if you want to see @Remote ejbs. Cheers, -- Haroon Rafique haroon.rafi...@utoronto.ca - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: EJB Injection in Interceptor
Just to clear up my actual question from the thread below as feedback has run dry unfortunately. Is there anybody working daily with Struts 2 and EJB 3.0? If so, what is the best way to obtain local references to EJB 3 session beans from within Struts 2 action classes? Thanks for any thoughts on this subject. Robin Mannering wrote: Just wondering if the below thread has gone any further. After creating another thread on the same subject at an earlier date, we discussed using the EJB plugin here: http://cwiki.apache.org/S2PLUGINS/ejb3-plugin.html However, having started to use this plugin so that I can reference stateless session beans, it seems that all EJB Session bean classes must be defined as @Remote rather than @Local in order for the injection to obtain the references correctly. Failure to specify them as remote throws a javax.naming.NameNotFoundException. However, reading from a book entitled Pro EJB 3.0, the following performance issues are mentioned in relation to using @Remote when @Local is available. Hopefully this link will work for you. http://books.google.co.uk/books?id=fVCuB_Xq3pACpg=PA40lpg=PA40dq=Making+an+interface+remote+has+consequencessource=blots=Bg9DdpVAWWsig=vxrumZhYLhjmqbt6bdMJ96hrY7shl=enei=QIdtStuLC-WhjAf34KGeCwsa=Xoi=book_resultct=resultresnum= So, the problem is : How can we obtain references to EJB 3 session beans from within Struts 2 action classes? I'd be very interested to hear your thoughts. Thanks Robin Nathan Schulte wrote: Wes Wannemacher wesw at wantii.com writes: Seems to me that my idea to create an ObjectFactory based plugin ... needs to pick up some steam. I only have one question for the EJB users out there... Do you guys need Spring integration as well? To answer your question, _I_ personally don't need Spring integration. I've never used Spring, and for this project, it was too much overhead to learn (on top of Java EE, the JPA, Hibernate intricacies, Struts2...), and from what I understand, it seemed like using it and S2 together provided duplicate functionality (another topic altogether...). On another note, I find it awesome that the community (or whatever group you're part of) is so willing to provide support. I mean, in my eyes, this is something that I could see myself writing to make my coding easier, it's just that given my situation, it's easier to use the workaround. Admittedly, I'm not very familiar with JEE5. Some of this is still black magic, and I don't fully understand the issue, I just know enough to understand that the architecture permits it as an issue (and not everyone is just blowing smoke my way) and can leave all of the intricate details be, as they don't directly affect my project. -Nate - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.20/2248 - Release Date: 07/19/09 05:57:00 No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.31/2265 - Release Date: 07/26/09 17:59:00
Re: EJB Injection in Interceptor
You can either use Spring or implement your own EJB3 interceptor. Though I use my own EJB3 interceptor, I believe the best option is to go with Spring. Google Juice can also be option on the table as well. --- On Thu, 7/30/09, Robin Mannering ro...@mtndesigns.co.uk wrote: From: Robin Mannering ro...@mtndesigns.co.uk Subject: Re: EJB Injection in Interceptor To: Struts Users Mailing List user@struts.apache.org Received: Thursday, July 30, 2009, 6:17 AM Just to clear up my actual question from the thread below as feedback has run dry unfortunately. Is there anybody working daily with Struts 2 and EJB 3.0? If so, what is the best way to obtain local references to EJB 3 session beans from within Struts 2 action classes? Thanks for any thoughts on this subject. Robin Mannering wrote: Just wondering if the below thread has gone any further. After creating another thread on the same subject at an earlier date, we discussed using the EJB plugin here: http://cwiki.apache.org/S2PLUGINS/ejb3-plugin.html However, having started to use this plugin so that I can reference stateless session beans, it seems that all EJB Session bean classes must be defined as @Remote rather than @Local in order for the injection to obtain the references correctly. Failure to specify them as remote throws a javax.naming.NameNotFoundException. However, reading from a book entitled Pro EJB 3.0, the following performance issues are mentioned in relation to using @Remote when @Local is available. Hopefully this link will work for you. http://books.google.co.uk/books?id=fVCuB_Xq3pACpg=PA40lpg=PA40dq=Making+an+interface+remote+has+consequencessource=blots=Bg9DdpVAWWsig=vxrumZhYLhjmqbt6bdMJ96hrY7shl=enei=QIdtStuLC-WhjAf34KGeCwsa=Xoi=book_resultct=resultresnum= So, the problem is : How can we obtain references to EJB 3 session beans from within Struts 2 action classes? I'd be very interested to hear your thoughts. Thanks Robin Nathan Schulte wrote: Wes Wannemacher wesw at wantii.com writes: Seems to me that my idea to create an ObjectFactory based plugin ... needs to pick up some steam. I only have one question for the EJB users out there... Do you guys need Spring integration as well? To answer your question, _I_ personally don't need Spring integration. I've never used Spring, and for this project, it was too much overhead to learn (on top of Java EE, the JPA, Hibernate intricacies, Struts2...), and from what I understand, it seemed like using it and S2 together provided duplicate functionality (another topic altogether...). On another note, I find it awesome that the community (or whatever group you're part of) is so willing to provide support. I mean, in my eyes, this is something that I could see myself writing to make my coding easier, it's just that given my situation, it's easier to use the workaround. Admittedly, I'm not very familiar with JEE5. Some of this is still black magic, and I don't fully understand the issue, I just know enough to understand that the architecture permits it as an issue (and not everyone is just blowing smoke my way) and can leave all of the intricate details be, as they don't directly affect my project. -Nate - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.20/2248 - Release Date: 07/19/09 05:57:00 No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.31/2265 - Release Date: 07/26/09 17:59:00 __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: EJB Injection in Interceptor
Sorry Robin, this is on my to-do list, but it's not something I'm working on right this second. One thing that is holding me up is the lack of knowledge of JEE. Is there a standard mechanism for creating instances of EJB-hydrated objects? For instance, if you annotated a field on a servlet with @PersistenceContext, the entity manager will be populated on the servlet. Obviously this works because the app server instantiates the servlet and the app server knows to do things like this. Is it part of the spec(s) that there is a way to instantiate objects, complete with dependencies injected? I know you can get objects from the JNDI context, but would that mean that objects retrieved need to be defined in JNDI? In the example with the servlet and EM, the servlet is defined in the web.xml, not the JNDI context... So, is there a place where I can read up on standard instantiation with EE DI? If it's not part of the standard, then, I still wouldn't mind building something specific to the app server that you are using (provided it is something I can get my hands on for free i.e. JBoss, OpenEJB). I started looking into this when this came up a few weeks ago, but I wasn't finding what I wanted so it got put off. If there is a way for me to call into the app server's own instantiation w/ DI facilities, writing this plugin would be a snap... -Wes On Thu, Jul 30, 2009 at 2:17 AM, Robin Manneringro...@mtndesigns.co.uk wrote: Just to clear up my actual question from the thread below as feedback has run dry unfortunately. Is there anybody working daily with Struts 2 and EJB 3.0? If so, what is the best way to obtain local references to EJB 3 session beans from within Struts 2 action classes? Thanks for any thoughts on this subject. Robin Mannering wrote: Just wondering if the below thread has gone any further. After creating another thread on the same subject at an earlier date, we discussed using the EJB plugin here: http://cwiki.apache.org/S2PLUGINS/ejb3-plugin.html However, having started to use this plugin so that I can reference stateless session beans, it seems that all EJB Session bean classes must be defined as @Remote rather than @Local in order for the injection to obtain the references correctly. Failure to specify them as remote throws a javax.naming.NameNotFoundException. However, reading from a book entitled Pro EJB 3.0, the following performance issues are mentioned in relation to using @Remote when @Local is available. Hopefully this link will work for you. http://books.google.co.uk/books?id=fVCuB_Xq3pACpg=PA40lpg=PA40dq=Making+an+interface+remote+has+consequencessource=blots=Bg9DdpVAWWsig=vxrumZhYLhjmqbt6bdMJ96hrY7shl=enei=QIdtStuLC-WhjAf34KGeCwsa=Xoi=book_resultct=resultresnum= So, the problem is : How can we obtain references to EJB 3 session beans from within Struts 2 action classes? I'd be very interested to hear your thoughts. Thanks Robin Nathan Schulte wrote: Wes Wannemacher wesw at wantii.com writes: Seems to me that my idea to create an ObjectFactory based plugin ... needs to pick up some steam. I only have one question for the EJB users out there... Do you guys need Spring integration as well? To answer your question, _I_ personally don't need Spring integration. I've never used Spring, and for this project, it was too much overhead to learn (on top of Java EE, the JPA, Hibernate intricacies, Struts2...), and from what I understand, it seemed like using it and S2 together provided duplicate functionality (another topic altogether...). On another note, I find it awesome that the community (or whatever group you're part of) is so willing to provide support. I mean, in my eyes, this is something that I could see myself writing to make my coding easier, it's just that given my situation, it's easier to use the workaround. Admittedly, I'm not very familiar with JEE5. Some of this is still black magic, and I don't fully understand the issue, I just know enough to understand that the architecture permits it as an issue (and not everyone is just blowing smoke my way) and can leave all of the intricate details be, as they don't directly affect my project. -Nate - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.20/2248 - Release Date: 07/19/09 05:57:00 No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.31/2265 - Release Date: 07/26/09 17:59:00 -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven,
Re: EJB Injection in Interceptor
On Today at 9:16am, WW=Wes Wannemacher w...@wantii.com wrote: WW Sorry Robin, this is on my to-do list, but it's not something I'm WW working on right this second. One thing that is holding me up is the WW lack of knowledge of JEE. Is there a standard mechanism for creating WW instances of EJB-hydrated objects? WW WW [..snip..] WW Hi Wes, I don't know much of the details about the JEE spec, however, I can share my implementation with you. The code is not in production yet, so caveat emptor (it works for us, for now in development). I use glassfish as my app server. To expose local EJB interfaces within our entire application, I use an EJBInvokerServlet (uses the @EJB and @EJBs annotations). The listing is as follows (took out package and import statements and anonymized): @EJBs( value = { @EJB(beanInterface = Local1.class, name = ejb/local1), @EJB(beanInterface = Local2.class, name = ejb/local2), } ) /** * Used to make local interfaces of listed EJBs available within the whole * web application. */ public class EJBInvokerServlet extends HttpServlet { } The other way to inject beans is by specifying ejb-local-ref inside web.xml. ejb-local-ref ejb-ref-nameLocal1Bean/ejb-ref-name ejb-ref-typeSession/ejb-ref-type localLocal1/local /ejb-local-ref I prefer the Servlet approach as its simpler. Wherever we need the EJBs to be automagically injected (the container does its part because of EJBInvokerServlet), we then use the @Resource annotation, e.g., to inject the Local1 interface, I would use: @Resource(mappedName = ejb/local1) private Local1 local1; Hope that helps. -- Haroon Rafique haroon.rafi...@utoronto.ca - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: EJB Injection in Interceptor
On Thu, Jul 30, 2009 at 10:34 AM, Haroon Rafiqueharoon.rafi...@utoronto.ca wrote: Hi Wes, I don't know much of the details about the JEE spec, however, I can share my implementation with you. The code is not in production yet, so caveat emptor (it works for us, for now in development). I use glassfish as my app server. To expose local EJB interfaces within our entire application, I use an EJBInvokerServlet (uses the @EJB and @EJBs annotations). The listing is as follows (took out package and import statements and anonymized): �...@ejbs( value = { �...@ejb(beanInterface = Local1.class, name = ejb/local1), �...@ejb(beanInterface = Local2.class, name = ejb/local2), } ) /** * Used to make local interfaces of listed EJBs available within the whole * web application. */ public class EJBInvokerServlet extends HttpServlet { } The other way to inject beans is by specifying ejb-local-ref inside web.xml. ejb-local-ref ejb-ref-nameLocal1Bean/ejb-ref-name ejb-ref-typeSession/ejb-ref-type localLocal1/local /ejb-local-ref I prefer the Servlet approach as its simpler. Wherever we need the EJBs to be automagically injected (the container does its part because of EJBInvokerServlet), we then use the @Resource annotation, e.g., to inject the Local1 interface, I would use: �...@resource(mappedName = ejb/local1) private Local1 local1; Hope that helps. Haroon, it does and it doesn't. @EJB/@EJBs and @Resource aren't the only DI annotations that are part of the EE specs. This is the problem Robin has with the existing integration plugins. My understanding of what he wants is that he wants to be able to use other annotations (like @PersistenceContext) on fields in a struts action and have those fields injected. To turn it around and consider it compared to another similar plugin... In the spring plugin, we delegate the class instantiation to spring, then spring can decide what needs injected, etc. based on spring configuration. What I'd like to do is apply the same concept to EE. To do this in spring, there is an implementation of the ObjectFactory that first tries to instantiate objects using spring, and when that fails, it falls back on traditional xwork instantiation (reflection-based). Once the object is created, the spring object factory then checks to see if it can autowire the instance (based on plugin configuration). I'd like to try a similar approach with EE. The hard part is that I don't know what API, or where to look for an API that instantiates EE objects. Spring has 'applicationContext.getBean', is there something similar for EE? Even if it's not as easy as Spring, I'm still willing to wade through it for a bit since it seems like it would be useful to at least a few users. The advantage to an object factory based EE plugin is that I don't need to be aware of the annotations at all, I'd be delegating that sort of thing to the EE app server's own mechanisms. -Wes -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: EJB Injection in Interceptor
Just to note, there has been some work in OpenEJB to make it so Struts objects can use Java EE injection like Servlets or JSF components can. Karan did the work, he might be able to give more detail. -David On Jul 30, 2009, at 6:16 AM, Wes Wannemacher wrote: Sorry Robin, this is on my to-do list, but it's not something I'm working on right this second. One thing that is holding me up is the lack of knowledge of JEE. Is there a standard mechanism for creating instances of EJB-hydrated objects? For instance, if you annotated a field on a servlet with @PersistenceContext, the entity manager will be populated on the servlet. Obviously this works because the app server instantiates the servlet and the app server knows to do things like this. Is it part of the spec(s) that there is a way to instantiate objects, complete with dependencies injected? I know you can get objects from the JNDI context, but would that mean that objects retrieved need to be defined in JNDI? In the example with the servlet and EM, the servlet is defined in the web.xml, not the JNDI context... So, is there a place where I can read up on standard instantiation with EE DI? If it's not part of the standard, then, I still wouldn't mind building something specific to the app server that you are using (provided it is something I can get my hands on for free i.e. JBoss, OpenEJB). I started looking into this when this came up a few weeks ago, but I wasn't finding what I wanted so it got put off. If there is a way for me to call into the app server's own instantiation w/ DI facilities, writing this plugin would be a snap... -Wes On Thu, Jul 30, 2009 at 2:17 AM, Robin Manneringro...@mtndesigns.co.uk wrote: Just to clear up my actual question from the thread below as feedback has run dry unfortunately. Is there anybody working daily with Struts 2 and EJB 3.0? If so, what is the best way to obtain local references to EJB 3 session beans from within Struts 2 action classes? Thanks for any thoughts on this subject. Robin Mannering wrote: Just wondering if the below thread has gone any further. After creating another thread on the same subject at an earlier date, we discussed using the EJB plugin here: http://cwiki.apache.org/S2PLUGINS/ejb3-plugin.html However, having started to use this plugin so that I can reference stateless session beans, it seems that all EJB Session bean classes must be defined as @Remote rather than @Local in order for the injection to obtain the references correctly. Failure to specify them as remote throws a javax.naming.NameNotFoundException. However, reading from a book entitled Pro EJB 3.0, the following performance issues are mentioned in relation to using @Remote when @Local is available. Hopefully this link will work for you. http://books.google.co.uk/books?id=fVCuB_Xq3pACpg=PA40lpg=PA40dq=Making+an+interface+remote+has+consequencessource=blots=Bg9DdpVAWWsig=vxrumZhYLhjmqbt6bdMJ96hrY7shl=enei=QIdtStuLC-WhjAf34KGeCwsa=Xoi=book_resultct=resultresnum= So, the problem is : How can we obtain references to EJB 3 session beans from within Struts 2 action classes? I'd be very interested to hear your thoughts. Thanks Robin Nathan Schulte wrote: Wes Wannemacher wesw at wantii.com writes: Seems to me that my idea to create an ObjectFactory based plugin ... needs to pick up some steam. I only have one question for the EJB users out there... Do you guys need Spring integration as well? To answer your question, _I_ personally don't need Spring integration. I've never used Spring, and for this project, it was too much overhead to learn (on top of Java EE, the JPA, Hibernate intricacies, Struts2...), and from what I understand, it seemed like using it and S2 together provided duplicate functionality (another topic altogether...). On another note, I find it awesome that the community (or whatever group you're part of) is so willing to provide support. I mean, in my eyes, this is something that I could see myself writing to make my coding easier, it's just that given my situation, it's easier to use the workaround. Admittedly, I'm not very familiar with JEE5. Some of this is still black magic, and I don't fully understand the issue, I just know enough to understand that the architecture permits it as an issue (and not everyone is just blowing smoke my way) and can leave all of the intricate details be, as they don't directly affect my project. -Nate - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database: 270.13.20/2248 - Release Date: 07/19/09 05:57:00
Re: EJB Injection in Interceptor
Robin Mannering robin at mtndesigns.co.uk writes: http://cwiki.apache.org/S2PLUGINS/ejb3-plugin.html Are you using that plugin, or the following? http://cwiki.apache.org/S2PLUGINS/ejb3-jboss-plugin.html With the JBoss plugin, I am able to use Local interfaces rather than remote. I can show an example of this as well if you think it might help. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
EJB Injection in Interceptor
This may be more related to XWork2, but I'll start by asking here. I'm creating a custom Interceptor to handle user permissions for an application. Rather than redirecting to an action to actually process a login attempt (requiring a custom result type), the Interceptor itself will process the login attempt. However, in order for this to work, the Interceptor needs access to a session bean that is the interface to the persistence layer. Is it possible to use the Java EE 5 @EJB annotation to inject an EJB, or even the Inject EJB Plugin? I've tried both, and neither seem to work (both result in a null object reference). I realize I can use a JNDI lookup to get a reference to the bean, but I would much rather use injection if possible, as that's why it's there. Thanks! -Nate - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: EJB Injection in Interceptor
The short answer - You have to do the lookup yourself. The long answer - There's a similar discussion going on that pretty much covers the topic: http://www.nabble.com/Struts2-Action-Class-and-EJB-Injection-td24497801.html Nils-H On Thu, Jul 16, 2009 at 10:03 PM, Nathan Schultenathan.schu...@ngc.com wrote: This may be more related to XWork2, but I'll start by asking here. I'm creating a custom Interceptor to handle user permissions for an application. Rather than redirecting to an action to actually process a login attempt (requiring a custom result type), the Interceptor itself will process the login attempt. However, in order for this to work, the Interceptor needs access to a session bean that is the interface to the persistence layer. Is it possible to use the Java EE 5 @EJB annotation to inject an EJB, or even the Inject EJB Plugin? I've tried both, and neither seem to work (both result in a null object reference). I realize I can use a JNDI lookup to get a reference to the bean, but I would much rather use injection if possible, as that's why it's there. Thanks! -Nate - 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: EJB Injection in Interceptor
Nils-Helge Garli Hegvik nilsga at gmail.com writes: The short answer - You have to do the lookup yourself. :/ The long answer - There's a similar discussion going on that pretty much covers the topic: http://www.nabble.com/Struts2-Action-Class-and-EJB-Injection-td24497801.html Yes, I'm familiar with this issue. I guess, in order to resolve it in an Interceptor as opposed to an Action (the method of using an Interceptor and reflection to do the injection), one would have to do the same for the Interceptors... Oh well, you can't win all of the time. Thanks for the speedy reply! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: EJB Injection in Interceptor
On Thursday 16 July 2009 04:20:05 pm Nathan Schulte wrote: Nils-Helge Garli Hegvik nilsga at gmail.com writes: The short answer - You have to do the lookup yourself. :/ : The long answer - There's a similar discussion going on that pretty much covers the topic: http://www.nabble.com/Struts2-Action-Class-and-EJB-Injection-td24497801.h tml Yes, I'm familiar with this issue. I guess, in order to resolve it in an Interceptor as opposed to an Action (the method of using an Interceptor and reflection to do the injection), one would have to do the same for the Interceptors... Oh well, you can't win all of the time. Thanks for the speedy reply! Seems to me that my idea to create an ObjectFactory based plugin (rather than the existing interceptor-based plugins) needs to pick up some steam. I only have one question for the EJB users out there... Do you guys need Spring integration as well? Currently, the spring plugin is the only plugin (I know of) that is based on a replacement ObjectFactory. If you don't need Spring, I could probably put one together pretty quick. If you need Spring, it would take a little longer, or it could be a separate plugin... -Wes -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: EJB Injection in Interceptor
Wes Wannemacher wesw at wantii.com writes: Seems to me that my idea to create an ObjectFactory based plugin ... needs to pick up some steam. I only have one question for the EJB users out there... Do you guys need Spring integration as well? To answer your question, _I_ personally don't need Spring integration. I've never used Spring, and for this project, it was too much overhead to learn (on top of Java EE, the JPA, Hibernate intricacies, Struts2...), and from what I understand, it seemed like using it and S2 together provided duplicate functionality (another topic altogether...). On another note, I find it awesome that the community (or whatever group you're part of) is so willing to provide support. I mean, in my eyes, this is something that I could see myself writing to make my coding easier, it's just that given my situation, it's easier to use the workaround. Admittedly, I'm not very familiar with JEE5. Some of this is still black magic, and I don't fully understand the issue, I just know enough to understand that the architecture permits it as an issue (and not everyone is just blowing smoke my way) and can leave all of the intricate details be, as they don't directly affect my project. -Nate - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Interceptor Execution Tracing
Is it possible to easily see a record of all the interceptors executed during an action invocation? I want to see the actual interceptors that are executed, not the config (which shows me what I _think_ is happening). Thanks, Steve -- Stephen Turner Sr. Analyst/Programmer MIT IST - SAIS - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor Execution Tracing
Hi Stephen, turn debug on by adding ?profiling=true after any action address in browser and turning devMode. Read more here: http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/util/profiling/UtilTimerStack.html Best greetings, Paweł Wielgus. 2009/7/2 Stephen Turner stur...@mit.edu: Is it possible to easily see a record of all the interceptors executed during an action invocation? I want to see the actual interceptors that are executed, not the config (which shows me what I _think_ is happening). Thanks, Steve -- Stephen Turner Sr. Analyst/Programmer MIT IST - SAIS - 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: Interceptor Execution Tracing
On Thu, 02 Jul 2009 08:37:28 -0400, Paweł Wielgus poulw...@gmail.com wrote: Hi Stephen, turn debug on by adding ?profiling=true after any action address in browser and turning devMode. Read more here: http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/util/profiling/UtilTimerStack.html Best greetings, Paweł Wielgus. Thanks Paweł, that's exactly what I was looking for - Steve -- Stephen Turner Sr. Analyst/Programmer MIT IST - SAIS - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Need help writing an interceptor to force a user to change their password
Thanks Nate and Tim. Worked like a charm. Russ Sarr, Nathan wrote: Hi Russ, You may want to try creating a global result in your struts.xml: global-results result name=change-password/pages/user/login/force_change_password.jsp/result /global-results Then in your interceptor return the result name change-password That is how we accomplished something similar to your pblem. Hope this helps. -Nate From: Russell Neufeld [mailto:russ.neuf...@hds.com] Sent: Mon 6/29/2009 5:19 PM To: Struts Users Mailing List Subject: Need help writing an interceptor to force a user to change their password Hi all, I'm trying to implement functionality which will force a user to a change-password page if a certain bit is set on their user account. That is, no matter what action they are attempting to take, I'd like to intercept the request and show them a change-password page. I've written a few struts2 interceptors before, but this one has me stumped. I can easily get the user principal object and see whether or not I need to insert the change-password page, but I'm not sure what to do next. I was thinking about trying to change the action object to one which would simply return a string pointing to the change-password jsp, but I don't know how to replace the action object on the invocation object (and that doesn't seem like a good idea). I'd prefer not to solve this with a redirect because I'd like to use some of the context of current request in the rendering of the change-password page. Any ideas? Thanks, Russ - 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
Need help writing an interceptor to force a user to change their password
Hi all, I'm trying to implement functionality which will force a user to a change-password page if a certain bit is set on their user account. That is, no matter what action they are attempting to take, I'd like to intercept the request and show them a change-password page. I've written a few struts2 interceptors before, but this one has me stumped. I can easily get the user principal object and see whether or not I need to insert the change-password page, but I'm not sure what to do next. I was thinking about trying to change the action object to one which would simply return a string pointing to the change-password jsp, but I don't know how to replace the action object on the invocation object (and that doesn't seem like a good idea). I'd prefer not to solve this with a redirect because I'd like to use some of the context of current request in the rendering of the change-password page. Any ideas? Thanks, Russ
Need help writing an interceptor to force a user to change their password
Hi all, I'm trying to implement functionality which will force a user to a change-password page if a certain bit is set on their user account. That is, no matter what action they are attempting to take, I'd like to intercept the request and show them a change-password page. I've written a few struts2 interceptors before, but this one has me stumped. I can easily get the user principal object and see whether or not I need to insert the change-password page, but I'm not sure what to do next. I was thinking about trying to change the action object to one which would simply return a string pointing to the change-password jsp, but I don't know how to replace the action object on the invocation object (and that doesn't seem like a good idea). I'd prefer not to solve this with a redirect because I'd like to use some of the context of current request in the rendering of the change-password page. Any ideas? Thanks, Russ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Need help writing an interceptor to force a user to change their password
You should be able to just create a global result with the jsp you want. Ala: global-results result name=passwordChange/passwordChange.jsp/result /global-results Then have the interceptor return that string when needed. Any time it's true, the result will get hit and the user will get fowarded. Unless I'm missing something. -Tim Russell Neufeld wrote: Hi all, I'm trying to implement functionality which will force a user to a change-password page if a certain bit is set on their user account. That is, no matter what action they are attempting to take, I'd like to intercept the request and show them a change-password page. I've written a few struts2 interceptors before, but this one has me stumped. I can easily get the user principal object and see whether or not I need to insert the change-password page, but I'm not sure what to do next. I was thinking about trying to change the action object to one which would simply return a string pointing to the change-password jsp, but I don't know how to replace the action object on the invocation object (and that doesn't seem like a good idea). I'd prefer not to solve this with a redirect because I'd like to use some of the context of current request in the rendering of the change-password page. Any ideas? Thanks, Russ - 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: Need help writing an interceptor to force a user to change their password
Hi Russ, You may want to try creating a global result in your struts.xml: global-results result name=change-password/pages/user/login/force_change_password.jsp/result /global-results Then in your interceptor return the result name change-password That is how we accomplished something similar to your pblem. Hope this helps. -Nate From: Russell Neufeld [mailto:russ.neuf...@hds.com] Sent: Mon 6/29/2009 5:19 PM To: Struts Users Mailing List Subject: Need help writing an interceptor to force a user to change their password Hi all, I'm trying to implement functionality which will force a user to a change-password page if a certain bit is set on their user account. That is, no matter what action they are attempting to take, I'd like to intercept the request and show them a change-password page. I've written a few struts2 interceptors before, but this one has me stumped. I can easily get the user principal object and see whether or not I need to insert the change-password page, but I'm not sure what to do next. I was thinking about trying to change the action object to one which would simply return a string pointing to the change-password jsp, but I don't know how to replace the action object on the invocation object (and that doesn't seem like a good idea). I'd prefer not to solve this with a redirect because I'd like to use some of the context of current request in the rendering of the change-password page. Any ideas? Thanks, Russ - 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
Interceptor Use
Hello, Struts 2.1.6 I wish to ensure a user is logged into an application before allowing him/her to execute certain tasks. Would using an Interceptor be a good way to go? My idea is to retrieve session data in the intercept() method of the interceptor and verify a certain attribute is held in the session. If it is not, I would then like to redirect the user to a login page with an appropriate error message. Is this an approriate use of interceptors? Previously, I simply had a verifyLoginStatus() method in a base action class which I extended in actions I wanted to protect. I'd appreciate any thoughts... Thanks Robin - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor Use
Robin Mannering wrote: I wish to ensure a user is logged into an application before allowing him/her to execute certain tasks. Would using an Interceptor be a good way to go? Yep. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor Use
This is a very appropriate use for interceptors. You might also want to look at Spring Security, which does this and a lot more without too much configuration pain. jk On Sat, Jun 27, 2009 at 12:25 PM, Robin Mannering ro...@mtndesigns.co.ukwrote: Hello, Struts 2.1.6 I wish to ensure a user is logged into an application before allowing him/her to execute certain tasks. Would using an Interceptor be a good way to go? My idea is to retrieve session data in the intercept() method of the interceptor and verify a certain attribute is held in the session. If it is not, I would then like to redirect the user to a login page with an appropriate error message. Is this an approriate use of interceptors? Previously, I simply had a verifyLoginStatus() method in a base action class which I extended in actions I wanted to protect. I'd appreciate any thoughts... Thanks Robin - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Jim Kiley Senior Technical Consultant | Summa [p] 412.258.3346 http://www.summa-tech.com
Custom validation interceptor
Hi,I have following requirement:If validation of the page fails 3 times in row - invalidate session and redirect to index page.Should I replace default validation interceptor in default stack with my own to achieve what I am after?I there any other way?Any hint would be greatly appreciatedPeter.
Re: Custom validation interceptor
I don't think a custom interceptor is required. You could probably get this done through hidden parameters or by storing attempts in the session or something. Do you have this req for one action or all actions in the app? On 6/20/09, Peter Bliznak bliz...@rogers.com wrote: Hi, I have following requirement: If validation of the page fails 3 times in row - invalidate session and redirect to index page. Should I replace default validation interceptor in default stack with my own to achieve what I am after? I there any other way? Any hint would be greatly appreciated Peter. -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Custom validation interceptor
Peter Bliznak wrote: I have following requirement: If validation of the page fails 3 times in row - invalidate session and redirect to index page. Should I replace default validation interceptor in default stack with my own to achieve what I am after? I there any other way? Is this across the entire app or just a single action? If it's just a single action then this could probably be done via a session var or a hidden counter (updated in the actions validate() method)... although I'm not sure how you'd tell the workflow interceptor to go to the strike three page. AFAICT the workflow.inputResultName parameter doesn't eval OGNL, so you'd have to set the result location in the action--seems messy. I started off thinking no on the interceptor, but now I'm not so sure. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Custom validation interceptor
It is across entire app (there are many dozen of actions) - every single action has to have same behavior - 3 crosses go and try again. It's app for changing personal info on government issued documents - sorta wizard like thing. I can see how I can do it by keeping eye of parameters - but I am looking for cleanest possible implementation. But if I decide to modify default stack I am not certain what might be consequences for the rest of app. From: Dave Newton newton.d...@yahoo.com To: Struts Users Mailing List user@struts.apache.org Sent: Saturday, June 20, 2009 7:57:24 PM Subject: Re: Custom validation interceptor Peter Bliznak wrote: I have following requirement: If validation of the page fails 3 times in row - invalidate session and redirect to index page. Should I replace default validation interceptor in default stack with my own to achieve what I am after? I there any other way? Is this across the entire app or just a single action? If it's just a single action then this could probably be done via a session var or a hidden counter (updated in the actions validate() method)... although I'm not sure how you'd tell the workflow interceptor to go to the strike three page. AFAICT the workflow.inputResultName parameter doesn't eval OGNL, so you'd have to set the result location in the action--seems messy. I started off thinking no on the interceptor, but now I'm not so sure. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Custom validation interceptor
Peter Bliznak wrote: It is across entire app (there are many dozen of actions) - every single action has to have same behavior - 3 crosses go and try again. It's app for changing personal info on government issued documents - sorta wizard like thing. I can see how I can do it by keeping eye of parameters - but I am looking for cleanest possible implementation. But if I decide to modify default stack I am not certain what might be consequences for the rest of app. None, if you do it right. Since it's across the entire app I'd go the interceptor route--but you're still going to have to either use a hidden parameter, keep something in session, or whatever. Both have their advantages and disadvantages, but are basically the same complexity. I'd probably consider modifying the s:form template to insert a hidden parameter, but that leaves it vulnerable to someone spoofing the validation count--if that's an issue. Otherwise you'd have to track a session variable, re-initialize it when a form is displayed for the first time, and so on. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Custom validation interceptor
Preciously!..what you said about changing form is exactly what I was thinking. From: Dave Newton newton.d...@yahoo.com To: Struts Users Mailing List user@struts.apache.org Sent: Saturday, June 20, 2009 8:35:50 PM Subject: Re: Custom validation interceptor Peter Bliznak wrote: It is across entire app (there are many dozen of actions) - every single action has to have same behavior - 3 crosses go and try again. It's app for changing personal info on government issued documents - sorta wizard like thing. I can see how I can do it by keeping eye of parameters - but I am looking for cleanest possible implementation. But if I decide to modify default stack I am not certain what might be consequences for the rest of app. None, if you do it right. Since it's across the entire app I'd go the interceptor route--but you're still going to have to either use a hidden parameter, keep something in session, or whatever. Both have their advantages and disadvantages, but are basically the same complexity. I'd probably consider modifying the s:form template to insert a hidden parameter, but that leaves it vulnerable to someone spoofing the validation count--if that's an issue. Otherwise you'd have to track a session variable, re-initialize it when a form is displayed for the first time, and so on. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor issue in Struts 2.1.6
Yanto wrote: thanks, we are able to run the interceptor now, but we have another issue, the interceptor will Loop, we create the sample follow the code from the webworks *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { System.*out*.println(Testing the interceptor flow from TEST:); *return* invocation.invoke(); } } You're saying that with the above interceptor invoking the action loops infinitely and without it it doesn't? We'd need to see the action and interceptor configuration at the least. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor issue in Struts 2.1.6
Hi Dave, thanks, we already solve the interceptor issue, we need to include the defaultstack before the custom interceptor.. after that it's working fine... Regards Yanto On Thu, Jun 18, 2009 at 7:36 PM, Dave Newton newton.d...@yahoo.com wrote: Yanto wrote: thanks, we are able to run the interceptor now, but we have another issue, the interceptor will Loop, we create the sample follow the code from the webworks *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { System.*out*.println(Testing the interceptor flow from TEST:); *return* invocation.invoke(); } } You're saying that with the above interceptor invoking the action loops infinitely and without it it doesn't? We'd need to see the action and interceptor configuration at the least. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor issue in Struts 2.1.6
Finally we found the issue is actually with the theme, we need to stop using simple themeand the validation and interceptor will work. http://www.nabble.com/Struts2-Validation-not-working-with-theme-simple-td23127366.html just wondering, is there any other theme that working with validation ? Regards Yanto On Wed, Jun 17, 2009 at 11:39 AM, Yanto yantob...@gmail.com wrote: Hi Dave, after following your note, we are able to run our sample interceptor, however now we have another issue the sample interceptor will always looping, since we have the following code in the sample interceptor, *return* invocation.invoke(); but the sample interceptor will not run, if we are not include this code. == interceptors interceptor name=*sample* class=* com.obs.ssts.framework.interceptor.InterceptorSample*/ interceptor-stack name=*MyInterceptorStack* interceptor-ref name=*prepare*/ interceptor-ref name=*modelDriven*/ interceptor-ref name=*exception*/ interceptor-ref name=*servletConfig*/ interceptor-ref name=*checkbox*/ interceptor-ref name=*params*/ ***interceptor-ref** name=**sample**/*** /interceptor-stack /interceptors default-interceptor-ref name=*MyInterceptorStack*/ action name=*authentication* method=*authentication* class=* loginAction* resultmain.*jsp*/result /action Now my action calls going in loop and after added the myinterceptostack *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor flow from TEST: ); System.*out*.println(Testing the interceptor flow from TEST :); *return* invocation.invoke(); } } Thanks Yanto On Tue, Jun 16, 2009 at 7:32 PM, Dave Newton newton.d...@yahoo.comwrote: Yanto wrote: action name=test class=test.QuizAction interceptor-ref name=sample / /action This will configure *only* the sample interceptor. If you specify *any* interceptors on a per-action basis you must configure *all* interceptors. This can be done in several ways. - specify all interceptors in the action's configuration (you can specify interceptor stacks as well as single interceptors) - creating a new stack including your custom interceptor and using that stack in your action configuration - same, but define the new stack and using it as the default stack Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor issue in Struts 2.1.6
All of the themes work with validation, it just depends on what you are expecting out of validation. The validation workflow interceptors will stop processing if validation fails and then indicate to the framework that the input result should be rendered. Whether and how you show the validation errors is a function of the view. The simple theme does not display validation/action errors without the help of tags such as s:fielderror and s:actionerror. The xhtml and css themes will show the errors, but you do not have as much freedom, as far as placement. The ajax theme is pretty much like xhtml. -Wes On Wed, Jun 17, 2009 at 6:15 AM, Yantoyantob...@gmail.com wrote: Finally we found the issue is actually with the theme, we need to stop using simple themeand the validation and interceptor will work. http://www.nabble.com/Struts2-Validation-not-working-with-theme-simple-td23127366.html just wondering, is there any other theme that working with validation ? Regards Yanto On Wed, Jun 17, 2009 at 11:39 AM, Yanto yantob...@gmail.com wrote: Hi Dave, after following your note, we are able to run our sample interceptor, however now we have another issue the sample interceptor will always looping, since we have the following code in the sample interceptor, *return* invocation.invoke(); but the sample interceptor will not run, if we are not include this code. == interceptors interceptor name=*sample* class=* com.obs.ssts.framework.interceptor.InterceptorSample*/ interceptor-stack name=*MyInterceptorStack* interceptor-ref name=*prepare*/ interceptor-ref name=*modelDriven*/ interceptor-ref name=*exception*/ interceptor-ref name=*servletConfig*/ interceptor-ref name=*checkbox*/ interceptor-ref name=*params*/ ***interceptor-ref** name=**sample**/*** /interceptor-stack /interceptors default-interceptor-ref name=*MyInterceptorStack*/ action name=*authentication* method=*authentication* class=* loginAction* resultmain.*jsp*/result /action Now my action calls going in loop and after added the myinterceptostack *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor flow from TEST: ); System.*out*.println(Testing the interceptor flow from TEST :); *return* invocation.invoke(); } } Thanks Yanto On Tue, Jun 16, 2009 at 7:32 PM, Dave Newton newton.d...@yahoo.comwrote: Yanto wrote: action name=test class=test.QuizAction interceptor-ref name=sample / /action This will configure *only* the sample interceptor. If you specify *any* interceptors on a per-action basis you must configure *all* interceptors. This can be done in several ways. - specify all interceptors in the action's configuration (you can specify interceptor stacks as well as single interceptors) - creating a new stack including your custom interceptor and using that stack in your action configuration - same, but define the new stack and using it as the default stack Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Why all this WARN on interceptor (and how to eliminate?)
Hi all. I developed an application with struts2, tiles and EJB using jboss. In the log of jboss i've a lot of warning: 15:28:13,484 WARN [InterceptorRegistry] applicable interceptors is non-existent for public boolean session.MGMTBean.addCustomer(java.lang.String,java.lang.Stri ng,java.lang.String,java.lang.String,java.lang.String,double) 15:28:13,500 WARN [InterceptorRegistry] applicable interceptors is non-existent for public java.util.List session.MGMTBean.getAllOrders(entity.Customer) 15:28:13,515 WARN [InterceptorRegistry] applicable interceptors is non-existent for public java.util.List session.MGMTBean.getAllBought(int) 15:28:13,515 WARN [InterceptorRegistry] applicable interceptors is non-existent for public java.util.List session.MGMTBean.getAllItemByCategory(int) 15:28:13,531 WARN [InterceptorRegistry] applicable interceptors is non-existent for public entity.Customer session.MGMTBean.findCustomer(int) 15:28:13,593 WARN [InterceptorRegistry] applicable interceptors is non-existent for public java.util.List session.MGMTBean.findSimilarItem(entity.Item) 15:28:13,609 WARN [InterceptorRegistry] applicable interceptors is non-existent for public double session.MGMTBean.getTotalSpend(entity.Customer) 15:28:13,609 WARN [InterceptorRegistry] applicable interceptors is non-existent for public boolean session.MGMTBean.updateItem(int,java.lang.String,int, java.la ng.String,double,int,java.lang.String) where MGMTBean is my EJB. How can i eliminate all these outputs? (i think, (i done a fast check in the log file) is only in the command (cmd), not in the log file). -- Stefano
Re: Why all this WARN on interceptor (and how to eliminate?)
I think it's unrelated to Struts, check that [1] [1] http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.0/html/EJB3_Interceptors.html Regards -- Lukasz 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: Interceptor issue in Struts 2.1.6
Hi Wes, thanks for the explaination, we decide to use the simple theme and use the tag to display the error. Case closed, thanks for others also that already help... Regards Yanto On Wed, Jun 17, 2009 at 8:57 PM, Wes Wannemacher w...@wantii.com wrote: All of the themes work with validation, it just depends on what you are expecting out of validation. The validation workflow interceptors will stop processing if validation fails and then indicate to the framework that the input result should be rendered. Whether and how you show the validation errors is a function of the view. The simple theme does not display validation/action errors without the help of tags such as s:fielderror and s:actionerror. The xhtml and css themes will show the errors, but you do not have as much freedom, as far as placement. The ajax theme is pretty much like xhtml. -Wes On Wed, Jun 17, 2009 at 6:15 AM, Yantoyantob...@gmail.com wrote: Finally we found the issue is actually with the theme, we need to stop using simple themeand the validation and interceptor will work. http://www.nabble.com/Struts2-Validation-not-working-with-theme-simple-td23127366.html just wondering, is there any other theme that working with validation ? Regards Yanto On Wed, Jun 17, 2009 at 11:39 AM, Yanto yantob...@gmail.com wrote: Hi Dave, after following your note, we are able to run our sample interceptor, however now we have another issue the sample interceptor will always looping, since we have the following code in the sample interceptor, *return* invocation.invoke(); but the sample interceptor will not run, if we are not include this code. == interceptors interceptor name=*sample* class=* com.obs.ssts.framework.interceptor.InterceptorSample*/ interceptor-stack name=*MyInterceptorStack* interceptor-ref name=*prepare*/ interceptor-ref name=*modelDriven*/ interceptor-ref name=*exception*/ interceptor-ref name=*servletConfig*/ interceptor-ref name=*checkbox*/ interceptor-ref name=*params*/ ***interceptor-ref** name=**sample**/*** /interceptor-stack /interceptors default-interceptor-ref name=*MyInterceptorStack*/ action name=*authentication* method=*authentication* class=* loginAction* resultmain.*jsp*/result /action Now my action calls going in loop and after added the myinterceptostack *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor flow from TEST: ); System.*out*.println(Testing the interceptor flow from TEST :); *return* invocation.invoke(); } } Thanks Yanto On Tue, Jun 16, 2009 at 7:32 PM, Dave Newton newton.d...@yahoo.com wrote: Yanto wrote: action name=test class=test.QuizAction interceptor-ref name=sample / /action This will configure *only* the sample interceptor. If you specify *any* interceptors on a per-action basis you must configure *all* interceptors. This can be done in several ways. - specify all interceptors in the action's configuration (you can specify interceptor stacks as well as single interceptors) - creating a new stack including your custom interceptor and using that stack in your action configuration - same, but define the new stack and using it as the default stack Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Why all this WARN on interceptor (and how to eliminate?)
Ok i can ignore them. On Wed, Jun 17, 2009 at 15:34, Lukasz Lenart lukasz.len...@googlemail.comwrote: I think it's unrelated to Struts, check that [1] [1] http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.0/html/EJB3_Interceptors.html Regards -- Lukasz http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Stefano
Interceptor issue in Struts 2.1.6
Hi, I am trying to use the following simple interceptor test the interceptor concepts but is not happened while calling the action class. Sample interceptor class. *import* *com.opensymphony.xwork2.ActionContext*; *import* com.opensymphony.xwork2.ActionInvocation; *import* com.opensymphony.xwork2.interceptor.AbstractInterceptor; *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor : calling the interceptor sample); *return* success; } } I configured in the struts.xml for my action class using below config. package name=*test* namespace=*/test* extends=*struts-default* * interceptors* *interceptor name=sample class=sample.**InterceptorSample* * /* * /interceptors* action name=*test* class=*test.QuizAction* interceptor-ref name=*sample*/ result name=*success*/input.*jsp*/result result name=*error*/input.*jsp*/result result name=*input*/input.*jsp*/result /action /package I noted nothing printed and anyone can help to resolve the issue. Thanks Yanto
Re: Interceptor issue in Struts 2.1.6
Hi Yanto, use this [1] plugin to verify if all namespaces and stacks are as You think they should be. [1] http://struts.apache.org/2.x/docs/config-browser-plugin.html Best greetings, Paweł Wielgus. 2009/6/16 Yanto yantob...@gmail.com: Hi, I am trying to use the following simple interceptor test the interceptor concepts but is not happened while calling the action class. Sample interceptor class. *import* *com.opensymphony.xwork2.ActionContext*; *import* com.opensymphony.xwork2.ActionInvocation; *import* com.opensymphony.xwork2.interceptor.AbstractInterceptor; *public* *class* *InterceptorSample* *extends* AbstractInterceptor { �...@override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor : calling the interceptor sample); *return* success; } } I configured in the struts.xml for my action class using below config. package name=*test* namespace=*/test* extends=*struts-default* * interceptors* * interceptor name=sample class=sample.**InterceptorSample* * /* * /interceptors* action name=*test* class=*test.QuizAction* interceptor-ref name=*sample*/ result name=*success*/input.*jsp*/result result name=*error*/input.*jsp*/result result name=*input*/input.*jsp*/result /action /package I noted nothing printed and anyone can help to resolve the issue. Thanks Yanto - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor issue in Struts 2.1.6
Hi Pawel, thanks for the link we already check the interceptor for the namespace, and it's showing the interceptor yang we configure in the config-browser-plugin TimerInterceptor com.opensymphony.xwork2.interceptor.TimerInterceptor but, when we check from the Apache console, the interceptor is not in the console log for 2.1.6, when we run the same code in the 2.0.6 at the end of the apache log, it show the interceptor is envoked. Is there any additional configuration need to be setup to enable the interceptor in 2.1.6 ? beside the one we already setup as in previous email. Name Type ExceptionMappingInterceptor com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor AliasInterceptor com.opensymphony.xwork2.interceptor.AliasInterceptor ServletConfigInterceptor org.apache.struts2.interceptor.ServletConfigInterceptor I18nInterceptor com.opensymphony.xwork2.interceptor.I18nInterceptor PrepareInterceptor com.opensymphony.xwork2.interceptor.PrepareInterceptor ChainingInterceptor com.opensymphony.xwork2.interceptor.ChainingInterceptor DebuggingInterceptor org.apache.struts2.interceptor.debugging.DebuggingInterceptor ProfilingActivationInterceptor org.apache.struts2.interceptor.ProfilingActivationInterceptor ScopedModelDrivenInterceptor com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor ModelDrivenInterceptor com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor FileUploadInterceptor org.apache.struts2.interceptor.FileUploadInterceptor CheckboxInterceptor org.apache.struts2.interceptor.CheckboxInterceptor StaticParametersInterceptor com.opensymphony.xwork2.interceptor.StaticParametersInterceptor ActionMappingParametersInteceptor org.apache.struts2.interceptor.ActionMappingParametersInteceptor ParametersInterceptor com.opensymphony.xwork2.interceptor.ParametersInterceptor StrutsConversionErrorInterceptor org.apache.struts2.interceptor.StrutsConversionErrorInterceptor AnnotationValidationInterceptor org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor DefaultWorkflowInterceptor com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor TimerInterceptor com.opensymphony.xwork2.interceptor.TimerInterceptor Thanks Yanto 2009/6/16 Paweł Wielgus poulw...@gmail.com Hi Yanto, use this [1] plugin to verify if all namespaces and stacks are as You think they should be. [1] http://struts.apache.org/2.x/docs/config-browser-plugin.html Best greetings, Paweł Wielgus. 2009/6/16 Yanto yantob...@gmail.com: Hi, I am trying to use the following simple interceptor test the interceptor concepts but is not happened while calling the action class. Sample interceptor class. *import* *com.opensymphony.xwork2.ActionContext*; *import* com.opensymphony.xwork2.ActionInvocation; *import* com.opensymphony.xwork2.interceptor.AbstractInterceptor; *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor : calling the interceptor sample); *return* success; } } I configured in the struts.xml for my action class using below config. package name=*test* namespace=*/test* extends=*struts-default* * interceptors* *interceptor name=sample class=sample.**InterceptorSample* * /* * /interceptors* action name=*test* class=*test.QuizAction* interceptor-ref name=*sample*/ result name=*success*/input.*jsp*/result result name=*error*/input.*jsp*/result result name=*input*/input.*jsp*/result /action /package I noted nothing printed and anyone can help to resolve the issue. Thanks Yanto - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor issue in Struts 2.1.6
after we add validationWorkflowStack interceptor before the timer, then the timer interceptor will show the result, interceptor-ref name=validationWorkflowStack/ interceptor-ref name=timer/ if we use the above in the action it is printing the timer value like below [2009-06-16 18:03:41,218] INFO com.opensymphony.xwork2.interceptor.TimerInterceptor - Executed action [//authentication!authentication] took 93 ms. is this the configuration requirement of the interceptor in 2.1.6 ? Thanks Yanto 2009/6/16 Yanto yantob...@gmail.com Hi Pawel, thanks for the link we already check the interceptor for the namespace, and it's showing the interceptor yang we configure in the config-browser-plugin TimerInterceptor com.opensymphony.xwork2.interceptor.TimerInterceptor but, when we check from the Apache console, the interceptor is not in the console log for 2.1.6, when we run the same code in the 2.0.6 at the end of the apache log, it show the interceptor is envoked. Is there any additional configuration need to be setup to enable the interceptor in 2.1.6 ? beside the one we already setup as in previous email. Name Type ExceptionMappingInterceptor com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor AliasInterceptor com.opensymphony.xwork2.interceptor.AliasInterceptor ServletConfigInterceptor org.apache.struts2.interceptor.ServletConfigInterceptor I18nInterceptor com.opensymphony.xwork2.interceptor.I18nInterceptor PrepareInterceptor com.opensymphony.xwork2.interceptor.PrepareInterceptor ChainingInterceptor com.opensymphony.xwork2.interceptor.ChainingInterceptor DebuggingInterceptor org.apache.struts2.interceptor.debugging.DebuggingInterceptor ProfilingActivationInterceptor org.apache.struts2.interceptor.ProfilingActivationInterceptor ScopedModelDrivenInterceptor com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor ModelDrivenInterceptor com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor FileUploadInterceptor org.apache.struts2.interceptor.FileUploadInterceptor CheckboxInterceptor org.apache.struts2.interceptor.CheckboxInterceptor StaticParametersInterceptor com.opensymphony.xwork2.interceptor.StaticParametersInterceptor ActionMappingParametersInteceptor org.apache.struts2.interceptor.ActionMappingParametersInteceptor ParametersInterceptor com.opensymphony.xwork2.interceptor.ParametersInterceptor StrutsConversionErrorInterceptor org.apache.struts2.interceptor.StrutsConversionErrorInterceptor AnnotationValidationInterceptor org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor DefaultWorkflowInterceptor com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor TimerInterceptor com.opensymphony.xwork2.interceptor.TimerInterceptor Thanks Yanto 2009/6/16 Paweł Wielgus poulw...@gmail.com Hi Yanto, use this [1] plugin to verify if all namespaces and stacks are as You think they should be. [1] http://struts.apache.org/2.x/docs/config-browser-plugin.html Best greetings, Paweł Wielgus. 2009/6/16 Yanto yantob...@gmail.com: Hi, I am trying to use the following simple interceptor test the interceptor concepts but is not happened while calling the action class. Sample interceptor class. *import* *com.opensymphony.xwork2.ActionContext*; *import* com.opensymphony.xwork2.ActionInvocation; *import* com.opensymphony.xwork2.interceptor.AbstractInterceptor; *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor : calling the interceptor sample); *return* success; } } I configured in the struts.xml for my action class using below config. package name=*test* namespace=*/test* extends=*struts-default* * interceptors* *interceptor name=sample class=sample.**InterceptorSample* * /* * /interceptors* action name=*test* class=*test.QuizAction* interceptor-ref name=*sample*/ result name=*success*/input.*jsp*/result result name=*error*/input.*jsp*/result result name=*input*/input.*jsp*/result /action /package I noted nothing printed and anyone can help to resolve the issue. Thanks Yanto - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor issue in Struts 2.1.6
Yanto wrote: action name=test class=test.QuizAction interceptor-ref name=sample / /action This will configure *only* the sample interceptor. If you specify *any* interceptors on a per-action basis you must configure *all* interceptors. This can be done in several ways. - specify all interceptors in the action's configuration (you can specify interceptor stacks as well as single interceptors) - creating a new stack including your custom interceptor and using that stack in your action configuration - same, but define the new stack and using it as the default stack Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor issue in Struts 2.1.6
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, sounds like you mixed up interceptors and action classes. Look at *http://struts.apache.org/2.x/docs/interceptors.html *regards Volker Yanto schrieb: Hi, I am trying to use the following simple interceptor test the interceptor concepts but is not happened while calling the action class. Sample interceptor class. *import* *com.opensymphony.xwork2.ActionContext*; *import* com.opensymphony.xwork2.ActionInvocation; *import* com.opensymphony.xwork2.interceptor.AbstractInterceptor; *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor : calling the interceptor sample); *return* success; } } I configured in the struts.xml for my action class using below config. package name=*test* namespace=*/test* extends=*struts-default* * interceptors* *interceptor name=sample class=sample.**InterceptorSample* * /* * /interceptors* action name=*test* class=*test.QuizAction* interceptor-ref name=*sample*/ result name=*success*/input.*jsp*/result result name=*error*/input.*jsp*/result result name=*input*/input.*jsp*/result /action /package I noted nothing printed and anyone can help to resolve the issue. Thanks Yanto - -- - --- Volker Karlmeier Friedrich-Freye-Str. 61 45481 Mülheim/Ruhr Tel. : (+49) 208-7785675 Mobil: (+49) 176-21056587 Mail : vol...@magiccode.eu -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFKOCg7aEMQXBIqssERAgRaAKCbsdFrzAFxuk8Rva9B6XVPOy8jeACfQ2XS 53yea3su5lVImf1ZabY3JmE= =6PTg -END PGP SIGNATURE- - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor issue in Struts 2.1.6
Hi Dave, after following your note, we are able to run our sample interceptor, however now we have another issue the sample interceptor will always looping, since we have the following code in the sample interceptor, *return* invocation.invoke(); but the sample interceptor will not run, if we are not include this code. == interceptors interceptor name=*sample* class=* com.obs.ssts.framework.interceptor.InterceptorSample*/ interceptor-stack name=*MyInterceptorStack* interceptor-ref name=*prepare*/ interceptor-ref name=*modelDriven*/ interceptor-ref name=*exception*/ interceptor-ref name=*servletConfig*/ interceptor-ref name=*checkbox*/ interceptor-ref name=*params*/ ***interceptor-ref** name=**sample**/*** /interceptor-stack /interceptors default-interceptor-ref name=*MyInterceptorStack*/ action name=*authentication* method=*authentication* class=* loginAction* resultmain.*jsp*/result /action Now my action calls going in loop and after added the myinterceptostack *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor flow from TEST:); System.*out*.println(Testing the interceptor flow from TEST :); *return* invocation.invoke(); } } Thanks Yanto On Tue, Jun 16, 2009 at 7:32 PM, Dave Newton newton.d...@yahoo.com wrote: Yanto wrote: action name=test class=test.QuizAction interceptor-ref name=sample / /action This will configure *only* the sample interceptor. If you specify *any* interceptors on a per-action basis you must configure *all* interceptors. This can be done in several ways. - specify all interceptors in the action's configuration (you can specify interceptor stacks as well as single interceptors) - creating a new stack including your custom interceptor and using that stack in your action configuration - same, but define the new stack and using it as the default stack Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor issue in Struts 2.1.6
Hi Volker, thanks, we are able to run the interceptor now, but we have another issue, the interceptor will Loop, we create the sample follow the code from the webworks *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor flow from TEST:); System.*out*.println(Testing the interceptor flow from TEST :); *return* invocation.invoke(); } } Regards Yanto On Wed, Jun 17, 2009 at 7:18 AM, Volker Karlmeier vol...@magiccode.euwrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, sounds like you mixed up interceptors and action classes. Look at *http://struts.apache.org/2.x/docs/interceptors.html *regards Volker Yanto schrieb: Hi, I am trying to use the following simple interceptor test the interceptor concepts but is not happened while calling the action class. Sample interceptor class. *import* *com.opensymphony.xwork2.ActionContext*; *import* com.opensymphony.xwork2.ActionInvocation; *import* com.opensymphony.xwork2.interceptor.AbstractInterceptor; *public* *class* *InterceptorSample* *extends* AbstractInterceptor { @Override *public* String intercept(ActionInvocation invocation) *throws*Exception { // *TODO* Auto-generated method stub System.*out*.println(Testing the interceptor : calling the interceptor sample); *return* success; } } I configured in the struts.xml for my action class using below config. package name=*test* namespace=*/test* extends=*struts-default* * interceptors* *interceptor name=sample class=sample.**InterceptorSample* * /* * /interceptors* action name=*test* class=*test.QuizAction* interceptor-ref name=*sample*/ result name=*success*/input.*jsp*/result result name=*error*/input.*jsp*/result result name=*input*/input.*jsp*/result /action /package I noted nothing printed and anyone can help to resolve the issue. Thanks Yanto - -- - --- Volker Karlmeier Friedrich-Freye-Str. 61 45481 Mülheim/Ruhr Tel. : (+49) 208-7785675 Mobil: (+49) 176-21056587 Mail : vol...@magiccode.eu -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFKOCg7aEMQXBIqssERAgRaAKCbsdFrzAFxuk8Rva9B6XVPOy8jeACfQ2XS 53yea3su5lVImf1ZabY3JmE= =6PTg -END PGP SIGNATURE- - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Interceptor - Conditional Redirect to alternate action
I need to put an interceptor after the cookie interceptor that will send the user to a preference page if a preference cookie is missing rather than let the desired action fire--like a guard condition. If I was using a Filter I would just do a redirect. Eventually I will also add a Flash shared object as a back-up to the cookie, so I'll need to put a Flash shared object interceptor in the stack too. The redirector interceptor would check the cookie and flash token values put set by the previous interceptors in the stack. If both are missing, then a different action needs to fire. Where can I find an example of an interceptor that conditionally redirects the user to an alternate action? I'm having trouble picturing how the plumbing would work and I think an example of this kind would be a big help. Steve Mitchell http://www.ByteworksInc.com -- NOTICE: This electronic mail message and any attached files are confidential. The information is exclusively for the use of the individual or entity intended as the recipient. If you are not the intended recipient, any use, copying, printing, reviewing, retention, disclosure, distribution or forwarding of the message or any attached file is not authorized and is strictly prohibited. If you have received this electronic mail message in error, please advise the sender by reply electronic mail immediately and permanently delete the original transmission, any attachments and any copies of this message from your computer system. Thank you. == - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor - Conditional Redirect to alternate action
Could you use a global-result? http://struts.apache.org/2.x/docs/result-configuration.html#ResultConfiguration-GlobalResults I would just think up a unique name for the set of conditions that should cause the redirect. Then, configure that string as a global-result and write your interceptor to do the check and return the string if the conditions are met and action.invoke otherwise. -Wes On Mon, Jun 8, 2009 at 10:09 AM, Mitchell, Stevensteven.mitch...@umb.com wrote: I need to put an interceptor after the cookie interceptor that will send the user to a preference page if a preference cookie is missing rather than let the desired action fire--like a guard condition. If I was using a Filter I would just do a redirect. Eventually I will also add a Flash shared object as a back-up to the cookie, so I'll need to put a Flash shared object interceptor in the stack too. The redirector interceptor would check the cookie and flash token values put set by the previous interceptors in the stack. If both are missing, then a different action needs to fire. Where can I find an example of an interceptor that conditionally redirects the user to an alternate action? I'm having trouble picturing how the plumbing would work and I think an example of this kind would be a big help. Steve Mitchell http://www.ByteworksInc.com -- NOTICE: This electronic mail message and any attached files are confidential. The information is exclusively for the use of the individual or entity intended as the recipient. If you are not the intended recipient, any use, copying, printing, reviewing, retention, disclosure, distribution or forwarding of the message or any attached file is not authorized and is strictly prohibited. If you have received this electronic mail message in error, please advise the sender by reply electronic mail immediately and permanently delete the original transmission, any attachments and any copies of this message from your computer system. Thank you. == - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Interceptor - Conditional Redirect to alternate action
Oh, wow, that's incredibly simple. I was making it too complicated in my mind, thinking I needed to tell the ActionInvocation class not to allow the original action to fire. I see now that the answer was right there in the API [Interceptor.intercept()] - Allows the Interceptor to... short-circuit the processing and just return a String return code. -Original Message- From: Wes Wannemacher [mailto:w...@wantii.com] Sent: Monday, June 08, 2009 9:14 AM To: Struts Users Mailing List Subject: Re: Interceptor - Conditional Redirect to alternate action Could you use a global-result? http://struts.apache.org/2.x/docs/result-configuration.html#ResultConfiguration-GlobalResults I would just think up a unique name for the set of conditions that should cause the redirect. Then, configure that string as a global-result and write your interceptor to do the check and return the string if the conditions are met and action.invoke otherwise. -Wes On Mon, Jun 8, 2009 at 10:09 AM, Mitchell, Stevensteven.mitch...@umb.com wrote: I need to put an interceptor after the cookie interceptor that will send the user to a preference page if a preference cookie is missing rather than let the desired action fire--like a guard condition. If I was using a Filter I would just do a redirect. Eventually I will also add a Flash shared object as a back-up to the cookie, so I'll need to put a Flash shared object interceptor in the stack too. The redirector interceptor would check the cookie and flash token values put set by the previous interceptors in the stack. If both are missing, then a different action needs to fire. Where can I find an example of an interceptor that conditionally redirects the user to an alternate action? I'm having trouble picturing how the plumbing would work and I think an example of this kind would be a big help. Steve Mitchell http://www.ByteworksInc.com -- NOTICE: This electronic mail message and any attached files are confidential. The information is exclusively for the use of the individual or entity intended as the recipient. If you are not the intended recipient, any use, copying, printing, reviewing, retention, disclosure, distribution or forwarding of the message or any attached file is not authorized and is strictly prohibited. If you have received this electronic mail message in error, please advise the sender by reply electronic mail immediately and permanently delete the original transmission, any attachments and any copies of this message from your computer system. Thank you. == - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - 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
Interceptor (Thread Safety)
If two copies of the same action is run at the same time parallelly (by ajax, iframe, etc.) in the same session, possibly with different parameters, do these actions call the same instance of an interceptor's intercept() method? If this is the case, how to avoid problems that can arise? For example, there is an intercept method like public String intercept(ActionInvocation actionInvocation) throws Exception { .Do some pre work String result = actionInvocation.invoke(); .Do some after work return result; } when the first copy of action is run, it does the pre work, then invoke() is called, at this time action2 is run so it runs pre work, calls it's invoke() then while doing after work, first action returns from invoke() thus changing the value of result variable. So the result is now first action's result and both actions return to the result from the first action, right? is defining the intercept method as synchronized a solution? thanks for the help. -- View this message in context: http://www.nabble.com/Interceptor-%28Thread-Safety%29-tp23836386p23836386.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
Re: Interceptor (Thread Safety)
ZeckoN wrote: public String intercept(ActionInvocation actionInvocation) throws Exception { .Do some pre work String result = actionInvocation.invoke(); .Do some after work return result; } Local variables aren't shared across method invocations. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor (Thread Safety)
On Tue, Jun 2, 2009 at 12:45 PM, ZeckoN zec...@gmail.com wrote: If two copies of the same action is run at the same time parallelly (by ajax, iframe, etc.) in the same session, possibly with different parameters, do these actions call the same instance of an interceptor's intercept() method? If this is the case, how to avoid problems that can arise? For example, there is an intercept method like public String intercept(ActionInvocation actionInvocation) throws Exception { .Do some pre work String result = actionInvocation.invoke(); .Do some after work return result; } when the first copy of action is run, it does the pre work, then invoke() is called, at this time action2 is run so it runs pre work, calls it's invoke() then while doing after work, first action returns from invoke() thus changing the value of result variable. So the result is now first action's result and both actions return to the result from the first action, right? is defining the intercept method as synchronized a solution? thanks for the help. String result = actionInvocation.invoke() ; This is thread-safe, another thread will invoke the intercept method, but the result string is scoped. I think you might be misunderstanding how threading works. If your pre-work and post-work only deal with variables locally scoped within the method, then I don't think there is a problem. Here is an example of a problem - public class MyInterceptor extends whatever { public String classScopedResultString; public String intercept(ActionInvocation actionInvocation) throws Exception { classScopedResultString = gettingReadyToInvoke; classScopedResultString = actionInvocation.invoke(); classScopedResultString = justGotDoneInvoking; return classScopedResultString; } } -Wes -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How to setup Interceptor when using struts2.1.6 rest plugin with convention
xnpeng, I think you are missing the point, packages have interceptor and interceptor stack definitions. Actions live inside of packages. What you need to do is move your conventions actions into your package. The interceptor ref annotation will point to the stacks you want, but it does no good if those interceptors are not defined in the package where those actions live. To have your actions use your package, change the configuration from - constant name=struts.convention.default.parent.package value=rest-default/ to - constant name=struts.convention.default.parent.package value=admin/ Then, conventions will put the actions in your package. Once this is done, since you have a default-interceptor-ref in your package, the interceptor ref annotations will no longer even be necessary. -Wes 2009/5/27 xnpeng xnp...@163.com: Hi, can some one help me? when i add annotation to my action,tomcat failed start. @InterceptorRefs({...@interceptorref(user), @InterceptorRef(defaultStack)}) public class MainController extends MainAction {...} Caused by: Unable to find interceptor class referenced by ref-name user - [unknown location] at com.opensymphony.xwork2.config.providers.InterceptorBuilder.constructInterceptorReference(InterceptorBuilder.java: at org.apache.struts2.convention.DefaultInterceptorMapBuilder.buildInterceptorList(DefaultInterceptorMapBuilder.java: at org.apache.struts2.convention.DefaultInterceptorMapBuilder.build(DefaultInterceptorMapBuilder.java:90) at org.apache.struts2.convention.DefaultInterceptorMapBuilder.build(DefaultInterceptorMapBuilder.java:63) at org.apache.struts2.convention.PackageBasedActionConfigBuilder.createActionConfig(PackageBasedActionConfigBuilder.j at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildConfiguration(PackageBasedActionConfigBuilder.j at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.j at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:52) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:200) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55) -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts2 Interceptor
Hi all, can an interceptor call an arbitraty action different from the action requested by the client? Suppose i've the interceptor interceptor-router placed in the stack and the client call MyAction.action, when the interceptor intercept the call is possible to 'redirect' the call to MyDifferentAction.action from the interceptor? I've seen that there is action chaining but this require to know at build time the name of the actions i want to redirect to, but i know the name only at runtime and I hope i was clear :) sorry for my english. -- Stefano Corallo
Re: Struts2 Interceptor
Sort of. The way that I've achieved something similar to what you seem to be asking is to define a bunch of Global Results in struts.xml that define common actions that the interceptors may need to invoke (like reset-password or invalid-input), then instead of chaining to the action in the interceptor, just return the name of the global result and you've effectively called that action. (*Chris*) On Tue, May 26, 2009 at 11:53 PM, Stefano Corallo stefan...@gmail.comwrote: Hi all, can an interceptor call an arbitraty action different from the action requested by the client? Suppose i've the interceptor interceptor-router placed in the stack and the client call MyAction.action, when the interceptor intercept the call is possible to 'redirect' the call to MyDifferentAction.action from the interceptor? I've seen that there is action chaining but this require to know at build time the name of the actions i want to redirect to, but i know the name only at runtime and I hope i was clear :) sorry for my english. -- Stefano Corallo
RE: Struts2 Interceptor
Hello David and Chris, Thank you two very much indeed for your help. I have tried s:set tag with different scope and seems I can set a parameter to any value I want, but I cant set it to the value/variable from jsps java code block, so I suppose s:set may not be applicable to my requirement. (or I must done something wrong somewhere!? Sorry I might not have presented the use case clearly in the first place) Ill check the JSTL approach later I suppose I should use its set tag (to a page scoped attribte?). Cheers, Qunhuan ~ Hi, Sorry for my ignorance but could some one tell me how to access java code block's variable in jsp page. See the sample code below (say, from test.jsp) ... % boolean goAhead = true; int counter = 0; ... % s:if test=goAhead ... !-- go a head and do something -- /s:if s:if test=counter0 ... !-- go a head and do something -- /s:if ... The reference of goAhead and counter within Struts' if tag is wrong. What should be the correct way to reference variable from java code block in this scenario? Many thanks in advance, Qunhuan - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 Interceptor
Hi Criss, thanks for your reply. I know the global result, but is unusefull for this purpose. The problem is that the actions that i want to call is knew at runtime cause the interceptor at init time scan classes with certain annotations and i want to forward to those actions so i can't put the result in struts.xml because i can't know what action to call. So my question is: the only way for an action to redirect to another action is via redirect-action-result ? like described in: http://struts.apache.org/2.x/docs/redirect-action-result.html Maybe putting in the annotation the information to call the action i want -- Stefano Corallo On Wed, May 27, 2009 at 9:07 AM, Chris Pratt thechrispr...@gmail.comwrote: Sort of. The way that I've achieved something similar to what you seem to be asking is to define a bunch of Global Results in struts.xml that define common actions that the interceptors may need to invoke (like reset-password or invalid-input), then instead of chaining to the action in the interceptor, just return the name of the global result and you've effectively called that action. (*Chris*) On Tue, May 26, 2009 at 11:53 PM, Stefano Corallo stefan...@gmail.com wrote: Hi all, can an interceptor call an arbitraty action different from the action requested by the client? Suppose i've the interceptor interceptor-router placed in the stack and the client call MyAction.action, when the interceptor intercept the call is possible to 'redirect' the call to MyDifferentAction.action from the interceptor? I've seen that there is action chaining but this require to know at build time the name of the actions i want to redirect to, but i know the name only at runtime and I hope i was clear :) sorry for my english. -- Stefano Corallo
RE: Struts2 Interceptor
Hi Stefano, This looks like an awkward design as you would go through half the interceptor stack expecting to call one action, and half the stack expecting to call a second action. As an alternative could you do something like the following:- Create class (or Interface) ReceivingAction with sub classes as the actions you want to assign dynamically. Create a true action class ForwardingAction with a property ReceivingAction. The interceptor can now dynamically create the class required (derived from / implementing ReceivingAction) and set it on the current action (ForwardingAction). It could also place the ReceivingAction instance on the ValueStack. The main action methods you are interested in (e.g. execute) could simply forward to the ReceivingAction instance. You will need to be careful about interceptor order if you want to do things like set your parameter values on your ReceivingAction. I haven't implemented this myself, although I have implemented all the techniques I have described. I'm fairly confident that this will achieve what you want. Cheers, Steve -Original Message- From: Stefano Corallo [mailto:stefan...@gmail.com] Sent: 27 May 2009 07:54 To: user@struts.apache.org Subject: Struts2 Interceptor Hi all, can an interceptor call an arbitraty action different from the action requested by the client? Suppose i've the interceptor interceptor-router placed in the stack and the client call MyAction.action, when the interceptor intercept the call is possible to 'redirect' the call to MyDifferentAction.action from the interceptor? I've seen that there is action chaining but this require to know at build time the name of the actions i want to redirect to, but i know the name only at runtime and I hope i was clear :) sorry for my english. -- Stefano Corallo - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Struts2 Interceptor
you might possibly be breaking the one action class design of Struts is there anything in the 2nd Action class which will not be accomodated by the first class? right now its simple to look at the interceptor stack and determine which class is being called in what order..although technically possible to create any other class (Spring accomplishes this DI functionality thru Spring configured Factories) you would need a reason to justify a change in flow: Specifically: 1a)Which updated/new attributes would the new Action class contain? 1b)Can we not accomodate the new Action attributes in the original Action Class? 2a)Which updated/new methods would the new Action class contain? 2b)Can we not accomodate these new Action methods in the original Action Class? 3a)Which context (element and attribute) params would be introduced by the new class? 3b)Can we not accomodate these new Context Params in the original Action Context? What happens when this new class abends..how do you debug? (my concern is obfuscation of flow or process can lead to confusion in implementation) What say ye Musachy? Martin __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. From: st...@sjlt.co.uk To: user@struts.apache.org Subject: RE: Struts2 Interceptor Date: Wed, 27 May 2009 10:47:42 +0100 Hi Stefano, This looks like an awkward design as you would go through half the interceptor stack expecting to call one action, and half the stack expecting to call a second action. As an alternative could you do something like the following:- Create class (or Interface) ReceivingAction with sub classes as the actions you want to assign dynamically. Create a true action class ForwardingAction with a property ReceivingAction. The interceptor can now dynamically create the class required (derived from / implementing ReceivingAction) and set it on the current action (ForwardingAction). It could also place the ReceivingAction instance on the ValueStack. The main action methods you are interested in (e.g. execute) could simply forward to the ReceivingAction instance. You will need to be careful about interceptor order if you want to do things like set your parameter values on your ReceivingAction. I haven't implemented this myself, although I have implemented all the techniques I have described. I'm fairly confident that this will achieve what you want. Cheers, Steve -Original Message- From: Stefano Corallo [mailto:stefan...@gmail.com] Sent: 27 May 2009 07:54 To: user@struts.apache.org Subject: Struts2 Interceptor Hi all, can an interceptor call an arbitraty action different from the action requested by the client? Suppose i've the interceptor interceptor-router placed in the stack and the client call MyAction.action, when the interceptor intercept the call is possible to 'redirect' the call to MyDifferentAction.action from the interceptor? I've seen that there is action chaining but this require to know at build time the name of the actions i want to redirect to, but i know the name only at runtime and I hope i was clear :) sorry for my english. -- Stefano Corallo - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ Hotmail® goes with you. http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009
Interceptor Trouble
So, I've edited the struts.xml appropriately and I've created an Interceptor that implements the interceptor interface. Init() is called on startup but I can't get it to call intercept() to save my life. My objective is to create an interceptor that checks to see if a session variable is set and if not then take some action (either set it or send the user to a page that sets it). Here is the interceptor: public class UidInterceptor implements Interceptor { private static final Logger LOG = LoggerFactory.getLogger(sigacts); public void destroy() { LOG.debug(jim May 27, 2009 : destroy called); } public void init() { LOG.debug(jim May 27, 2009 : init called ); } public String intercept(ActionInvocation invocation) throws Exception { LOG.debug(jim May 27, 2009 : intercept called); return invocation.invoke(); } } Here is the relevant portion of the xml: package name=xxx extends=struts-default interceptors interceptor name=UidIntercept class=com.eds.xxx.web.admin.UidInterceptor/ interceptor-stack name=CustomStack interceptor-ref name=paramsPrepareParamsStack/ interceptor-ref name=UidIntercept/ /interceptor-stack /interceptors default-interceptor-ref name=CustomStack/ /package Clues anyone? I can see the init() being called in the logs but I never see intercept. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 Interceptor
Stefano Corallo wrote: I know the global result, but is unusefull for this purpose. The problem is that the actions that i want to call is knew at runtime cause the interceptor at init time scan classes with certain annotations and i want to forward to those actions so i can't put the result in struts.xml because i can't know what action to call. If you make the global result shortCircuitRedirect redirect to %{shortCircuitRedirectUrl}, add that member and getter to your BaseAction class, and have your interceptor both set the Url on the action, then return the global result name, you'll be able to do what you ask. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 Interceptor
Hi Dale, i think that this is the only one solution. Thanks guys for your reply. -- Stefano Corallo On Wed, May 27, 2009 at 4:59 PM, Dale Newfield d...@newfield.org wrote: Stefano Corallo wrote: I know the global result, but is unusefull for this purpose. The problem is that the actions that i want to call is knew at runtime cause the interceptor at init time scan classes with certain annotations and i want to forward to those actions so i can't put the result in struts.xml because i can't know what action to call. If you make the global result shortCircuitRedirect redirect to %{shortCircuitRedirectUrl}, add that member and getter to your BaseAction class, and have your interceptor both set the Url on the action, then return the global result name, you'll be able to do what you ask. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 Interceptor
Stefano Corallo wrote: i think that this is the only one solution. Thanks guys for your reply. If you don't have a base class for all of your actions, you might be able in the interceptor to get ahold of the ognl valueStack and set the value directly, then refer to #shortCircuitRedirectUrl (in the ognl dictionary rather than an attribute on action (top of ValueStack)). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 Interceptor
Yes i know that, very appreciate this clarification :) -- Stefano Corallo On Wed, May 27, 2009 at 5:25 PM, Dale Newfield d...@newfield.org wrote: Stefano Corallo wrote: i think that this is the only one solution. Thanks guys for your reply. If you don't have a base class for all of your actions, you might be able in the interceptor to get ahold of the ognl valueStack and set the value directly, then refer to #shortCircuitRedirectUrl (in the ognl dictionary rather than an attribute on action (top of ValueStack)). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 Interceptor
Yes, you can, though I don't really thing it's the right way to go. Basically you use the body content of the s:set tag to set the variable to the value of a scriplet expression like so: s:set value=fred%= myVar%/s:set Again, there are much better ways of coding modern web applications that resorting to scriplets and I would certainly take the time to eradicate all scriplets from your code as soon as you can, you will be happy you did. (*Chris*) On Wed, May 27, 2009 at 1:01 AM, Qunhuan Mei q...@qm18.wanadoo.co.uk wrote: Hello David and Chris, Thank you two very much indeed for your help. I have tried s:set tag with different scope and seems I can set a parameter to any value I want, but I can’t set it to the value/variable from jsp’s java code block, so I suppose s:set may not be applicable to my requirement. (or I must done something wrong somewhere!? Sorry I might not have presented the use case clearly in the first place) I’ll check the JSTL approach later – I suppose I should use its set tag (to a page scoped attribte?). Cheers, Qunhuan ~ Hi, Sorry for my ignorance but could some one tell me how to access java code block's variable in jsp page. See the sample code below (say, from test.jsp) ... % boolean goAhead = true; int counter = 0; ... % s:if test=goAhead ... !-- go a head and do something -- /s:if s:if test=counter0 ... !-- go a head and do something -- /s:if ... The reference of goAhead and counter within Struts' if tag is wrong. What should be the correct way to reference variable from java code block in this scenario? Many thanks in advance, Qunhuan - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2 Interceptor
You can still use the Global Result, just set the global results value to an OGNL expression. This limits the places you can use the interceptor to actions that can fill the OGNL expression, but you could handle that with a common base class if you really want to go down this path. I don't think you really want to just call another Action (which is totally doable, but it won't have any of it's data since it's interceptor stack won't have been run). Basically what you want is a method on your common base class like: method getNextAction () { return next; } And a global result like: result name=gtfo type=redirect-action${nextAction}/result I think you would be better off sticking to the tried and true patterns that the Struts team has designed the system to work with, but if you must, this should work. (*Chris*) On Wed, May 27, 2009 at 2:17 AM, Stefano Corallo stefan...@gmail.comwrote: Hi Criss, thanks for your reply. I know the global result, but is unusefull for this purpose. The problem is that the actions that i want to call is knew at runtime cause the interceptor at init time scan classes with certain annotations and i want to forward to those actions so i can't put the result in struts.xml because i can't know what action to call. So my question is: the only way for an action to redirect to another action is via redirect-action-result ? like described in: http://struts.apache.org/2.x/docs/redirect-action-result.html Maybe putting in the annotation the information to call the action i want -- Stefano Corallo On Wed, May 27, 2009 at 9:07 AM, Chris Pratt thechrispr...@gmail.com wrote: Sort of. The way that I've achieved something similar to what you seem to be asking is to define a bunch of Global Results in struts.xml that define common actions that the interceptors may need to invoke (like reset-password or invalid-input), then instead of chaining to the action in the interceptor, just return the name of the global result and you've effectively called that action. (*Chris*) On Tue, May 26, 2009 at 11:53 PM, Stefano Corallo stefan...@gmail.com wrote: Hi all, can an interceptor call an arbitraty action different from the action requested by the client? Suppose i've the interceptor interceptor-router placed in the stack and the client call MyAction.action, when the interceptor intercept the call is possible to 'redirect' the call to MyDifferentAction.action from the interceptor? I've seen that there is action chaining but this require to know at build time the name of the actions i want to redirect to, but i know the name only at runtime and I hope i was clear :) sorry for my english. -- Stefano Corallo
RE: Struts2 Interceptor
hello dale- in my xwork discoveries i came upon the ShortCircuitableValidator defined as /** Copyright (c) 2002-2006 by OpenSymphony All rights reserved.*/ package com.opensymphony.xwork.validator; /** * This interface should be implemented by validators that can short-circuit the validator queue that it is in @author Mark Woon */ public interface ShortCircuitableValidator { /*** Sets whether this field validator should short circuit the validator queue * it's in if validation fails * @param shortcircuit true if this field validator should short circuit on * failure, false otherwise */ public void setShortCircuit(boolean shortcircuit); /*** Gets whether this field validator should short circuit the validator queue * it's in if validation fails. * @return true if this field validator should short circuit on failure, * false otherwise*/ public boolean isShortCircuit(); } //action class not implements ShortCircuitableValidator public class MyAction extends ActionSupport implements ShortCircuitableValidator { OgnlValueStack vs = new OgnlValueStack(); String isBogus =(isShortCircuit()==true)?true:false; try { vs.setValue(shortCircuitRedirectUrl, isBogus, 1); } catch (OgnlException e) { log.debug(OgnlException happened here+e.getMessage()); } } would this work for shortCircuitRedirectUrl ? Martin Gainty __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Wed, 27 May 2009 11:25:47 -0400 From: d...@newfield.org To: user@struts.apache.org Subject: Re: Struts2 Interceptor Stefano Corallo wrote: i think that this is the only one solution. Thanks guys for your reply. If you don't have a base class for all of your actions, you might be able in the interceptor to get ahold of the ognl valueStack and set the value directly, then refer to #shortCircuitRedirectUrl (in the ognl dictionary rather than an attribute on action (top of ValueStack)). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ Insert movie times and more without leaving Hotmail®. http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd1_052009