struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James CE Johnson <>
Subject modules, tiles and html:form
Date Wed, 12 Mar 2003 01:25:21 GMT

I'm having a problem with a combination of modules, tiles and html:form. 
Hopefully someone out there has a better solution than what I've come up 

The short version of my saga is that html:form in a jsp included as a 
tile by an action of a sub-application cannot resolve it's 'action' 
attribute into the appropriate action defined in the sub-application's 
struts config file.

The long version of the saga... (and there's a URL to a tarball of an 
example of my problem at the bottom)

My web.xml specifies two struts configuration files:

Each of the named config files installs the Tiles plugin. 
struts-config.xml looks to tiles-definitions.xml while 
struts-config-admin.xml looks both there and at tiles-definitions-admin.xml.

In struts-config-admin.xml I have the following action defined:
    <action path="/broken1"
      <forward name="success" path="tile.broken1"/>
This, of course, corresponds to the context-relative url /admin/

The tile definition for 'tile.broken1' in tiles-definitions-admin.xml is:
  <definition name="tile.broken1" extends="layout">
      <put name="body" value="/WEB-INF/jsp/admin/broken1.jsp"/>

Finally, the 'layout' tile is defined in tiles-definitions.xml as:
  <definition name="layout" path="/WEB-INF/jsp/layout.jsp">
    <put name="title"   value="Struts Issues" />
    <put name="header"  value="/" />
    <put name="footer"  value="/"/>
    <put name="body"    value="/WEB-INF/jsp/blank.jsp" />

broken1.jsp attempts to create a trivial form thusly:
<html:form action="/admin/">
  <html:text property="name"/>

So, with all of that in place, when i try to access 
http://localhost:8080/StrutsIssue/admin/ (using JBoss 3.0.6 by 
the way) I get a nasty stacktrace telling me:
[ServletException in:/WEB-INF/jsp/admin/broken1.jsp] Cannot retrieve 
mapping for action /admin/bar' javax.servlet.jsp.JspException: Cannot 
retrieve mapping for action /admin/bar at 
org.apache.struts.taglib.html.FormTag.lookup( at 
org.apache.struts.taglib.html.FormTag.doStartTag( at 

Thinking that, perhaps, the jsp thinks it is within the /admin "scope" 
(if you'll pardon the misuse of the term), I try again with:
<html:form action="/">
  <html:text property="name"/>
But, as expected, that fails because there is no /bar action defined in 
the struts-config.xml (only in struts-config-admin.xml)

I have a workaround but I don't like it very much. First we return to 
struts-config-admin.xml with a new pair of actions:
    <action path="/working"
      <forward name="success" path="tile.working"/>
    <action path="/workingView"
      <forward name="success" contextRelative="true" 
I don't like this for two reasons:
1) I have to define two action paths for every action
2) I now have an action path that directly forwards to a jsp rather than 
handling all of that with tiles

tiles-definitions-admin.xml picks up the new tile.working definition so 
that the defined layout will be pleased:
  <definition name="tile.working" extends="layout">
      <put name="body" value="/admin/"/>
I don't like this because now my tiles have knowlege of the 
sub-application's context. Ideally, the '/admin' partial-path should 
only be known to web.xml.

And the working.jsp is:
<html:form action="/">
  <html:text property="name"/>
The only thing I really like about the solution is that the working.jsp 
references the action path within the scope of the /admin module.

I'm using struts 1.1-RC1 BTW.

A simplified and fully working example of my problem is here:
There's a deployable warfile in the target subdirectory of the tarball.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message