You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2002/11/25 21:10:31 UTC
[tiles] More help with tabbed tiles
On Cedric's advice, I decided to try the xml config file approach for tiles.
I've got classicLayout and vboxLayout working, and now I'm trying to get a
tabbed page to work.
Currently, I'm getting:
javax.servlet.ServletException: Can't get definitions factory from context.
Google turned up a post that said I ought to have 'ActionComponentServlet'
defined in web.xml but that is not how the tiles-definitions example is set
up. The message is from August 2001 so I assume that advice is no longer
valid.
My web.xml, less the filters and security stuff:
<web-app>
<!-- Standard Action Servlet Configuration (with debugging) -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>definitions-config</param-name>
<param-value>/WEB-INF/tiles-defs.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
The relevant bits of struts-config for 'testAction.do':
<struts-config>
<action-mappings>
<action path="/testAction"
type="edu.asu.vpia.example.TestAction"
scope="request" >
<forward name="success"
path="/WEB-INF/jsp/tilesTest/tabsTest.jsp" />
</action>
</action-mappings>
<message-resources parameter="ApplicationResources"/>
</struts-config>
tabsTest.jsp merely has:
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/tld/struts-tiles.tld" prefix="tiles" %>
<tiles:insert definition="examples.tabs.page" flush="true" />
And what the heck, this is already really long, so here's tiles-defs.xml:
<tiles-definitions>
<!-- Master layout and default tiles used by all pages -->
<definition name="examples.masterPage"
path="/WEB-INF/tilesTest/classicLayout.jsp">
<put name="title" value="Tiles 1.1 Examples" />
<put name="header" value="/WEB-INF/tilesTest/header.jsp" />
<put name="menu" value="/WEB-INF/tilesTest/menu.jsp" />
<put name="footer" value="/WEB-INF/tilesTest/footer.jsp" />
<put name="body" value="/WEB-INF/tilesTest/body.jsp" />
</definition>
<!-- tabs page -->
<definition name="examples.tabs.page" extends="examples.masterPage">
<put name="title" value="Tiles 1.1 Tabs layout example" />
<put name="body" value="examples.tabs.body" />
</definition>
<!-- body using tabs -->
<definition name="examples.tabs.body"
path="/WEB-INF/tilesTest/tabsLayout.jsp" >
<put name="selectedIndex" value="0" />
<put name="parameterName" value="selected" />
<putList name="tabList" >
<item value="Doc Home" link="/WEB-INF/tilesTest/a.jsp"
/>
<item value="Quick overview" link="/WEB-INF/tilesTest/b.jsp"
/>
</putList>
</definition>
</tiles-definitions>
As you can see, I've stolen most of this from tiles-docutmentation webapp.
Obviously I missed one or more things, becasue that webapp works and mine
doesn't!
Hopefully someone who has done this before will immediately see what I've
missed. :)
Thanks!
--
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management