You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Zhang, Larry (L.)" <lz...@ford.com> on 2007/11/12 16:21:54 UTC

Tiles-def.xml

Can I define a constant in tiles-def.xml so that I can used it in all
places inside this file? 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Tiles-def.xml

Posted by "Zhang, Larry (L.)" <lz...@ford.com>.
That approach works except in your following note it should be


<tiles:importAttribute name="myList" />
<c:forEach var="item" items="${myList}">
		c:out value="${item}" />
	</c:forEach> 

Thanks a lot.



-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: Monday, November 12, 2007 11:07 AM
To: Struts Users Mailing List
Subject: Re: Tiles-def.xml

2007/11/12, Zhang, Larry (L.) <lz...@ford.com>:
>
>                 <tiles:getAsString name="myCss1" ignore="true"/>
>                 <tiles:getAsString name="myCss2" ignore="true"/>
>                 <tiles:getAsString name="myCss3" ignore="true"/>
>                 <tiles:getAsString name="myCss4" ignore="true"/>
>                 <tiles:getAsString name="myCss5" ignore="true"/>
>                 <tiles:getAsString name="myCss6" ignore="true"/>
>                 <tiles:getAsString name="myCss7" ignore="true"/>
>                 <tiles:getAsString name="myCss8" ignore="true"/>
>                 <tiles:getAsString name="myCss9" ignore="true"/>
>                 <tiles:getAsString name="myCss10" ignore="true"/>


I think that you could use the list attribute:

<definition....>
  <putList name="myList">
    <add value="myfirst.css" />
    <add value="mysecond.css" />
  </putList>
</definition>

And in your JSP:

<tiles:importAttribute name="myList" />
<c:forEach var="item" items="myList">
  <c:out var="item" />
</c:forEach>


HTH
Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles-def.xml

Posted by Antonio Petrelli <an...@gmail.com>.
2007/11/12, Zhang, Larry (L.) <lz...@ford.com>:
>
>                 <tiles:getAsString name="myCss1" ignore="true"/>
>                 <tiles:getAsString name="myCss2" ignore="true"/>
>                 <tiles:getAsString name="myCss3" ignore="true"/>
>                 <tiles:getAsString name="myCss4" ignore="true"/>
>                 <tiles:getAsString name="myCss5" ignore="true"/>
>                 <tiles:getAsString name="myCss6" ignore="true"/>
>                 <tiles:getAsString name="myCss7" ignore="true"/>
>                 <tiles:getAsString name="myCss8" ignore="true"/>
>                 <tiles:getAsString name="myCss9" ignore="true"/>
>                 <tiles:getAsString name="myCss10" ignore="true"/>


I think that you could use the list attribute:

<definition....>
  <putList name="myList">
    <add value="myfirst.css" />
    <add value="mysecond.css" />
  </putList>
</definition>

And in your JSP:

<tiles:importAttribute name="myList" />
<c:forEach var="item" items="myList">
  <c:out var="item" />
</c:forEach>


HTH
Antonio

RE: Tiles-def.xml

Posted by "Zhang, Larry (L.)" <lz...@ford.com>.
My problem is:

I have 10 (or more ) css files, some pages use 2 of those, some of those
uses 5 of those, some pages use 6 of those, and this combination is
totally random. Then we I create tiles template, I can't put all these
css in the template, instead I thought I can do the following:

My template:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
	<title><tiles:getAsString name="title" ignore="true"/></title>

	<style type="text/css" media="screen">  
		<tiles:getAsString name="myCss1" ignore="true"/>	
		<tiles:getAsString name="myCss2" ignore="true"/>	
		<tiles:getAsString name="myCss3" ignore="true"/>	
		<tiles:getAsString name="myCss4" ignore="true"/>	
		<tiles:getAsString name="myCss5" ignore="true"/>	
  		<tiles:getAsString name="myCss6" ignore="true"/>	
		<tiles:getAsString name="myCss7" ignore="true"/>	
		<tiles:getAsString name="myCss8" ignore="true"/>	
		<tiles:getAsString name="myCss9" ignore="true"/>	
		<tiles:getAsString name="myCss10" ignore="true"/>	
	</style>

</head>


<body>

	<tiles:insert attribute="header"/><br />
	<tiles:insert attribute="bodyContent"/><br />
	<tiles:insert attribute="footer"/><br />
</body>
</html>

Then  I need to define myCss1 and etc in the tiles-def.xml, I don't know
what is the good one to define this, I don't want to define
them like the following :

<definition name="default" path="/jsp/common/main.jsp">
        <put name="header" value="/jsp/common/header.jsp" />
	   <put name="footer" value="/jsp/common/footer.jsp" />
    </definition>	
    
    <definition name="mySepeficPage" extends="default">
    	<put name="title" value="SMERF &gt; Change Request Queue" />
       put name="myCss1" value="the path to the Css1"
      	<put name="bodyContent" value="/jsp/mySpefic.jsp" />
    </definition>
 
Since that will make my tiles-def.xml too massy. 

So the original issue is how to put the dynamic css files in the
template between <head>....<head>.  I would think this is a common issue
for tiles community. Do you have any better way to resolve this issue?



-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: Monday, November 12, 2007 10:30 AM
To: Struts Users Mailing List
Subject: Re: Tiles-def.xml

2007/11/12, Zhang, Larry (L.) <lz...@ford.com>:
>
> Can I define a constant in tiles-def.xml so that I can used it in all
> places inside this file?



No, but probably you can do it in another way.
What do you want to do exactly?

Antonio

P.S.: If you are using Tiles 2, please ask this question to Tiles Users
Mailing List:
http://tiles.apache.org/mail.html
If you are using Struts/Tiles, go on here and ignore this P.S. :-)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles-def.xml

Posted by Antonio Petrelli <an...@gmail.com>.
2007/11/12, Zhang, Larry (L.) <lz...@ford.com>:
>
> Can I define a constant in tiles-def.xml so that I can used it in all
> places inside this file?



No, but probably you can do it in another way.
What do you want to do exactly?

Antonio

P.S.: If you are using Tiles 2, please ask this question to Tiles Users
Mailing List:
http://tiles.apache.org/mail.html
If you are using Struts/Tiles, go on here and ignore this P.S. :-)