struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Friedman" <hum...@ix.netcom.com>
Subject RE: Struts/tiles: Run-time definition of which tile to include
Date Tue, 01 Jun 2004 22:47:45 GMT
If it is only "logged in" versus "not logged in",
why not use this simple 2-step process:

1. Set the tiles:put, tiles:add, etc. in your tiles xml
file to be the "not logged in" page.


2. In your action, subclass the TilesAction
(class org.apache.struts.tiles.actions.TilesAction)
and, in it's execute() method, override the tile
component if you are logged in, kind of like below:

// Always refer to documentation
// don't just try quoting me

if ( request.getUserPrincipal != null ) {
	// override "someTilePart", which in your tiles xml
	// file points to the appropriate not-logged-in JSP
	// for content display

	context.putAttribute("someTilePart", new String("/somePage.jsp");

	// and whatever else you require done to the tile.
}

Regards,
David

-----Original Message-----
From: lokanath@molecularconnections.com
[mailto:lokanath@molecularconnections.com]
Sent: Monday, May 31, 2004 11:37 PM
To: Struts Users Mailing List
Cc: user-unsubscribe@struts.apache.org
Subject: RE: Struts/tiles: Run-time definition of which tile to include




-----Original Message-----
From: Struts Users Mailing List [mailto:user@struts.apache.org]
Sent: Monday, May 31, 2004 4:00 PM
To: Struts Users Mailing List
Subject: Re: Struts/tiles: Run-time definition of which tile to include


On 31/5/04 2:52, "Michael McGrady" <mike@michaelmcgrady.com> wrote:

> Why don't you just use an
> ActionForward to go to the tiles definition in tiles-defs.xml you
> want?

Maybe I didn't explain myself well.  The point is that I don't want to have
one set of tile definitions for when they're logged in, and another set for
when logged out.  I want a single set of definitions, with the status tile
putting up appropriate content depending on whether they're logged in or
not.

One way would be to have a status tile that does conditional logic, as I
showed in my snippet.

But I thought there ought to be a simple way to do away with the conditional
page and do the whole thing in the definitions file: In my definition file,
I want to say "insert tile A or tile B depending on the value of bean X"

 Husted's book, and the Wrox one, are pretty poor on their coverage of
tiles, IMO.


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






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


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


Mime
View raw message