You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "matthew c. mead" <mm...@goof.com> on 2003/07/07 14:45:43 UTC

odd tiles behavior with tile parameters

I'm trying to use Tiles for a couple different things and seeing
some bizarre behavior.  I've not looked into its source too
thoroughly at this point, but would be willing to do so to help
figure this out.

I use tile parameters in a couple different ways:

<definition name="ServiceWithoutSearchHeader" path="/include/header_without_search.jsp" />
<definition name="ServiceWithoutSearchLeftNav" path="/include/left_nav.jsp" />
<definition name="ServiceWithoutSearchFooter" path="/includes/footer.inc" />
<definition name="ServiceWithoutSearchDebug" path="/includes/debug_output.jsp" />
<definition name="ServiceWithoutSearch">
  <put name="header" value="ServiceWithoutSearchHeader" />
  <put name="leftnav" value="ServiceWithoutSearchLeftNav" />
  <put name="footer" value="ServiceWithoutSearchFooter" />
  <put name="debug" value="ServiceWithoutSearchDebug" />
  <put name="navNode" value="Maintenance" type="string" />
  <put name="title" value="Service" direct="true" />
</definition>

So you can see I use them to include tiles within a tile, as well
as some parameters.  When I want to include one of those JSPs in
the output, I simply use <tiles:insert>.

The other parameters in that outer definition (navNode, title), I
pass along to some specific subtiles - the header and the leftnav:

<tiles:insert attribute="header">
  <tiles:put name="title" beanName="title" beanScope="tile" />
  <tiles:put name="navNode" beanName="navNode" beanScope="tile" />
</tiles:insert>

In the sub-tiles I access the title like so:

<tiles:get name="title" />

and it works fine.

However, the navNode I need to use programmatically:

<tiles:useAttribute name="navNode" classname="java.lang.String" />

If I specify direct="true" or type="string" for navNode in the
definition I get a ClassCastException with the above line in my
JSP.  However, the way I'm currently putting it in the definition,
I cannot use it within a <tiles:get> tag because it assumes it is
not direct and tries to read a file.

Is there one method I can use for defining these parameters so they
are consistent or am I stuck with the different definition entries
based on how I use them?

Thanks!



-matt

-- 
matthew c. mead

http://www.goof.com/~mmead/

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


Re: odd tiles behavior with tile parameters

Posted by Sandeep Takhar <sa...@yahoo.com>.
The docs on useAttribute seem do not mention that it
will honour the "type" attribute.  

Obviously it is not a string when placed as a put. 
This would cause the class cast.

What is the cast exception.  It should specify what it
thinks it is?  

There is a getAsString method as well, but I don't
know if this will help you...


