• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stripes: how to set interceptor only for a group of actions?

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to write an interceptor that checked id user is logged, or not. But i need this to work only for a group of Actions (CMS). I don't need it to intercept for frontend. Is it possible?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An interceptor will intercept all requests for a given set of LifecyclePhases. There is nothing that you can tag the interceptor with to specify which actions. However, you can, in your interceptor, determine which Actions are acted upon. So the interceptor will execute every time, but you decide which actions matter.

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used something like the following to constrain an interceptor to particular actions.


It's also possible to restrict intercepts to particular methods using the Before and After annotations, either positively:@Before(on="save") or negatively: @Before(on="!save").
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In addition to what Ulf said, seeing as how you could have a huge amount of Actions to test against, you could use the servlet path:

String servletPath = executionContext.getActionBeanContext().getRequest().getServletPath();

This means all your "front-end" actions would reside in a specific path and your secure actions in a different path

http://yourserver.com/public/action
http://yourserver.com/protected/action
 
Vadim Vararu
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much guys! I guess last variant will be more suitable for my case cause my actions paths differs in ..../frontend/... and .../backend/...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic