On 9/16/05, Stas Ostapenko <[EMAIL PROTECTED]> wrote:
> 
> Hi !
> I'm trying to resolve how to use servlet as a view with Struts. It's
> very diffcult to find how to do it. I have asked at struts user
> mailing list but nobody answered.


Under the covers, Struts is just doing a RequestDispatcher.forward() call 
when your Action returns an appropriate ActionForward. Therefore, you need 
to ensure that the URL defined in that <forward> element corresponds to a 
context relative path that is mapped (in web.xml) to your alternate view 
handling servlet. The Velocity integration referenced by Joe does exactly 
this.

How to get ActionMessages and form bean objects when simple sevlet is
> used as a view ? How to get particular error message string for global 
> message ?
> Plese help.


The answers are different for each of the things you're asking about:

* *IF* you create the form bean ahead of time, it will be passed as a 
request or session
scope object with a key equal to the form bean name. If you're using the 
standard
view technology, the <html:form> tag will create this bean if it doesn't 
exist -- your
alternate view technology will likely need to have that same functionality.

* The ActionMessages instance is passed as a request scope attribute
whose key is defined by the manifest constant Globals.MESSAGE_KEY.

* Localized text for the actual messages is looked up (in the standard view
techology) in the applicaton resource bundle(s), which are defined in your
struts-config.xml. You can see how that's done by looking at the source code
for the <html:errors> tag, and emulate the same behavior.

Regards, Stas.


Craig

Reply via email to