Results 1 to 5 of 5

Thread: dynamic tiles2 definitions with spring 3

  1. #1
    Join Date
    Jan 2011
    Posts
    3

    Default dynamic tiles2 definitions with spring 3

    Hi all,
    Am doing some work in Spring 3, together with tiles2. I am using the MVC, and am kind of stuck. I have a method in a controller, defined as :

    @RequestMapping("/content/stories/view/{storyid}")
    public ModelAndView editStoryPage(HttpServletRequest request, @PathVariable("storyid") int storyid) {
    ...
    }


    In my tiles xml definition, how do i dynamically map the {storyid} to a definition: the following is not working

    <definition name="content/stories/**" extends="classic.definition">
    <put-attribute name="title" value="View story" />
    <put-attribute name="body" value="/WEB-INF/jsp/content/stories/viewstory.jsp" />
    </definition>

    So in short, if execute something like:
    localhost/content/stories/1
    localhost/content/stories/2
    localhost/content/stories/3

    all these should map to the definition in tiles.xml.
    hope this explains my dilema.

    Thanks a mill.

  2. #2

    Default

    Quote Originally Posted by davidwaf View Post
    Hi all,
    Am doing some work in Spring 3, together with tiles2. I am using the MVC, and am kind of stuck. I have a method in a controller, defined as :

    @RequestMapping("/content/stories/view/{storyid}")
    public ModelAndView editStoryPage(HttpServletRequest request, @PathVariable("storyid") int storyid) {
    ...
    }


    In my tiles xml definition, how do i dynamically map the {storyid} to a definition: the following is not working

    <definition name="content/stories/**" extends="classic.definition">
    <put-attribute name="title" value="View story" />
    <put-attribute name="body" value="/WEB-INF/jsp/content/stories/viewstory.jsp" />
    </definition>

    So in short, if execute something like:
    localhost/content/stories/1
    localhost/content/stories/2
    localhost/content/stories/3

    all these should map to the definition in tiles.xml.
    hope this explains my dilema.

    Thanks a mill.
    I don't follow your question neither whether it is a valid view name definition in Tiles. You can definite your view as content/stories/1, content/stories/2 and so on and return the different views based on the path variable. BTW what is the point to have various views while its components always are the same?
    [URL="http://vicina.info"] 新闻,社区新闻,分类广告

  3. #3
    Join Date
    Dec 2010
    Posts
    315

    Default

    @davidwaf, you should be returning a String instead of a ModelAndView and make sure you have the Tiles2 View Resolver.

    Here's a tutorial I've setup using Tiles 2:

    http://krams915.blogspot.com/2010/12...tegration.html

  4. #4
    Join Date
    Jan 2011
    Posts
    3

    Default dynamic tiles2 definitions with spring 3'

    Thanks @skram. It turns out the problem was somewhere else..anyway, @wv729, basically i had wanted to dynamically generate tiles definitions:

    localhost/content/stories/1
    localhost/content/stories/2
    ...
    localhost/content/stories/n,

    but decided to do it differently, with just once definition and handing parameters from controller.

  5. #5
    Join Date
    Nov 2011
    Posts
    1

    Default

    davidwaf, I am trying to achieve the same what was your solution?

    Thanks

Tags for this Thread

Posting Permissions

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