struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stone, Sam" <sst...@constantcontact.com>
Subject RE: How to access componentDefinition?
Date Tue, 02 Jan 2007 18:28:20 GMT
In your example:

TilesContainer container = TilesAccess.getContainer(context);
ComponentContext ctx = container.getComponentContext(req, res);
ComponentAttribute attr = ctx.getAttribute(name);

ctx comes back with no attributes (therefore attr results in null).

I think I want to call getContainer with pageContext. How do I get the
pageContext?

To recap what I WAS doing with the old API - I was inspecting a tiles
definition and searching for a specific attribute. I'm doing this BEFORE
dispatching to the tiles servlet.

Sam

-----Original Message-----
From: David H. DeWolf [mailto:ddewolf@gmail.com] On Behalf Of David H.
DeWolf
Sent: Tuesday, January 02, 2007 10:36 AM
To: Struts Developers List
Subject: Re: How to access componentDefinition?

potentially . . .it depends on your environment.  My guess is that from 
your example the answer is yes.

David

Stone, Sam wrote:
> TilesContainer container = TilesAccess.getContainer(context);
> 
> Is "context" the servletContext?
> 
> -----Original Message-----
> From: David H. DeWolf [mailto:ddewolf@gmail.com] On Behalf Of David H.
> DeWolf
> Sent: Tuesday, January 02, 2007 10:30 AM
> To: Struts Developers List
> Subject: Re: How to access componentDefinition?
> 
> Hi Sam:
> 
> Everything is now done through the container.
> 
> Try something like this:
> 
> TilesContainer container = TilesAccess.getContainer(context);
> ComponentContext ctx = container.getComponentContext(req, res);
> ComponentAttribute attr = ctx.getAttribute(name);
> 
> 
> David
> 
> Stone, Sam wrote:
>> Using the API from Sep 2006 I was able to access externally an
> attribute
>> from a tiles definition as follows:
>>
>> String sTilesDefName = (String) request.getAttribute("tile_name");
>> TilesContext tilesContext = new
>> ServletTilesContext(session.getServletContext(), request, response);
>>
>> ComponentDefinition componentDefinition =
>> TilesUtil.getDefinition(sTilesDefName, tilesContext);
>>
>> String sMyAtribute = (String)
>> componentDefinition.getAttribute("myAttribute");
>>
>> I can't quite figure out how to do this using the current Tiles 2
API.
>>
>> Sam
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

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


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


Mime
View raw message