struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Cramer" <kcra...@siscom.net>
Subject Tiles Controller in definitions
Date Wed, 26 Mar 2003 02:50:19 GMT

I'm trying to setup a controller for a Tiles definition.  I follow the
examples I've seen but it appears that the controller class is not
called.  I've seen posts here that indicate that you need to use
tiles:insert to enable the controller but I'm always using that
whenever I include the JSP.  Perhaps my use of tile definitions is
causing problems?  I'm also unsure whether I'm supposed to use the
perform() or execute() on the Controller interface.  The error I get
is that the JSP of the tile with the controller complains that it
cannot find the object that I am doing the putAttribute with.  The
error is on the tiles:importAttribute.

I have the following in my tiles-defs.xml:

<definition name="standardPage"
            path="/WEB-INF/common/layouts/standardLayout.jsp">
    <put name="title.key"   value="title.notDefined" />
    <put name="header"      value=".standardPage.header" />
    <put name="content"     value="NO CONTENT DEFINED" />
    <put name="left"        value="/WEB-INF/common/other1.jsp" />
    <put name="right"       value="standardPage.testcontroller" />
</definition>

<definition name=".standardPage.header"
            path="/WEB-INF/common/header.jsp">
    <put name="headerbar"  value="standardPage.header.bar"/>
</definition>

<definition name="standardPage.header.bar"
            path="/WEB-INF/common/bar.jsp">
    <put name="left"  value="NO LEFT DEFINED" />
    <put name="right" value="NO RIGHT DEFINED" />        
</definition>


<definition name="standardPage.testcontroller" 
            path="/WEB-INF/common/testcontroller.jsp"
            controllerClass="mytest.TestAction">
</definition>

Here is the testcontroller.jsp:

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-tiles" prefix="tiles" %>

<tiles:importAttribute name="TEST"/>
<bean:write name="TEST" property="value"/>


Here is the controller class:

public final class TestAction extends TilesAction implements Controller {
        public static final String TEST_KEY = "TEST";

        public ActionForward perform(
                ComponentContext context,
                ActionMapping arg1,
                ActionForm arg2,
                HttpServletRequest arg3,
                HttpServletResponse arg4)
                throws IOException, ServletException {

                perform(context, arg3, arg4, getServlet().getServletContext());
                return null;
        }

        public void perform(
                ComponentContext context,
                HttpServletRequest arg1,
                HttpServletResponse arg2,
                ServletContext arg3)
                throws ServletException, IOException {

                MyTestObject test = new MyTestObject("Test Value");
                context.putAttribute(TEST_KEY, test);
        }

        public ActionForward execute(
                ComponentContext context,
                ActionMapping arg1,
                ActionForm arg2,
                HttpServletRequest arg3,
                HttpServletResponse arg4)
                throws Exception {

                perform(context, arg3, arg4, getServlet().getServletContext());
                return null;
        }
}


Thanks,
Kevin

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message