Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7833393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:41:12+00:00 2026-06-02T12:41:12+00:00

I’m developing my own project using spring-mvc and spring-webflow. After reading some articles about

  • 0

I’m developing my own project using spring-mvc and spring-webflow. After reading some articles about spring webflow and ajax, I understood the better option is the use of Apache Tiles for rendering the view.

In Sitemesh i used a tag call head (). That tag used in the template allows render the entire head attribute of a page rendered on the resulting HTML.

Is there any way to achive this in Apache Tiles? From my readings i presume that i have to do the following:

Two jps, one with the body of the page and another with the head definition. Here is an example with the template, a page and the tiles definition for better understanding.

the tiles definition

<tiles-definitions>
  <definition name="base" template="/WEB-INF/view/templates/tileslayout.jsp">
    <put-attribute name="title" value="Held - main page"/>
    <put-attribute name="body" value=""/>
    <put-attribute name="head" value=""/>
  </definition>

  <definition name="company.edit" extends="base">
    <put-attribute name="head" value="/WEB-INF/view/company/editHeader.jsp"></put-attribute>
    <put-attribute name="body" value="/WEB-INF/view/company/edit.jsp"></put-attribute>
  </definition>

</tiles-definitions>

the template:

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %> 
<html>
<head>
 -- css and scripts --
 <tiles:insertAttribute name="head"  ignore="true"/>
<!--  <decorator:head /> -->
</head>

<body>

--- menu definition ---

<div class="container-fluid">
    <tiles:insertAttribute name="body"/>
<!--   <decorator:body/> -->
</div>
<hr/>      
<footer>
    -----
</footer>

</body>
</html>

a company page

<div class="container">
-- the page html code
</div>

the head company page

<meta name="menu" content="company" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
.error {
    color: red;
}
</style>
<script type="text/javascript">
    $(document).ready(function() {
        $('#name').focus();
    });
</script>

sometimes the head maybe more complex.

The resulting html is ok. But i don’t like to define two jps for something that should be simple.

I’m doing something wrong?

Is there a better way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T12:41:18+00:00Added an answer on June 2, 2026 at 12:41 pm

    What you have is correct. The decoration pattern which Sitemesh uses can address this while the composition which Tiles uses can not. However I would not say it is much of a worry.

    Composition is the conceptually simpler strategy and it is less resource intensive. It is good you are learning Tiles the two systems are not exclusive and can be complimentary.

    Tiles is about factoring your pages into tiles. What you have is as good as tiles currently allows. You have found that in the head there is script the re-occurs and so have made a tile of it. Although it isn’t as minimal as doing what you are proposing, if you put all the site functionality into a single script file it will take a short time to load but after doing so there will be no overhead due to caching.

    If security is an issue (ie you have different security levels in your application and don’t want to give away what a high level user is even capable of by exposing their JS) then you could have the tiles attributes use EL to define which tiles to bring in. To do this use tiles version 2.2.2 and use the tiles listener “org.apache.tiles.extras.complete.CompleteAutoloadTilesListener”, this will allow the use of wildcards, EL, OGNL and MVEL within the tiles defintions. The following will show how wldcards can greatly reduce the size of your definitions:

    Your second definition “company.edit” if you have multiple companies, with multiple verbs then you could write the following definition instead:

    <definition name="*.*" extends="base">
      <put-attribute name="head" value="/WEB-INF/view/{1}/{2}Header.jsp"></put-attribute>
      <put-attribute name="body" value="/WEB-INF/view/{1}/{2}.jsp"></put-attribute>
    </definition>
    

    Now you can simply create company after company under /WEB-INF/view/ along with editHeader, viewHeader, etc.

    If you upgrade to 2.2.2 and use the “org.apache.tiles.extras.complete.CompleteAutoloadTilesListener” because of the multiple ways of interpreting the expressions you would need to write:

    <definition name="WILDCARD:*.*" extends="base">
      <put-attribute name="head" value="/WEB-INF/view/{1}/{2}Header.jsp"></put-attribute>
      <put-attribute name="body" value="/WEB-INF/view/{1}/{2}.jsp"></put-attribute>
    </definition>
    

    If you decided to decided to put all the JS for a particular security level into a tile you get the appropriate tile by possibly saying:

    <put-attribute name="head" value="/WEB-INF/view/{1}/OGNL:'session.securityLevel'+'.jsp'"></put-attribute>
    

    OGNL is the default Struts2 expression language, in your case you’d use the appropriate EL or MVEL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.