sandeep
--- "matthew c. mead" <mm...@goof.com> wrote:
> Thanks for the follow-up - I will try "String".
> 
> My problem really isn't with the attributes I'm
> specifying as
> direct="true" or type="string", it's with the one
> (navNode from
> my example) that I must specifically leave off the
> type/direct
> attributes in order for it to work with the
> useAttribute tag:
> 
> <tiles:useAttribute name="navNode"
> classname="java.lang.String" />
> 
> If I specify direct/type for navNode I get
> ClassCastExceptions
> when my JSP runs with the above tag.
> 
> It seems if there is a bug, it's with the
> useAttribute tag
> implementation or the put tag implementation.
> 
> Any other ideas?
> 
> Thanks again.
> 
> 
> 
> -matt
> 
> On Mon, Jul 07, 2003 at 06:07:33AM -0700, Sandeep
> Takhar wrote:
> > Not sure if this is what you are after, but
> according
> > to the docs it says that tiles:get will respect
> the
> > "type" parameter.  So maybe this is a bug.
> > 
> > >From the docs:
> > 
> > <--
> > If 'direct=true' content is 'string', if
> > 'direct=false', content is 'page'
> > 
> > 
> > Specify content type: string, page, template or
> > definition. 
> > String : Content is printed directly. 
> > page | template : Content is included from
> specified
> > URL. Name is used as an URL. 
> > definition : Value is the name of a definition
> defined
> > in factory (xml file). Definition will be searched
> in
> > the inserted tile, in a <template:insert
> > attribute="attributeName"> tag, where
> 'attributeName'
> > is the name used for this tag. 
> > -->
> > maybe it is case sensitive 'String' instead of
> > 'string'?
> > 
> > 
> > 
> > 
> > sandeep
> > --- "matthew c. mead" <mm...@goof.com> wrote:
> > > I'm trying to use Tiles for a couple different
> > > things and seeing
> > > some bizarre behavior.  I've not looked into its
> > > source too
> > > thoroughly at this point, but would be willing
> to do
> > > so to help
> > > figure this out.
> > > 
> > > I use tile parameters in a couple different
> ways:
> > > 
> > > <definition name="ServiceWithoutSearchHeader"
> > > path="/include/header_without_search.jsp" />
> > > <definition name="ServiceWithoutSearchLeftNav"
> > > path="/include/left_nav.jsp" />
> > > <definition name="ServiceWithoutSearchFooter"
> > > path="/includes/footer.inc" />
> > > <definition name="ServiceWithoutSearchDebug"
> > > path="/includes/debug_output.jsp" />
> > > <definition name="ServiceWithoutSearch">
> > >   <put name="header"
> > > value="ServiceWithoutSearchHeader" />
> > >   <put name="leftnav"
> > > value="ServiceWithoutSearchLeftNav" />
> > >   <put name="footer"
> > > value="ServiceWithoutSearchFooter" />
> > >   <put name="debug"
> > > value="ServiceWithoutSearchDebug" />
> > >   <put name="navNode" value="Maintenance"
> > > type="string" />
> > >   <put name="title" value="Service"
> direct="true" />
> > > </definition>
> > > 
> > > So you can see I use them to include tiles
> within a
> > > tile, as well
> > > as some parameters.  When I want to include one
> of
> > > those JSPs in
> > > the output, I simply use <tiles:insert>.
> > > 
> > > The other parameters in that outer definition
> > > (navNode, title), I
> > > pass along to some specific subtiles - the
> header
> > > and the leftnav:
> > > 
> > > <tiles:insert attribute="header">
> > >   <tiles:put name="title" beanName="title"
> > > beanScope="tile" />
> > >   <tiles:put name="navNode" beanName="navNode"
> > > beanScope="tile" />
> > > </tiles:insert>
> > > 
> > > In the sub-tiles I access the title like so:
> > > 
> > > <tiles:get name="title" />
> > > 
> > > and it works fine.
> > > 
> > > However, the navNode I need to use
> programmatically:
> > > 
> > > <tiles:useAttribute name="navNode"
> > > classname="java.lang.String" />
> > > 
> > > If I specify direct="true" or type="string" for
> > > navNode in the
> > > definition I get a ClassCastException with the
> above
> > > line in my
> > > JSP.  However, the way I'm currently putting it
> in
> > > the definition,
> > > I cannot use it within a <tiles:get> tag because
> it
> > > assumes it is
> > > not direct and tries to read a file.
> > > 
> > > Is there one method I can use for defining these
> > > parameters so they
> > > are consistent or am I stuck with the different
> > > definition entries
> > > based on how I use them?
> > > 
> > > Thanks!
> > > 
> > > 
> > > 
> > > -matt
> > > 
> > > -- 
> > > matthew c. mead
> > > 
> > > http://www.goof.com/~mmead/
> > > 
> > >
> >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > > struts-user-help@jakarta.apache.org
> > > 
> > 
> > 
> > __________________________________
> > Do you Yahoo!?
> > SBC Yahoo! DSL - Now only $29.95 per month!
> > http://sbc.yahoo.com
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> > 
> 
> -- 
> matthew c. mead
> 
> http://www.goof.com/~mmead/
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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


