DMF and ExecutionContext.getCurrentContext()

View: New views
2 Messages — Rating Filter:   Alert me  

DMF and ExecutionContext.getCurrentContext()

by VANKEISBELCK Remi-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi folks,

I'm using DMF with a custom ActionResolver.
In MyActionResolver.getActionBeanType(String path), I need to access
ExecutionContext.getCurrentContext(), unfortunately it returns null.

The code in MyActionResolver goes like :

  public Class<? extends ActionBean> getActionBeanType(String path) {
    ActionBeanContext ctx =
ExecutionContext.currentContext().getActionBeanContext(); // throws
NPE
    try {
      ActionBean bean = getActionBean(ctx, path);
      if (bean!=null) {
        return bean.getClass();
      }
      return null;
    } catch (StripesServletException e) {
      return null;
    }
  }

As you see, it simply delegates to getActionBean(actionBeanContext,
path), so I use ExecutionContext.getCurrentContext() in order to
retrieve the current ActionBeanContext. I need to get the bean
context, as my action resolver is fully dynamic (action beans are not
known at startup time)... but I have this NPE.

I've investigated a bit, and I could see that the DMF calls
actionResolver before invoking the dispatcher, which is the one which
initializes the context :/

Using regular StripesFilter/Dispatcher web.xml config (without DMF),
or with MockRoundtrip, it works smoothly...

I'm kinda stuck, I don't want to hardcode those url mappings in web.xml... :/
Is there any way to get around this ?

Thanks in advance for any advice...

Cheers

Remi

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Stripes-development mailing list
Stripes-development@...
https://lists.sourceforge.net/lists/listinfo/stripes-development

Re: DMF and ExecutionContext.getCurrentContext()

by VANKEISBELCK Remi-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I was thinking, I only need the HttpServletRequest to get the job done
in my ActionResolver, not the full ActionBeanContext...

Is there any way to do this, that would not rely on
ExecutionContext.getCurrentContext(), and thereby that would work with
DMF smoothly ?

Thanks

Cheers

Remi

2009/11/4 VANKEISBELCK Remi <remi@...>:

> Hi folks,
>
> I'm using DMF with a custom ActionResolver.
> In MyActionResolver.getActionBeanType(String path), I need to access
> ExecutionContext.getCurrentContext(), unfortunately it returns null.
>
> The code in MyActionResolver goes like :
>
>  public Class<? extends ActionBean> getActionBeanType(String path) {
>    ActionBeanContext ctx =
> ExecutionContext.currentContext().getActionBeanContext(); // throws
> NPE
>    try {
>      ActionBean bean = getActionBean(ctx, path);
>      if (bean!=null) {
>        return bean.getClass();
>      }
>      return null;
>    } catch (StripesServletException e) {
>      return null;
>    }
>  }
>
> As you see, it simply delegates to getActionBean(actionBeanContext,
> path), so I use ExecutionContext.getCurrentContext() in order to
> retrieve the current ActionBeanContext. I need to get the bean
> context, as my action resolver is fully dynamic (action beans are not
> known at startup time)... but I have this NPE.
>
> I've investigated a bit, and I could see that the DMF calls
> actionResolver before invoking the dispatcher, which is the one which
> initializes the context :/
>
> Using regular StripesFilter/Dispatcher web.xml config (without DMF),
> or with MockRoundtrip, it works smoothly...
>
> I'm kinda stuck, I don't want to hardcode those url mappings in web.xml... :/
> Is there any way to get around this ?
>
> Thanks in advance for any advice...
>
> Cheers
>
> Remi
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Stripes-development mailing list
Stripes-development@...
https://lists.sourceforge.net/lists/listinfo/stripes-development