jspspring-mvcapache-tiles

Apache tiles using spring mvc


I have a comment tile i want refresh just the comment added not all comment my code is :

<definition name="accueil" extends="new.definition">
     <put-attribute name="showAllPub" value="/WEB-INF/pages/showAllPub.jsp"/>
     <put-attribute name="tileCommentPub" value="/WEB-INF/pages/allPub/tileCommentPub.jsp"/>
</definition>

Can I concatenate the name TileCommentpub with -${p.commentId} to refresh just the comment added?
If yes how I can pass comment id to tiles.xml?
thanks


Solution

  • Can I concatenate the name TileCommentpub with -${p.commentId}

    Unfortunately not; the tile is just a fixed template created at deploy time, and you probably don't know the comment ID until run-time.

    Perhaps this will help; put your comment into tileCommentPub.jsp;

    .... your existing comment jsp code ....
    <p>Comment ID is : ${p.commentId}</p>
    <p>For example : ${comment.text}</p>
    

    And inject the comment specific data from your controller;

    @RequestMapping
    public String getSomePageWithComment (final Model model) {
        // ... get the comments...
        model.addAttribute("comment", comment);
        model.addAttribute("p", p);
        return "tileCommentPub";
    }