On 5/9/06, A. Alonso Dominguez <[EMAIL PROTECTED]> wrote:
Hi there!
I'm trying to use the new struts-action framework, version 1.3.3 with
tiles
and faces. I'm following the example applications but I found possibly a
bug
when rendering a struts-based FormBean.
The jsp code that I was using is as follows:
<s:errors />
<s:form action="/login" id="login" styleClass="loginForm"
focus="username">
<h:panelGrid columns="2">
<f:facet name="header">
<h:panelGroup>
<h:graphicImage
url="/common/skin/social-labs/img/circle1.png"
/>
<s:message key="page.logon.form">
<f:param name="arg0" value="Social Labs" />
</s:message>
</h:panelGroup>
</f:facet>
<h:outputLabel for="username">
<s:message key="form.logon.username" />
</h:outputLabel>
<h:inputText id="username" size="25" value="#{logonForm.username}"
/>
<h:outputLabel for="password">
<s:message filter="false" key="form.logon.password" />
</h:outputLabel>
<h:inputSecret id="password" size="25" value="#{logonForm.password}"
/>
<f:facet name="footer">
<h:commandButton id="submit" type="SUBMIT" styleClass="img"
image="/common/skin/social-labs/img/login.png" />
</f:facet>
</h:panelGrid>
</s:form>
but when it's rendered to the view, the HTML form's "action" attribute
references "/common/skin/default/layout/base.do". There is not any action
in
my application with that url. Instead there is a file
"/common/skin/default/layout/base.jsp" which is the base file for the
tiles
definitions:
<definition name="base.layout"
page="/common/skin/default/layout/base.jsp">
<put name="title" value="" />
<put name="navigation" value="" />
<put name="body" value="" />
<putList name="scripts">
<add value="" />
</putList>
</definition>
I dived inside "the org.apache.struts.faces.renderer.FormRenderer" code
and
I found this code (line 280):
protected String action(FacesContext context, UIComponent component) {
String actionURL =
context.getApplication().getViewHandler().
getActionURL(context, context.getViewRoot().getViewId());
if (log.isTraceEnabled()) {
log.trace("getActionURL(" + context.getViewRoot().getViewId()
+
") --> " + actionURL);
}
return (context.getExternalContext().encodeActionURL(actionURL));
}
which really does nothing with the actionURL, It just takes de ViewRootId
and returns it to the caller.
Playing with this code I have now the following:
protected String action(FacesContext context, UIComponent component,
ModuleConfig moduleConfig) {
//String actionURL =
// context.getApplication ().getViewHandler().
// getActionURL(context, context.getViewRoot().getViewId());
FormComponent form = (FormComponent) component;
String actionURL = context.getApplication().getViewHandler().
getActionURL(context, moduleConfig.getPrefix() +
form.getAction());
if (log.isTraceEnabled()) {
log.trace("getActionURL(" + context.getViewRoot().getViewId()
+
") --> " + actionURL);
}
return (context.getExternalContext().encodeActionURL(actionURL));
}
I don't know if this is the correct way for retrieving the real actionURL
but It works now and I'm using it.
Should this be posted as a bug??
Yes, this does sound like a bug. Could you please file an issue on it,
using project name "Struts Action 1" and component "Faces"?
http://issues.apache.org/struts/
Craig