Interceptor Trouble

2009-05-27 Thread Jim Collings
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: Interceptor Trouble

2009-05-27 Thread Wes Wannemacher
On Wed, May 27, 2009 at 8:18 AM, Jim Collings jlistn...@gmail.com wrote:
[snip]

 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.


Do you have any actions in that package? Your interceptor should be
run, but only against actions in that package (xxx). Also, your
interceptor is last in your stack, so things like validation failure
can keep it from firing.

-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: Interceptor Trouble

2009-05-27 Thread Martin Gainty


can we see the code for com.eds.xxx.web.admin.UidInterceptor
?

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.




 Date: Wed, 27 May 2009 12:47:48 -0400
 Subject: Re: Interceptor Trouble
 From: w...@wantii.com
 To: user@struts.apache.org
 
 On Wed, May 27, 2009 at 8:18 AM, Jim Collings jlistn...@gmail.com wrote:
 [snip]
 
  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.
 
 
 Do you have any actions in that package? Your interceptor should be
 run, but only against actions in that package (xxx). Also, your
 interceptor is last in your stack, so things like validation failure
 can keep it from firing.
 
 -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
 

_
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd1_052009

Re: Interceptor Trouble

2009-05-27 Thread Jim Collings
 Do you have any actions in that package? Your interceptor should be
 run, but only against actions in that package (xxx). Also, your
 interceptor is last in your stack, so things like validation failure
 can keep it from firing.

 -Wes

Yes. Tried putting it in the Actions package. No dice. No validation as yet.
I've since implemented this as a filter.


Jim C.

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



Re: Interceptor Trouble

2009-05-27 Thread Wes Wannemacher
Wait, wait... Actions package? Are you using codebehind or
conventions? If so, then the struts.xml file you posted won't be
enough. You have to either change the default convention package or
you have to use InterceptorRef annotations on your action. By default,
the conventions plugin uses something like conventions-default as the
default package for all of your actions. Just because you map a
package in struts.xml does not mean that the actions will
automatically be in that package because their namespace matches (I
think, I could be wrong, maybe it is supposed to, I dunno). But, there
are annotations for applying an interceptor stack to the action.

-Wes

On Wed, May 27, 2009 at 3:13 PM, Jim Collings jlistn...@gmail.com wrote:
 Do you have any actions in that package? Your interceptor should be
 run, but only against actions in that package (xxx). Also, your
 interceptor is last in your stack, so things like validation failure
 can keep it from firing.

 -Wes

 Yes. Tried putting it in the Actions package. No dice. No validation as yet.
 I've since implemented this as a filter.


 Jim C.

 -
 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 Trouble

2009-05-27 Thread Jim Collings
On Wed, May 27, 2009 at 3:17 PM, Wes Wannemacher w...@wantii.com wrote:
 Wait, wait... Actions package? Are you using codebehind or
 conventions? If so, then the struts.xml file you posted won't be
 enough. You have to either change the default convention package or
 you have to use InterceptorRef annotations on your action. By default,
 the conventions plugin uses something like conventions-default as the
 default package for all of your actions. Just because you map a
 package in struts.xml does not mean that the actions will
 automatically be in that package because their namespace matches (I
 think, I could be wrong, maybe it is supposed to, I dunno). But, there
 are annotations for applying an interceptor stack to the action.
...
 Yes. Tried putting it in the Actions package. No dice. No validation as yet.
 I've since implemented this as a filter.

Conventions. Hmmm.. Perhaps better implemented as a filter then. I'ld
prefer it to having to annotate every single Action class.


Jim C.

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



Re: Interceptor Trouble

2009-05-27 Thread Wes Wannemacher
On Wed, May 27, 2009 at 3:24 PM, Jim Collings jlistn...@gmail.com wrote:

 Conventions. Hmmm.. Perhaps better implemented as a filter then. I'ld
 prefer it to having to annotate every single Action class.


 Jim C.



You don't need to annotate every class, but you will need to change
the package the conventions assigns by default -

constant name=struts.convention.default.parent.package
value=yourPackageNameWhichIForgot/

-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: Interceptor Trouble

2009-05-27 Thread musomesa
Jim, since it is the interceptor you are interested in testing why not
test it without the Convention Plug-in (configuring the action by
xml) to see if it is working, which is your aim. That way you don't
have two things you are unsure of happening at once.
Cheers
Chris








-Original Message-
From: Wes Wannemacher w...@wantii.com
To: Struts Users Mailing List user@struts.apache.org
Sent: Wed, 27 May 2009 3:29 pm
Subject: Re: Interceptor Trouble



On Wed, May 27, 2009 at 3:24 PM, Jim Collings jlistn...@gmail.com wrote:

 Conventions. Hmmm.. Perhaps better implemented as a filter then. I'ld
 prefer it to having to annotate every single Action class.


 Jim C.



You don't need to annotate every class, but you will need to change
the package the conventions assigns by default -

constant name=struts.convention.default.parent.package
value=yourPackageNameWhichIForgot/

-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