facebook

[Struts & Tiles] XML parsing problems

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 7 posts - 16 through 22 (of 22 total)
  • Author
    Posts
  • #221212 Reply

    RUFFIE
    Member

    Allright, I’ve tried with 5.0.28 and 5.0.18, no difference!
    I can’t help to think that this is something with the xml files itselfs, although those validate fine.
    I put the project online, a little bit slimmed down (no images and such). I could’ve mailed it to you rkalla, but I guess providing a link is a bit better, so that others if they are interested can look at it too.

    http://www.xs4all.nl/~ruffie21/msl.zip

    I’m going home now, been working on this issue for 2 days now, frustrated and I’ll slap myself if this is one simple fix.
    Tnx rkalla

    #221246 Reply

    Riyad Kalla
    Member

    I couldn’t get this to work either. i would high suggest you do a File > New >Web Project, add Struts capabilities to the project and follow a Tiles tutorial JUST enough to get 1 page working, then see if you can slowly move over portions of your project to see why it isn’t working. Make sure that the simplest test case works first, stop trying to make this big app work.

    #221344 Reply

    RUFFIE
    Member

    Ok, it worked..yeah workED.
    i started a new project as u stated, just the bare components for a tiles project and it worked. I compared the files with the one of msl and they were basically the same as far as I could tell.
    So I just copied them to msl and yup they worked..so I started to expand it little by little to what I had before with msl, everything went well, but now just like that my content isn’t shown!
    It doesn’t matter what file i choose for content, it isn’t shown.

    This is my tiles-defs.xml now:

    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN" "tiles-config_1_1.dtd" >
    <tiles-definitions>
      <definition name="mslDefLayout" path="/layouts/mslDefaultLayout.jsp" >
          <put name="title" value="Hypotheekbank Curacao" />
          <put name="header" value="/jsp/header.jsp" />
          <put name="footer" value="/jsp/footer.jsp" />
          <put name="menu" value="/jsp/officeMenu.jsp" />
      </definition>
      <definition name="index" extends="mslDefLayout">
            <put name="body" value="/jsp/huiskopen.jsp"/>
        </definition>
        <definition name="account" extends="mslDefLayout">
            <put name="body" value="/jsp/accOptions.jsp"/>
        </definition>
    </tiles-definitions>
    

    My mslDefaultLayout.jsp:

    
    <%@ page language="java"%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-template" prefix="template" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>
    
    <html:html xhtml="http://www.w3.org/1999/xhtml" locale="true">
    <head>
    <html:base />
    <link rel="stylesheet" type="text/css" href="/css/chb.css" />
    <script type="text/javascript" language="JavaScript"
    src="myMenuImages.js" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title><tiles:getAsString name="title" ignore="true" /></title>
    </head>
    
    <body text="#000000" onLoad="MM_preloadImages('../images/buttons/butt-passchange-on.gif','../images/buttons/butt-logout-on.gif','../images/buttons/butt-toon-on.gif','../images/buttons/butt-zoekhyp-on.gif')">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="2" align="left"><tiles:insert attribute="header" ignore="true" /></td>
      </tr>
      <tr>
        <td width="22%"><tiles:insert attribute="menu" ignore="true" /></td>
        <td width="78%"><tiles:insert attribute="body" ignore="true" /></td>
      </tr>
     </table>
    </body>
    </html:html>
    

    This is in my struts-config.xml:

    
    <action-mappings >
          <action path="/index" type="com.frontier.action.doTiles">
             <forward name="success" path="index" />
          </action>
          <action path="/accOptions" type="com.frontier.action.doTiles">
             <forward name="success" path="account" />
          </action>
    
       </action-mappings>
    
      <plug-in className="org.apache.struts.tiles.TilesPlugin" >
           <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
           <set-property property="moduleAware" value="true" />
           <set-property property="definitions-parser-validate" value="true" />
       </plug-in>
    

    And my web.xml:

    
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
       <servlet>
          <servlet-name>action</servlet-name>
          <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
          <!--  <servlet-class>org.apache.struts.tiles.ActionComponentServlet</servlet-class>
            <init-param>
            <param-name>definitions-config</param-name>
            <param-value>/WEB-INF/tiles-defs.xml</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>debug</param-name>
             <param-value>3</param-value>
          </init-param>
          <init-param>
             <param-name>detail</param-name>
             <param-value>3</param-value>
          </init-param>
          <load-on-startup>0</load-on-startup>
       </servlet>
       <servlet-mapping>
          <servlet-name>action</servlet-name>
          <url-pattern>*.do</url-pattern>
       </servlet-mapping>
       <jsp-config>
      <taglib>
          <taglib-uri>http://jakarta.apache.org/struts/tags-tiles</taglib-uri>
          <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
      </taglib>
      </jsp-config>
    </web-app>
    

    In case you don’t really understand this tiles usage, here’s the tutorial: http://www.javaworld.com/javaworld/jw-01-2002/jw-0104-tilestrut.html

    It basically comes down to this: Eliminating the pages where you specify what files to put in the tiles. You can do that in the tiles-defs.xml and just call on an action (*.do) that will load the right definition. It’s all explained at the bottom (part 7) of that tutorial.

    No matter if I use this method or the more basic one (without the action mappings) my content isn’t shown anymore 🙁

    #221345 Reply

    RUFFIE
    Member

    Oh oh oh, how stupidddd, I’m really sorry guys, it’s working. Not exactly how I want to, but the content IS shown, but you know where? BELOW! I mean below the menu and all and as I didn’t expect it to show there, I didn’t pay attention to my scrollbar!

    But in my layout i stated it to be in the right column, but instead it goes beneath the menu column? How come??

    #221363 Reply

    Riyad Kalla
    Member

    I’m glad it is working now. As far as where the content is shown, I have no idea.

    #221585 Reply

    RUFFIE
    Member

    rkalla tnx for all your help 😀 Tiles itself is working perfectly now.
    De content showing somewhere else was due to some faulty javascripting, but it’s good now!

    #221588 Reply

    Riyad Kalla
    Member

    Glad to hear it

Viewing 7 posts - 16 through 22 (of 22 total)
Reply To: [Struts & Tiles] XML parsing problems

You must be logged in to post in the forum log in