Re: odd tiles behavior with tile parameters

Posted by "matthew c. mead" <mm...@goof.com>.
Thanks for the follow-up - I will try "String".

My problem really isn't with the attributes I'm specifying as
direct="true" or type="string", it's with the one (navNode from
my example) that I must specifically leave off the type/direct
attributes in order for it to work with the useAttribute tag:

<tiles:useAttribute name="navNode" classname="java.lang.String" />

If I specify direct/type for navNode I get ClassCastExceptions
when my JSP runs with the above tag.

It seems if there is a bug, it's with the useAttribute tag
implementation or the put tag implementation.

Any other ideas?

Thanks again.



-matt

On Mon, Jul 07, 2003 at 06:07:33AM -0700, Sandeep Takhar wrote:
> Not sure if this is what you are after, but according
> to the docs it says that tiles:get will respect the
> "type" parameter.  So maybe this is a bug.
> 
> >From the docs:
> 
> <--
> If 'direct=true' content is 'string', if
> 'direct=false', content is 'page'
> 
> 
> Specify content type: string, page, template or
> definition. 
> String : Content is printed directly. 
> page | template : Content is included from specified
> URL. Name is used as an URL. 
> definition : Value is the name of a definition defined
> in factory (xml file). Definition will be searched in
> the inserted tile, in a <template:insert
> attribute="attributeName"> tag, where 'attributeName'
> is the name used for this tag. 
> -->
> maybe it is case sensitive 'String' instead of
> 'string'?
> 
> 
> 
> 
> sandeep
> --- "matthew c. mead" <mm...@goof.com> wrote:
> > I'm trying to use Tiles for a couple different
> > things and seeing
> > some bizarre behavior.  I've not looked into its
> > source too
> > thoroughly at this point, but would be willing to do
> > so to help
> > figure this out.
> > 
> > I use tile parameters in a couple different ways:
> > 
> > <definition name="ServiceWithoutSearchHeader"
> > path="/include/header_without_search.jsp" />
> > <definition name="ServiceWithoutSearchLeftNav"
> > path="/include/left_nav.jsp" />
> > <definition name="ServiceWithoutSearchFooter"
> > path="/includes/footer.inc" />
> > <definition name="ServiceWithoutSearchDebug"
> > path="/includes/debug_output.jsp" />
> > <definition name="ServiceWithoutSearch">
> >   <put name="header"
> > value="ServiceWithoutSearchHeader" />
> >   <put name="leftnav"
> > value="ServiceWithoutSearchLeftNav" />
> >   <put name="footer"
> > value="ServiceWithoutSearchFooter" />
> >   <put name="debug"
> > value="ServiceWithoutSearchDebug" />
> >   <put name="navNode" value="Maintenance"
> > type="string" />
> >   <put name="title" value="Service" direct="true" />
> > </definition>
> > 
> > So you can see I use them to include tiles within a
> > tile, as well
> > as some parameters.  When I want to include one of
> > those JSPs in
> > the output, I simply use <tiles:insert>.
> > 
> > The other parameters in that outer definition
> > (navNode, title), I
> > pass along to some specific subtiles - the header
> > and the leftnav:
> > 
> > <tiles:insert attribute="header">
> >   <tiles:put name="title" beanName="title"
> > beanScope="tile" />
> >   <tiles:put name="navNode" beanName="navNode"
> > beanScope="tile" />
> > </tiles:insert>
> > 
> > In the sub-tiles I access the title like so:
> > 
> > <tiles:get name="title" />
> > 
> > and it works fine.
> > 
> > However, the navNode I need to use programmatically:
> > 
> > <tiles:useAttribute name="navNode"
> > classname="java.lang.String" />
> > 
> > If I specify direct="true" or type="string" for
> > navNode in the
> > definition I get a ClassCastException with the above
> > line in my
> > JSP.  However, the way I'm currently putting it in
> > the definition,
> > I cannot use it within a <tiles:get> tag because it
> > assumes it is
> > not direct and tries to read a file.
> > 
> > Is there one method I can use for defining these
> > parameters so they
> > are consistent or am I stuck with the different
> > definition entries
> > based on how I use them?
> > 
> > Thanks!
> > 
> > 
> > 
> > -matt
> > 
> > -- 
> > matthew c. mead
> > 
> > http://www.goof.com/~mmead/
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

