You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by adam kramer <ad...@monkey.org> on 2003/07/19 19:06:27 UTC

RequestUtils.retrieveMessageResources requires MVC w/taglibs

  I (re)installed the validator webapp and got the error at index.jsp:
java.lang.NullPointerException
	at org.apache.struts.util.RequestUtils.retrieveMessageResources(RequestUtils.java:1090)
	at org.apache.struts.util.RequestUtils.message(RequestUtils.java:1038)
	at org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:269)

 Looking into this, it seems that any taglib class that calls
RequestUtils.message() without the request going through the ActionServlet
first will get this error (thats about 8 taglib classes). It is the
ActionServlet that calls RequestUtils.selectModule that stores the current
ModuleConfig in the request scope. If a page is accessed directly this
will not be set, and a call to retrieveMEssageResources will get the NPE
exception (in most cases).

 some possible solutions:
1) require MVC approach with use of taglibs. this seems to go against
"Struts encourages application architectures based on the Model 2
approach, a variation of the classic Model-View-Controller (MVC) design
paradigm." from the home page. In this case, I could modify the validator
webapp to fit this paradigm, and another others deemed necessary to
modify.

2) insert a RequestUtils.selectModule in each taglib class calling
message(). This creates the overhead of calling selectModule in each call
to a taglib, but this might be minimal since taglib classes generally call
atleast once to another comparable RequestUtils method. If this was deemed
acceptable, I could do this easily as I have already written the code for
this in once taglib class.

???

-Adam K.


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