You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Radek Terber <ls...@post.cz> on 2009/01/12 20:38:37 UTC

dynamic components in page

Hi

Is there possibility to render components in T5 page "dynamically" (in
dependency on return value of any method in page´s class for example, 
or so) ?
Methods "onEvent..." return pages whose are rendered "dynamically" too -
each method can return many pages. I thing it would be possible allow
dynamic including components similar way, but i am not able to do it.

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: dynamic components in page

Posted by Daniel Jue <te...@gmail.com>.
Hi,

Your wording is a little vague.  You probably want to use the Block
component.  For pages from onEvent, they can be anything, and you can return
Strings or MyPage.class to get to the new page.  For components, you have to
list them in the source of your page class and/or page template.
When you stick them inside a <Block> tag in your template, they are not
rendered until specified elsewhere.
The ChenilleKit Tab Panel is a good example of using this.

Also look at the Delegate component.
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Delegate.html

This is about as Dynamic as it gets, without a fair amount of
warranty-voiding magic.

"Static Structure, Dynamic Content"


2009/1/12 Radek Terber <ls...@post.cz>

> Hi
>
> Is there possibility to render components in T5 page "dynamically" (in
> dependency on return value of any method in page´s class for example,
> or so) ?
> Methods "onEvent..." return pages whose are rendered "dynamically" too -
> each method can return many pages. I thing it would be possible allow
> dynamic including components similar way, but i am not able to do it.
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: dynamic components in page

Posted by Ulrich Stärk <ul...@spielviel.de>.
Please look at the Delegate 
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Delegate.html 
component as Daniel suggested. In combination with blocks, this fits 
your problem (see the example, it does exactly what you want).

Also remember Tapestry's "static structure, dynamic behaviour" paradigm. 
You can't manipulate a page's structure at runtime, i.e. all components 
have to be defined on the page.

Cheers,

Uli

Radek Terber schrieb:
> Thanks for responses.
> 
> Using ajax  (via component "zone") is one of  possibly solutions. But,
> ideally, i would like to solve this without Java Script - ideally all
> should be done on server side.
> 
> I try refine my question. My idea was something like this:
> --------
> The component's "Index.tml"
> <div xmlns:t=...>
>     ... Some Boundary Begin ...
>     <t:dynamicComponent t:source="requiredComponent" />      <!-- this
> is the idea. It could be (eventually) parametrized using additional
> attributes ... -->
>     ... Some Boundary End ...
> </div>
> 
> 
> public class Index {
> 
>     @Inject
>     private ComponentFactory componentFactory;     // or any other
> service to obtaint component's instance, ComponentResources ...  ??
> 
>     public Object getRequiredComponent() {
> 
>        String pathToComponent = getPathFromAnywhere();
>         AnyComponentClass componentInstance =
> componentFactory.getOrLoadComponent(pathToComponent);   // or any other
> way to obtain component's instance dynamically (without injection)
>         // do something with "componentInstance"
>         return componentInstance;
>     }
> }
> 
> There could be more ways to obtain component's instance: using path,
> using component class, ...  ??
> This is idea only. I do not know if something  such this is possible.
> 
> As far as I know, the component source in template  (e.g. something like
> this: <t:component t:id="COMPONENT_SOURCE" />) is now reference to page
> directly (or to field annotated as @Component(id = "COMPONENT_SOURCE")
> ... ) and there cannot be typed any expression (all typed here is
> interpreted as component´s page link or ID, including brackets ${...}).
> 
> Radek Terber napsal(a):
>> Hi
>>
>> Is there possibility to render components in T5 page "dynamically" (in
>> dependency on return value of any method in page´s class for example, 
>> or so) ?
>> Methods "onEvent..." return pages whose are rendered "dynamically" too -
>> each method can return many pages. I thing it would be possible allow
>> dynamic including components similar way, but i am not able to do it.
>>
>> Thanks.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>   
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: dynamic components in page

Posted by Radek Terber <ls...@post.cz>.
Thanks for responses.

Using ajax  (via component "zone") is one of  possibly solutions. But,
ideally, i would like to solve this without Java Script - ideally all
should be done on server side.

I try refine my question. My idea was something like this:
--------
The component's "Index.tml"
<div xmlns:t=...>
    ... Some Boundary Begin ...
    <t:dynamicComponent t:source="requiredComponent" />      <!-- this
is the idea. It could be (eventually) parametrized using additional
attributes ... -->
    ... Some Boundary End ...
</div>


public class Index {

    @Inject
    private ComponentFactory componentFactory;     // or any other
service to obtaint component's instance, ComponentResources ...  ??

    public Object getRequiredComponent() {

       String pathToComponent = getPathFromAnywhere();
        AnyComponentClass componentInstance =
componentFactory.getOrLoadComponent(pathToComponent);   // or any other
way to obtain component's instance dynamically (without injection)
        // do something with "componentInstance"
        return componentInstance;
    }
}

There could be more ways to obtain component's instance: using path,
using component class, ...  ??
This is idea only. I do not know if something  such this is possible.

As far as I know, the component source in template  (e.g. something like
this: <t:component t:id="COMPONENT_SOURCE" />) is now reference to page
directly (or to field annotated as @Component(id = "COMPONENT_SOURCE")
... ) and there cannot be typed any expression (all typed here is
interpreted as component´s page link or ID, including brackets ${...}).

Radek Terber napsal(a):
> Hi
>
> Is there possibility to render components in T5 page "dynamically" (in
> dependency on return value of any method in page´s class for example, 
> or so) ?
> Methods "onEvent..." return pages whose are rendered "dynamically" too -
> each method can return many pages. I thing it would be possible allow
> dynamic including components similar way, but i am not able to do it.
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: dynamic components in page

Posted by Andy Pahne <an...@googlemail.com>.
Radek Terber schrieb:
> Hi
>
> Is there possibility to render components in T5 page "dynamically" (in
> dependency on return value of any method in page´s class for example, 
> or so) ?
> Methods "onEvent..." return pages whose are rendered "dynamically" too -
> each method can return many pages. I thing it would be possible allow
> dynamic including components similar way, but i am not able to do it.
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>   


If I understand it right, the current situation is that you cannot 
"dynamically" create a component (on the fly) and then add it to the page.

In case you try to update a zone, you may use blocks. Predefine all 
possible outcomes as separate blocks and let your event handler return 
one of those blocks.

The difference is: the block's content is not generated on the fly, it 
is completly defned when page rendering starts.

Hope that helps,
Andy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: dynamic components in page

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 12 Jan 2009 16:38:37 -0300, Radek Terber <ls...@post.cz>  
escreveu:

> Hi

Hi!

> Is there possibility to render components in T5 page "dynamically" (in
> dependency on return value of any method in page´s class for example,
> or so) ? Methods "onEvent..." return pages whose are rendered  
> "dynamically" too -
> each method can return many pages. I thing it would be possible allow
> dynamic including components similar way, but i am not able to do it.

Take a look at the Zone component, maybe it is what you're:  
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Zone.html.  
There's way very nice example here:  
http://lombok.demon.co.uk/tapestry5Demo/test/core/zonedemoone.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: dynamic components in page

Posted by lst-ara <ls...@post.cz>.
Thanks for responses.

Using ajax  (via component "zone") is one of  possibly solutions. But,
ideally, i would like solve this without Java Script - ideally all
should be done on server side.

I try refine my question. My idea was something like this:
--------
The component's "Index.tml"
<div xmlns:t=...>
    ... Some Boundary Begin ...
    <t:dynamicComponent t:source="requiredComponent" />      <!-- this
is the idea. It could be (eventually) parametrized using additional
attributes ... -->
    ... Some Boundary End ...
</div>


public class Index {

    @Inject
    private ComponentFactory componentFactory;     // or any other
service to obtaint component's instance, ComponentResources ...  ??

    public Object getRequiredComponent() {

       String pathToComponent = getPathFromAnywhere();
        AnyComponentClass componentInstance =
componentFactory.getOrLoadComponent(pathToComponent);   // or any other
way to obtain component's instance dynamically (without injection)
        // do something with "componentInstance"
        return componentInstance;
    }
}

There could be more ways to obtain component's instance: using path,
using component class, ...  ??
This is idea only. I do not know if something  such this is possible.

As far as I know, the component source in template  (e.g. something like
this: <t:component t:id="COMPONENT_SOURCE" />) is now reference to page
directly (or to field annotated as @Component(id = "COMPONENT_SOURCE")
... ) and there cannot be typed any expression (all typed here is
interpreted as component´s page link or ID, including brackets ${...}).

Radek Terber napsal(a):
> Hi
>
> Is there possibility to render components in T5 page "dynamically" (in
> dependency on return value of any method in page´s class for example, 
> or so) ?
> Methods "onEvent..." return pages whose are rendered "dynamically" too -
> each method can return many pages. I thing it would be possible allow
> dynamic including components similar way, but i am not able to do it.
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>   



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org