You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Villalba Arias, Fredy [BILBOMATICA]" <fv...@mailext.com> on 2004/02/03 18:30:50 UTC
Pajes + Struts (REPOSTED and FORMATTED)
Hi to y’all,
I’m trying to integrate Pajes (www.pajes.org), a Servlet Presentation
Framework, with Struts. The idea is to use Struts’ MVC separation (Action,
ActionForms, ActionServlet, etc…) WITHOUT using Struts’ presentation tools
(i.e. no JSP, ergo no JSP Tags), just plain XHTML templates (in conjunction
with the Pajes framework I just mentioned).
I’m not interested in an XSLT-based solution (for now).
The problem I’ve come across:
For connecting with Pajes, I’ve thought about a Servlet (kind of a “View”
Dispatcher) that should be the “entry point” to all Pajes-related requests.
Then, one would do things like this:
package org.gn.samples.strutspajes.login;
. . .
public class MyFirstAction extends Action {
public ActionForward execute(ActionMapping actionMapping . . .) {
MyFirstActionForm theActionForm = (LoginActionForm) actionForm;
if (. . .) {
. . .
return actionMapping.findForward("/some_other_typically_mapped_page");
} else {
. . .
ActionForward af =
new PajeViewActionForwardFactory.generate("f.q.view.gen.pajes.classname”,
"theTemplateFilename.html",
request);
return af;
}
}
}
… where the generated ActionForward object points to the aforementioned
Servlet, including on that URL the corresponding parameters. Examples:
“/PajeDispatcher?template=Login.html&factory=org.gn.samples.strutspajes.login.LoginPageView" (in case this is the default web application)
“/webappname/PajeDispatcher?template=ProductCatalog.html&factory=org.gn.samples.strutspajes.login.NavigateProductCatalogPageView" (in case this is not the default web application and the name is “webappname”)
This solves the problem of “delegating” from Struts to Pajes.
HOWEVER, I have not solved yet the data access method part. I MUST
BE ABLE TO RECOVER THE APPROPRIATE ActionForm object FROM THAT Servlet
(actually, in a factory class, but I don’t want to bother you with all
the details) so that the view-generating class can “paint”, WITHOUT
REPLICATING THE ActionForm Management (especially, the scopes management)
ALREADY PERFORMED BY Struts. HOW CAN I DO THAT???
(1) Is there some method (+ class) that, given an Action class (/classname),
returns the ActionForm object its currently associated to? (if any)
(2) What’s the minimal information that one needs to retrieve an Action’s
corresponding ActionForm object?
(3) How can I do it from an ordinary Servlet?
Note that I’m trying to avoid passing it through the Session. My initial
idea was to take advantage of the classes behind the tag libs that do this,
but from what I’ve seen so far (I mean, its source code), that is not
possible (the code is too tied to a JSP environment).
This is my first “effort”. Therefore, I’m not worried about being able to
do EVERYTHING that can be done through the tag libs. For now, the only
thing I look forward is to be able to recover the appropriate ActionForm
object associated to that Action from where redirection took place
(ActionForward, that is).
I’d really appreciate any thoughts on this matter.
Thanks everybody,
Freddy.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.459 / Virus Database: 258 - Release Date: 25/02/2003
Re: Accessing ActionForm from Servlet (was: Pajes + Struts)
Posted by Joe Germuska <Jo...@Germuska.com>.
> > (2) Whatís the minimal information that one needs to retrieve an Actionís
> > corresponding ActionForm object?
ModuleConfig modConf = ModuleUtils.getInstance().getModuleConfig(request);
FormBeanConfig fbc = modConf.findFormBeanConfig(mapping.getName());
(since 2004/01/24):
ActionForm form = RequestUtils.createActionForm(fbc, servlet);
A form must always have a servlet; this is deep in the API of the ActionForm.
These are initial steps towards making it easier
to get an ActionForm instance for prepopulation
on the way to the view. Be warned, this method
does not use any of the logic for looking up an
existing form bean in request or session scope
under any name, either the forms name or the
'attribute' property of an ActionMapping, since
as you can see, the method gets neither a request
or an action mapping.
I have been thinking about adding a method:
RequestUtils.createActionForm(fbc, servlet,
request, scopeString, attributeString) which
would integrate that logic as well, but I was
waiting to make sure that no one objected to what
I did a few weeks ago. Actually, I would also
prefer to use a different method name like
'findOrCreateActionForm' but I don't love that
name, so I'm also waiting to come up with a
method name that I like.
Also, there has been a lot of effort to factor
certain things out of RequestUtils, so maybe it's
time to find a different home for these methods.
FormUtils?
Joe
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"Imagine if every Thursday your shoes
exploded if you tied them the usual way. This
happens to us all the time with computers, and
nobody thinks of complaining."
-- Jef Raskin
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Accessing ActionForm from Servlet (was: Pajes + Struts)
Posted by Hubert Rabago <ja...@yahoo.com>.
I definitely haven't used Pajes, but if the servlet is on the same web app,
perhaps your servlet can access the form in the request attribute.
More comments below
--- "Villalba Arias, Fredy [BILBOMATICA]" <fv...@mailext.com> wrote:
> HOWEVER, I have not solved yet the data access method part. I MUST
> BE ABLE TO RECOVER THE APPROPRIATE ActionForm object FROM THAT Servlet
> (actually, in a factory class, but I don�t want to bother you with all
> the details) so that the view-generating class can �paint�, WITHOUT
> REPLICATING THE ActionForm Management (especially, the scopes management)
> ALREADY PERFORMED BY Struts. HOW CAN I DO THAT???
>
> (1) Is there some method (+ class) that, given an Action class
> (/classname),
> returns the ActionForm object its currently associated to? (if any)
Not sure this would be possible. The actual ActionForm in use depends on the
session, and sometimes even the particular request. I doubt there's a way to
get to the form object actually in use by just specifying the action class.
If it's the *class* of the ActionForm you want, check out the ActionMapping
object for a particular mapping.
> (2) What�s the minimal information that one needs to retrieve an Action�s
> corresponding ActionForm object?
I would say the request object.
> (3) How can I do it from an ordinary Servlet?
request.getAttribute(formName);
or
session.getAttribute(formName);
depending on the scope of the form as declared in struts-config.
> Note that I�m trying to avoid passing it through the Session. My initial
> idea was to take advantage of the classes behind the tag libs that do this,
> but from what I�ve seen so far (I mean, its source code), that is not
> possible (the code is too tied to a JSP environment).
>
> This is my first �effort�. Therefore, I�m not worried about being able to
>
> do EVERYTHING that can be done through the tag libs. For now, the only
>
> thing I look forward is to be able to recover the appropriate ActionForm
>
> object associated to that Action from where redirection took place
>
> (ActionForward, that is).
>
>
>
> I�d really appreciate any thoughts on this matter.
>
>
>
> Thanks everybody,
>
> Freddy.
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.459 / Virus Database: 258 - Release Date: 25/02/2003
>
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org