You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by he...@teradyne.com on 2003/05/21 20:24:54 UTC
tiles attribute type: bug or expected behaviour?
I asked this on the tiles dev list but haven't heard anything.
I've seen a behaviour with tiles that I need some feedback on.
I'm attempting to set message tag key's at runtime using the name
attribute.
I set the name attribute in my tiles definition file.
In my tiles def. file I do something like this.
<put name="InfoHeader" value="some.heading" type="string"/>
In my JSP I do:
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<tiles:importAttribute/>
<h1><bean:message name="InfoHeader"/></h1>
..
This gives me a servletexception.
[ServletException in:/layouts/BodyInfoLayout.jsp] Property for message key
must be a String' javax.servlet.ServletException: Property for message key
must be a String at
..
HOWEVER, if I do the following in my tiles definition file:
<put name="InfoHeader" value="some.heading" type="java.lang.String"/>
the above JSP works correctly. The problem is that it doesn't follow the
tiles config dtd
The type is only supposed to be "string", "page" or "definition"
Is this a known issue or is it supposed to work this way or what??
---
Henrik Bentel
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: tiles attribute type: bug or expected behaviour?
Posted by Cedric Dumoulin <ce...@apache.org>.
Hi,
henrik.bentel@teradyne.com wrote:
>I asked this on the tiles dev list but haven't heard anything.
>
We can't always reply immediately ;-)
>
>I've seen a behaviour with tiles that I need some feedback on.
>I'm attempting to set message tag key's at runtime using the name
>attribute.
>I set the name attribute in my tiles definition file.
>
>In my tiles def. file I do something like this.
> <put name="InfoHeader" value="some.heading" type="string"/>
>
>In my JSP I do:
><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
><%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
><tiles:importAttribute/>
><h1><bean:message name="InfoHeader"/></h1>
>..
>
>This gives me a servletexception.
>[ServletException in:/layouts/BodyInfoLayout.jsp] Property for message key
>must be a String' javax.servlet.ServletException: Property for message key
>must be a String at
>..
>
>HOWEVER, if I do the following in my tiles definition file:
> <put name="InfoHeader" value="some.heading" type="java.lang.String"/>
>
>
>the above JSP works correctly. The problem is that it doesn't follow the
>tiles config dtd
>The type is only supposed to be "string", "page" or "definition"
>Is this a known issue or is it supposed to work this way or what??
>
>
The 'type' attribute is an hint for the insert tag: if the type is
'string', the insert tag output the attribute as a String; if the type
is 'definition', the insert tag try to locate the definition by
considering the attribute value as the definition name...
The importAttribute tag doesn't take into account the 'type'. The
value of the put tag is imported in the specified scope. But, when you
specify a 'type' attribute, the value is not a String, but a class named
Attribute containing the specified value and the specified type. Thus,
importAtrtibute import the class, and not the value.
The 'type' attribute is optional. If you don't have a special need to
specify it, don't do it. In your case, write:
<put name="InfoHeader" value="some.heading"/>
This should work for you.
Cedric
>---
>Henrik Bentel
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org