23 jan 2012 kl. 09.19 skrev Antonio Petrelli:


I need to change some content in my header tile for one page only, linking in some special javascript. Do I have to make a new main template just for
this page, or is there some other way?

In several individual pages I need to change the id value of body, which
is in my main template. How do I go about this in Tiles?

I've been trough the documentation, but this has eluded me. Please offer
some starter points or thoughts.


Can you explain with an example what are you trying to accomplish? You are
too vague.


Thanks for your response Antonio.

My Tiles setup is
***layout.xml:***
<definition name="default" template="/WEB-INF/layouts/default.jspx">
    <put-attribute name="header" value="/WEB-INF/views/header.jspx" />
    <put-attribute name="footer" value="/WEB-INF/views/footer.jspx" />
  </definition>

****

 and typically I put specific content in:

*** view.xml:***
<definition name="index" extends="default">
<put-attribute name="primary" value="/WEB-INF/views/ primary.jspx" /> <put-attribute name="secondary" value="/WEB-INF/views/ secondary.jspx" />
  </definition>
***
with a main template
***default.jspx:***

"<html xmlns:jsp="http://java.sun.com/JSP/Page"; xmlns:c="http://java.sun.com/jsp/jstl/core " xmlns:tiles="http://tiles.apache.org/tags-tiles"; xmlns:spring ="http://www.springframework.org/tags "
xmlns:util="urn:jsptagdir:/WEB-INF/tags/util" lang="se">
        
        <!-- jsp output and directive here-->
                        
        <head>
                <!--meta here-->
                        
        <link rel="stylesheet" href="styles/layout.css"></link>
<!--1. THESE ARE WHAT I WANT TO CHANGE FOR SOME VIEWS: -->
<script src="build/mediaelement-and-player.js" type="text/ javascript"></script>
        <script src="build/jquery.js" type="text/javascript"></script>
                
                <!-- message code for title here-->
        </head>
<!--2. HERE I WOULD LIKE TO CHANGE PER VIEW THE VALUE OF THE "id" ATTRIBUTE OF BODY -->
        <body id="a_value">
        <div id="page">
                    <tiles:insertAttribute name="header"/>
                    <div id="container" class="top">
                                <div id="main_content" class="page_content">
                                        <tiles:insertAttribute name="primary"/>
                                        <tiles:insertAttribute name="secondary" 
ignore="true"/>
                                </div>
                    </div>
                    <tiles:insertAttribute name="footer"/>
                </div>
        </body></html>
***

So I'd like to be able to change 1 above to other values per the current view for the script attribute "src" or omit it totally and also in 2 above change the attribute value "id" in the body element. I suppose I could make an alternative tile and swap the this for the views where I need this, but then I'd need one for every page, which seems over the top and clumsy.

I suspect I need inheritance and/or nested definitions, but I don't understand exactly how to implement this for the above. Even better would be if it's was possible to go even closer to the details I need to affect and change the attribute values at some places based on the current view. I don't know of this is possible, but this is what I'm looking for. Any suggestions are welcome.

An additional question related to the previous:

I have my
***header.jspx:***
<div id="header" xmlns:jsp="http://java.sun.com/JSP/Page"; xmlns:fn="http://java.sun.com/jsp/jstl/functions " xmlns:c="http://java.sun.com/jsp/jstl/core"; xmlns:spring="http://www.springframework.org/tags " version="2.0">

        <!--jsp output and directive -->
        <h1>Main Headline</h1>
        <ul id="navigation">
<!--3. I'D LIKE TO CHANGE THE CLASS FOR SOME LIST ITEMS BELOW BASED ON THE CURRENT VIEW -->
                <li id="start" class"current"><a href="/">Start</a></li>
                <!-- More list items without class attribute -->
        </ul>
</div>
***

On 3 above I'd like to change the class attribute on list items based on the current view. I suppose it's a similar solution like for the previous I need here, and also in this case what I need to affect is inside a tile and as with the previous 1 I'd like to avoid making one big tile per view.

I have a feeling Tiles is more versatile than I have understood so far and this is why I ask for some guidance or suggestions.

Thank you!
/MiB




Reply via email to