You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by James Gardener <ja...@gmail.com> on 2007/03/04 15:13:05 UTC

myfaces tiles problem

Hi all,

I am trying to use tiles with myfaces.  I could run
myfaces-1.0.7-tiles-example successfully, but I am having a hard time when
implementing a more complex project based on this example.

Here is my layout:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="tiles" uri="http://struts.apache.org/tags-tiles"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
      <meta http-equiv="Content-Type" content="text/html;CHARSET=iso-8859-1"
/>
      <link rel="stylesheet" type="text/css" href="css/basic.css" />
    </head>
    <body>
       <f:view>
         <div id="level0">
            <div id="level1">
               <div id="topBar">
                  <f:subview id="header">
                    <tiles:insert attribute="header" flush="false"/>
                  </f:subview>
               </div>
               <div id="level2">
                  <f:subview id="content">
                    <tiles:insert attribute="body" flush="false"/>
                  </f:subview>
               </div>
            </div>
         </div>
       </f:view>
    </body>
</html>

Here is my tiles-def.xml:
<tiles-definitions>
    <definition name="main.layout" path="/jsp/template/basicLayout.jsp">
        <put name="header" value="/jsp/common/adminHeader.jsp" />
    </definition>

    <definition name="/login.tiles" extends="main.layout">
        <put name="body" value="/jsp/admin/login.jsp" />
    </definition>
</tiles-definitions>

Here is the login.jsp page:

<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>


        <h:form id="loginForm">
            <table align="center">
                <tr>
                   <td style="padding:20">
                        <table>
                            <tr>
                                <td align="right">
                                    <h:outputText value="UserId"/>
                                 </td>
                                 <td align="left">
                                       <h:inputText value="#{
userAdminBean.userId}" id="userId" required="true"/>
                                       <h:message styleClass="errorMessage"
for="userId"/>
                                   </td>
                               </tr>
                            <tr>
                                   <td align="right">
                                       <h:outputText value="Password"/>
                                 </td>
                                 <td align="left">
                                    <h:inputSecret value="#{
userAdminBean.password}" id="password" required="true"/>
                                    <h:message styleClass="errorMessage"
for="password"/>
                                </td>
                              </tr>
                              <tr>
                                  <td colspan="2" align="center">
                                    <h:commandButton value="Login"
action="#{userAdminBean.loginAction}"/>
                                  </td>
                              </tr>
                              <tr >
                                  <td colspan="2" align="center">
                                    <h:messages errorClass="errorMessage"
globalOnly="true"/>
                                </td>
                            </tr>
                          </table>
                      </td>
                  </tr>
              </table>
        </h:form>

When I call http://localhost:8080/myApp/login.jsf, everything is displayed,
but the userid + userid textbox + password + password textbox + login button
are all displayed in a single row.  If I don't use tiles, the above fields
are displayed in different table rows based on the HTML, which is correct.

Could you please tell me if anything is wrong with my code?  Thanks a lot!

James