struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dale Newfield <d...@newfield.org>
Subject Re: using CompositeActionMapper
Date Thu, 02 Jul 2009 18:08:27 GMT
rsilva wrote:
> I dont not understand very much about Struts2 inject process but I fixed my
> problem extending the compositeActionMapper with the following one:
> 
> public class DebugCompositeActionMapper extends CompositeActionMapper {
> 
>     @Override
>     @Inject(StrutsConstants.STRUTS_MAPPER_COMPOSITE)
>     public void setActionMappers(String list) {
>         if (list != null) {
>             String[] arr = list.split(",");
>             for (String name : arr) {
>                 if (container==null) continue; // LINE ADDED
>                 Object obj = container.getInstance(ActionMapper.class,
> name);
>                 if (obj != null) {
>                     actionMappers.add((ActionMapper) obj);
>                 }
>             }
>         }
>     }
> }
> 
> I worked since it do not throw the Null Pointer Exception and it seem during
> injection process the function setActionMappers is called twice. One before
> the container is set and other after.

Do the call stacks during those two calls reveal anything useful about 
how/why it's getting called twice (once before it sounds like it should)?

If container is null during one of those calls, won't it be null during 
the entire method call?  If so, why not put
"if (container == null) return;" as the first line of the method instead 
of re-checking it for each potential mapper specification?

-Dale

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


Mime
View raw message