-- 
matthew c. mead

http://www.goof.com/~mmead/

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


Re: odd tiles behavior with tile parameters

Posted by Sandeep Takhar <sa...@yahoo.com>.
Not sure if this is what you are after, but according
to the docs it says that tiles:get will respect the
"type" parameter.  So maybe this is a bug.

>From the docs:

<--
If 'direct=true' content is 'string', if
'direct=false', content is 'page'


Specify content type: string, page, template or
definition. 
String : Content is printed directly. 
page | template : Content is included from specified
URL. Name is used as an URL. 
definition : Value is the name of a definition defined
in factory (xml file). Definition will be searched in
the inserted tile, in a <template:insert
attribute="attributeName"> tag, where 'attributeName'
is the name used for this tag. 
-->
maybe it is case sensitive 'String' instead of
'string'?




sandeep
--- "matthew c. mead" <mm...@goof.com> wrote:
> I'm trying to use Tiles for a couple different
> things and seeing
> some bizarre behavior.  I've not looked into its
> source too
> thoroughly at this point, but would be willing to do
> so to help
> figure this out.
> 
> I use tile parameters in a couple different ways:
> 
> <definition name="ServiceWithoutSearchHeader"
> path="/include/header_without_search.jsp" />
> <definition name="ServiceWithoutSearchLeftNav"
> path="/include/left_nav.jsp" />
> <definition name="ServiceWithoutSearchFooter"
> path="/includes/footer.inc" />
> <definition name="ServiceWithoutSearchDebug"
> path="/includes/debug_output.jsp" />
> <definition name="ServiceWithoutSearch">
>   <put name="header"
> value="ServiceWithoutSearchHeader" />
>   <put name="leftnav"
> value="ServiceWithoutSearchLeftNav" />
>   <put name="footer"
> value="ServiceWithoutSearchFooter" />
>   <put name="debug"
> value="ServiceWithoutSearchDebug" />
>   <put name="navNode" value="Maintenance"
> type="string" />
>   <put name="title" value="Service" direct="true" />
> </definition>
> 
> So you can see I use them to include tiles within a
> tile, as well
> as some parameters.  When I want to include one of
> those JSPs in
> the output, I simply use <tiles:insert>.
> 
> The other parameters in that outer definition
> (navNode, title), I
> pass along to some specific subtiles - the header
> and the leftnav:
> 
> <tiles:insert attribute="header">
>   <tiles:put name="title" beanName="title"
> beanScope="tile" />
>   <tiles:put name="navNode" beanName="navNode"
> beanScope="tile" />
> </tiles:insert>
> 
> In the sub-tiles I access the title like so:
> 
> <tiles:get name="title" />
> 
> and it works fine.
> 
> However, the navNode I need to use programmatically:
> 
> <tiles:useAttribute name="navNode"
> classname="java.lang.String" />
> 
> If I specify direct="true" or type="string" for
> navNode in the
> definition I get a ClassCastException with the above
> line in my
> JSP.  However, the way I'm currently putting it in
> the definition,
> I cannot use it within a <tiles:get> tag because it
> assumes it is
> not direct and tries to read a file.
> 
> Is there one method I can use for defining these
> parameters so they
> are consistent or am I stuck with the different
> definition entries
> based on how I use them?
> 
> Thanks!
> 
> 
> 
> -matt
> 
> -- 
> matthew c. mead
> 
> http://www.goof.com/~mmead/
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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