That's a really nice solution. Have to keep that in mind.
Uli
Am Do, 2.10.2008, 15:49, schrieb Filip S. Adamsen:
> Hi,
>
> Define Blocks containing the different states you need and use a
> Delegate to render the block you need based on an expression. This way
> you can do the whole if-then-else/switch stuff in your page class.
>
> Template:
>
> <t:block t:name="block1">...</t:block>
> <t:block t:name="block2">...</t:block>
>
> <t:delegate t:to="activeblock">
>
> Class:
>
> @Inject
> private ComponentResources resources;
>
> public Block getActiveBlock() {
> String blockId = ...;
> return resources.getBlock(blockId);
> }
>
> It's also possible to have the blocks on another page, in that case you
> can get the page through ComponentSource#getPage, get its
> ComponentResources, and go from there.
>
> http://tapestry.apache.org/tapestry5/guide/templates.html (see <block>)
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/Block.html
> http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Delegate.html
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/ComponentResourcesCommon.html#getBlock(java.lang.String)
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/services/ComponentSource.html#getPage(java.lang.Class)
>
> -Filip
>
> On 2008-10-02 14:39, János Jarecsni wrote:
>> Hi Uli,
>>
>> thanks, I did not know about these. However, what if I have to switch
>> between more states? If seems to be awkward in that case (if embedding
>> is
>> possible at all).
>>
>> Thanks
>> Janos
>>
>> 2008/10/1 Ulrich Stärk <[EMAIL PROTECTED]>
>>
>>> Have a look at the If
>>> (
>>> http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/If.html
>>> )
>>> and Zone
>>> (
>>> http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Zone.html
>>> )
>>> components.
>>>
>>> Uli
>>>
>>> Am Mi, 1.10.2008, 17:06, schrieb János Jarecsni:
>>>> Hi guys,
>>>>
>>>> is there a way to change the template (piece of the template) which
>>>> gets
>>>> generated, depending on state? Here is what I mean:
>>>> Given a component C, its C.tml looks like the following:
>>>>
>>>> <html>blabla...
>>>>
>>>> //if (loggedIn)
>>>> Logged in
>>>> //else
>>>> Not Logged in
>>>>
>>>> </html>
>>>>
>>>> Of course I know this concrete problem can be solved using expansion.
>>>> But
>>>> I'm now after replacing large chunks of the template depending on
>>>> state.
>>>> It
>>>> is easy to do so in a JSP page for example.
>>>>
>>>> Thanks in advance,
>>>> janos
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]