Results 1 to 9 of 9

Thread: Tiles with ControllerClass loads all the time

  1. #1
    Join Date
    Jun 2005
    Location
    Leuven, Belgium
    Posts
    5

    Default Tiles with ControllerClass loads all the time

    Hi,

    I am using tiles in my web application.

    For some of my pages, I use the TilesJstlView and show multiple views on one page. For each of these views I define a controller class in the tiles definition. This is how it is described in the Spring documentation.

    However, I noticed that all those controller classes are run each time I go to a page. (any page, even the pages that contain none of these definitions with controller classes).

    This means that way to much data is fetched everytime I visit a page.

    Is this a know problem, or is it just a misconfiguration of me?

    Thanks in advance,

    Geert

  2. #2
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    Hmmm, the TilesView executed the controller associated to the currently 'rendering' tiles definition. It should really just execute one controller class per definition.

    Could you have a look at the debug output (there's debug output entries for each controller that is executed: something like 'Executing Tiles controller' and then a class name). If there's multiple sightings of this entry for each request than this indeed might be an issue. Still I think only one should be executed, but I could be wrong.

    rgds,
    alef
    Alef Arendsen
    SpringSource
    http://www.springsource.com

  3. #3
    Join Date
    Jun 2005
    Location
    Leuven, Belgium
    Posts
    5

    Default

    Hi,

    In the log files I couldn't find anything like 'Executing Tiles controller'.

    I will show briefly how I have set up the tiles view (I'll paste only the relevant code):

    The controller class:
    Code:
    public class DirController extend ComponentControllerSupport{
    doPerform()
    }
    In servlet.xml:
    Code:
    <bean id="viewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
    <!-- TILES -->
    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles.TilesConfigurer">
      <property name="definitions">
        <list><value>/WEB-INF/conf/tiles-defs.xml</value></list>
      </property>
    </bean>
    <!-- VIEW RESOLVER -->
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass">
     <value>org.springframework.web.servlet.view.tiles.TilesJstlView</value>
    </property>
    </bean>
    In tiles-defs.xml:
    Code:
    <definition name=".dirs" page="/jsp/dirs.jsp" controllerClass="be.controller.DirController"/>
    <definition name="episodes" extends=".dirs">
    <put name="dir" value="episodes"/>  -> THIS IS USED BY THE CONTROLLER AS INPUT
    </definition>
    And finaly in my layout.jsp:
    Code:
    <tiles&#58;insert name="episodes"/>
    As I understood (or thought), DirController will only be used when the tile is used in my layout. But this controller is called everytime.

    I've set the loggin to ALL, and these are the only lines I find about the dirController:

    Code:
    &#91;DEBUG&#93; 08&#58;31&#58;54 DirController - the dir to proces&#58; \\\\127.0.0.1\\episodes
    &#91;DEBUG&#93; 08&#58;31&#58;58 DirController - Content to return&#58; <*snip*>
    &#91;DEBUG&#93; 08&#58;31&#58;58 TilesJstlView - Forwarded to resource &#91;index&#93; in InternalResourceView 'index'

    I hope this is enough information to help me pinpoint the problem I'm experiencing.

    Best regards,

    Geert

  4. #4
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    Geert, unfortunately I don't have the time to look into this until next week since I'm off for a short break. I'll have a look when I get back on Sunday or early next week otherwise.

    rgds,
    alef
    Alef Arendsen
    SpringSource
    http://www.springsource.com

  5. #5
    Join Date
    Jun 2005
    Location
    Leuven, Belgium
    Posts
    5

    Default

    Hi Alef,

    I am still having the same problem.
    Did you have the time to take a look at it ?

    Best regards,

    Geert

  6. #6
    Join Date
    Aug 2005
    Location
    Amsterdam
    Posts
    3

    Default

    Hi Geert,

    Do the other definitions by any chance extend the definition with
    the controller class? If thats the case, it is normal the controller will be
    called.

    Greetz

    Lau

  7. #7
    Join Date
    Jun 2005
    Location
    Leuven, Belgium
    Posts
    5

    Default

    Hi Lauwie,

    This could be.
    Here is the complete code:

    In the tiles-def.xml
    Code:
    <definition name=".dirs" 
        page="/jsp/dirs.jsp" controllerClass="be.verbeeck.intranet.controller.DirController"/>
    
    <definition name="flash" extends=".dirs">
        <put name="dir" value="flashDir"/>
    </definition>
    In the layout.jsp:
    Code:
    <tiles&#58;insert name="flash"/>
    So you're probably right. Thanks for the input.

    Do you have any idea how to do this differently?
    This way, it is not needed to supply the layout.jsp of the flash definition. So, in the definition of my layout/welcome page:
    Code:
    <definition name="layout" path="layout.jsp">
    ...
    </definition>
    
    <definition name="welcomePage" extends="layout">
    <!-- HERE I DON'T PUT THE 'flash' -->
    </definition>
    How can I use the controller class for tiles definitions so those definitions are only called when viewing the corresponding view?

    Thanks in advance,

    Geert

  8. #8
    Join Date
    Aug 2005
    Location
    Amsterdam
    Posts
    3

    Default

    Hi Geert,

    What you could try is the following

    Code:
    <definition name="layout" path="layout.jsp">
       <put name="flash" value="flash" type="definition"/>
       ...
    </definition>
    
    <definition name="welcomePage" extends="layout">
      <put name="flash" value=""/><!-- disable flash -->
       ...
    </definition>
    And then in your layout.jsp file something like
    Code:
    <tiles&#58;insert name="flash" ignore="true"/>
    This is the way I normally disable things like menus and stuff.

    Greetz Lauwie

  9. #9
    Join Date
    Jun 2005
    Location
    Leuven, Belgium
    Posts
    5

    Default

    Lauwie,

    thanks for the help. I will try to do it that way.

    Geert

Similar Threads

  1. Spring & Tiles
    By LilienfeldK in forum Web
    Replies: 7
    Last Post: Dec 28th, 2008, 10:04 PM
  2. Replies: 2
    Last Post: Oct 24th, 2005, 07:52 AM
  3. Replies: 1
    Last Post: Oct 21st, 2005, 05:27 AM
  4. Replies: 8
    Last Post: May 10th, 2005, 06:10 PM
  5. Replies: 2
    Last Post: Feb 10th, 2005, 03:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •