You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Roshni Basu <ro...@gmail.com> on 2009/07/16 07:44:12 UTC
How to use import attribute?
Hi,
I'm using <put-attribute name="enableID" value="true" /> in my
tile-definition.xml.
In my jsp I'm using ,
<tiles:importAttribute name="enableID" />
It throws exception saying attribute enableID not found.
If i do not use <tiles:importAttribute name="enableID" />, the jsp is
rendered properly.
Here is my snippet of web.xml
<servlet>
<servlet-name>tiles</servlet-name>
<servlet-class>org.apache.tiles.web.startup.TilesServlet</servlet-class>
<init-param>
<param-name>
org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/layout/tile-definition.xml</param-value>
</init-param>
</servlet>
--
View this message in context: http://www.nabble.com/How-to-use-import-attribute--tp24510460p24510460.html
Sent from the tiles users mailing list archive at Nabble.com.
Re: How to use import attribute?
Posted by Antonio Petrelli <an...@gmail.com>.
2009/7/16 Roshni Basu <ro...@gmail.com>:
> No I did not try it yet. I'll try that.
> So this means attributes defined in the tile-definition can be imported to
> Template.jsp
> and all other inner jsps can fetch the value of the attribute only if in
> Tile-definition file it is defined with cascade="true".
Right.
Re: How to use import attribute?
Posted by Roshni Basu <ro...@gmail.com>.
No I did not try it yet. I'll try that.
So this means attributes defined in the tile-definition can be imported to
Template.jsp
and all other inner jsps can fetch the value of the attribute only if in
Tile-definition file it is defined with cascade="true".
On Thu, Jul 16, 2009 at 2:04 PM, Antonio Petrelli <
antonio.petrelli@gmail.com> wrote:
> 2009/7/16 Roshni Basu <ro...@gmail.com>:
> > This means my Template.jsp should work with
> >
> > <tiles2:importAttribute name="enableID" />
> > <c:out value="${enableID}"></c:out>
> > ??
>
> I think so, did you try it?
>
> Antonio
>
Re: How to use import attribute?
Posted by Antonio Petrelli <an...@gmail.com>.
2009/7/16 Roshni Basu <ro...@gmail.com>:
> This means my Template.jsp should work with
>
> <tiles2:importAttribute name="enableID" />
> <c:out value="${enableID}"></c:out>
> ??
I think so, did you try it?
Antonio
Re: How to use import attribute?
Posted by Roshni Basu <ro...@gmail.com>.
This means my Template.jsp should work with
<tiles2:importAttribute name="enableID" />
<c:out value="${enableID}"></c:out>
??
On Thu, Jul 16, 2009 at 1:51 PM, Antonio Petrelli <
antonio.petrelli@gmail.com> wrote:
> 2009/7/16 Antonio Petrelli <an...@gmail.com>:
> > 2. <tiles:importAttribute> imports attribute that are available in
> > that JSP, not the inserted ones.
>
> Sorry, I meant that it imports attributes that are available in that
> JSP, not the *inserting* ones (i.e. JSP whose solely purpose is to
> insert definitions).
>
> Antonio
>
Re: How to use import attribute?
Posted by Antonio Petrelli <an...@gmail.com>.
2009/7/16 Antonio Petrelli <an...@gmail.com>:
> 2. <tiles:importAttribute> imports attribute that are available in
> that JSP, not the inserted ones.
Sorry, I meant that it imports attributes that are available in that
JSP, not the *inserting* ones (i.e. JSP whose solely purpose is to
insert definitions).
Antonio
Re: How to use import attribute?
Posted by Antonio Petrelli <an...@gmail.com>.
2009/7/16 Roshni Basu <ro...@gmail.com>:
> <tiles2:insertDefinition name="main.top">
> <tiles2:importAttribute name="enableID" />
> <c:out value="${enableID}"></c:out>
> </tiles2:insertDefinition>
Wait a minute, now I understand.
You are trying to insert the definition "main.top". The code above is
invalid, since:
1. in <tiles:insertDefinition> you can override attribute values by
using <tiles:putAttribute>
2. <tiles:importAttribute> imports attribute that are available in
that JSP, not the inserted ones.
But since "enableID" is already put by <put-attribute>, why do you
want to read it here?
Antonio
Re: How to use import attribute?
Posted by Roshni Basu <ro...@gmail.com>.
But yes I may need the same thing in Template.jsp also.
On Thu, Jul 16, 2009 at 1:41 PM, Roshni Basu <ro...@gmail.com> wrote:
> No .
>
>
> On Thu, Jul 16, 2009 at 1:15 PM, Antonio Petrelli <
> antonio.petrelli@gmail.com> wrote:
>
>> 2009/7/16 Roshni Basu <ro...@gmail.com>:
>> > snippet from Jsp file:
>> >
>> > <tiles2:insertDefinition name="main.top">
>> > <tiles2:importAttribute name="enableID" />
>> > <c:out value="${enableID}"></c:out>
>> >
>> >
>> >
>> > </tiles2:insertDefinition>
>>
>> Is this Template.jsp?
>>
>> Antonio
>>
>
>
Re: How to use import attribute?
Posted by Antonio Petrelli <an...@gmail.com>.
2009/7/16 Roshni Basu <ro...@gmail.com>:
> No .
Err... sorry what's this JSP then?
Attributes are available only in JSP pages specified in "template"
attribute. If you want them to be available elsewhere, try with the
"cascade" attribute of <put-attribute>.
Antonio
Re: How to use import attribute?
Posted by Roshni Basu <ro...@gmail.com>.
No .
On Thu, Jul 16, 2009 at 1:15 PM, Antonio Petrelli <
antonio.petrelli@gmail.com> wrote:
> 2009/7/16 Roshni Basu <ro...@gmail.com>:
> > snippet from Jsp file:
> >
> > <tiles2:insertDefinition name="main.top">
> > <tiles2:importAttribute name="enableID" />
> > <c:out value="${enableID}"></c:out>
> >
> >
> >
> > </tiles2:insertDefinition>
>
> Is this Template.jsp?
>
> Antonio
>
Re: How to use import attribute?
Posted by Antonio Petrelli <an...@gmail.com>.
2009/7/16 Roshni Basu <ro...@gmail.com>:
> snippet from Jsp file:
>
> <tiles2:insertDefinition name="main.top">
> <tiles2:importAttribute name="enableID" />
> <c:out value="${enableID}"></c:out>
>
>
>
> </tiles2:insertDefinition>
Is this Template.jsp?
Antonio
Re: How to use import attribute?
Posted by Roshni Basu <ro...@gmail.com>.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<!-- Definitions for Tiles documentation -->
<tiles-definitions>
<definition name="main.top" template="/framework/Template.jsp">
<put-attribute name="header" value="/view/common/header.jsp"/>
<put-attribute name="enableID" value="true"/>
</definition>
</tiles-definitions>
snippet from Jsp file:
<tiles2:insertDefinition name="main.top">
<tiles2:importAttribute name="enableID" />
<c:out value="${enableID}"></c:out>
</tiles2:insertDefinition>
On Thu, Jul 16, 2009 at 12:46 PM, Antonio Petrelli <
antonio.petrelli@gmail.com> wrote:
> 2009/7/16 Roshni Basu <ro...@gmail.com>:
> >
> > Hi,
> >
> > I'm using <put-attribute name="enableID" value="true" /> in my
> > tile-definition.xml.
> > In my jsp I'm using ,
> > <tiles:importAttribute name="enableID" />
>
> Can I see how your definition is done and the JSP pages?
>
> Antonio
>
Re: How to use import attribute?
Posted by Antonio Petrelli <an...@gmail.com>.
2009/7/16 Roshni Basu <ro...@gmail.com>:
>
> Hi,
>
> I'm using <put-attribute name="enableID" value="true" /> in my
> tile-definition.xml.
> In my jsp I'm using ,
> <tiles:importAttribute name="enableID" />
Can I see how your definition is done and the JSP pages?
Antonio