You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andrey Larionov <an...@gmail.com> on 2009/08/17 22:55:29 UTC

How to create Master-Detail view

Hi, everyone
I start to explore world of Tapestry 5. It so exciting. But at first
time is very difficult to find simple elegant (maybe pattern-like)
solution. And i want to ask, can any point or give advice on creating
Master-Detail presentation. I want to have two independent component
but with posibility to link. Selecting element in one is display
coresponding subset of data in another. But also i want to use it
independent (especialy Master view) for managing Master datasource.

Thanks

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


Re: How to create Master-Detail view

Posted by Andrey Larionov <an...@gmail.com>.
But the correct solution was in using prop: prefix to refer to
enclosing component.
Thanks for pointing. Work in progress.

On Tue, Aug 18, 2009 at 07:51, Andrey Larionov<an...@gmail.com> wrote:
> The only way i can achive result is ugly getSelf hack. Thru
> environmental service i can't access no component no wraped component.
>
> On Tue, Aug 18, 2009 at 05:57, Andrey Larionov<an...@gmail.com> wrote:
>> Thanks for good point. try it now.
>>
>> On Tue, Aug 18, 2009 at 05:51, Thiago H. de Paula
>> Figueiredo<th...@gmail.com> wrote:
>>> Em Mon, 17 Aug 2009 22:12:13 -0300, Andrey Larionov <an...@gmail.com>
>>> escreveu:
>>>
>>>> One more question. How to pass enclosing component into nested. I mean
>>>> "self". In loop i render elements and i want to pass enclosing element
>>>> as parameter in template
>>>> For example: (start component template)
>>>> <div id="feedList"
>>>> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
>>>> xmlns:p="tapestry:parameter">
>>>>    <ul>
>>>>        <li t:type="loop" t:source="feeds" t:value="feed">
>>>>            <t:feedelement feed="feed" feedList="component:feedList"/>
>>>
>>> You can only use component:componentId for components declared in the same
>>> template.
>>> A quick and dirty way would be to add a getSelf() { return this; } method in
>>> your component class and them pass feedList="self".
>>> A more elegant way would be to use the Environmental service, something I've
>>> never used but seems to be easy.
>>>
>>> --
>>> 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
>>>
>>>
>>
>

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


Re: How to create Master-Detail view

Posted by Andrey Larionov <an...@gmail.com>.
The only way i can achive result is ugly getSelf hack. Thru
environmental service i can't access no component no wraped component.

On Tue, Aug 18, 2009 at 05:57, Andrey Larionov<an...@gmail.com> wrote:
> Thanks for good point. try it now.
>
> On Tue, Aug 18, 2009 at 05:51, Thiago H. de Paula
> Figueiredo<th...@gmail.com> wrote:
>> Em Mon, 17 Aug 2009 22:12:13 -0300, Andrey Larionov <an...@gmail.com>
>> escreveu:
>>
>>> One more question. How to pass enclosing component into nested. I mean
>>> "self". In loop i render elements and i want to pass enclosing element
>>> as parameter in template
>>> For example: (start component template)
>>> <div id="feedList"
>>> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
>>> xmlns:p="tapestry:parameter">
>>>    <ul>
>>>        <li t:type="loop" t:source="feeds" t:value="feed">
>>>            <t:feedelement feed="feed" feedList="component:feedList"/>
>>
>> You can only use component:componentId for components declared in the same
>> template.
>> A quick and dirty way would be to add a getSelf() { return this; } method in
>> your component class and them pass feedList="self".
>> A more elegant way would be to use the Environmental service, something I've
>> never used but seems to be easy.
>>
>> --
>> 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
>>
>>
>

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


Re: How to create Master-Detail view

Posted by Andrey Larionov <an...@gmail.com>.
Thanks for good point. try it now.

On Tue, Aug 18, 2009 at 05:51, Thiago H. de Paula
Figueiredo<th...@gmail.com> wrote:
> Em Mon, 17 Aug 2009 22:12:13 -0300, Andrey Larionov <an...@gmail.com>
> escreveu:
>
>> One more question. How to pass enclosing component into nested. I mean
>> "self". In loop i render elements and i want to pass enclosing element
>> as parameter in template
>> For example: (start component template)
>> <div id="feedList"
>> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
>> xmlns:p="tapestry:parameter">
>>    <ul>
>>        <li t:type="loop" t:source="feeds" t:value="feed">
>>            <t:feedelement feed="feed" feedList="component:feedList"/>
>
> You can only use component:componentId for components declared in the same
> template.
> A quick and dirty way would be to add a getSelf() { return this; } method in
> your component class and them pass feedList="self".
> A more elegant way would be to use the Environmental service, something I've
> never used but seems to be easy.
>
> --
> 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
>
>

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


Re: How to create Master-Detail view

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 17 Aug 2009 22:12:13 -0300, Andrey Larionov <an...@gmail.com>  
escreveu:

> One more question. How to pass enclosing component into nested. I mean
> "self". In loop i render elements and i want to pass enclosing element
> as parameter in template
> For example: (start component template)
> <div id="feedList"
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
> xmlns:p="tapestry:parameter">
>     <ul>
>         <li t:type="loop" t:source="feeds" t:value="feed">
>             <t:feedelement feed="feed" feedList="component:feedList"/>

You can only use component:componentId for components declared in the same  
template.
A quick and dirty way would be to add a getSelf() { return this; } method  
in your component class and them pass feedList="self".
A more elegant way would be to use the Environmental service, something  
I've never used but seems to be easy.

-- 
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: How to create Master-Detail view

Posted by Andrey Larionov <an...@gmail.com>.
One more question. How to pass enclosing component into nested. I mean
"self". In loop i render elements and i want to pass enclosing element
as parameter in template
For example: (start component template)
<div id="feedList"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
    <ul>
        <li t:type="loop" t:source="feeds" t:value="feed">
            <t:feedelement feed="feed" feedList="component:feedList"/>
        </li>
    </ul>
    <a t:type="PageLink" t:page="EditFeed" href="#">Create new Feed...</a>
</div>

I want to pass FeedList (template of which) into FeedElement. But my
example are wrong.

On Tue, Aug 18, 2009 at 04:33, Andrey Larionov<an...@gmail.com> wrote:
> Thanks. I'll try it.
>
> On Tue, Aug 18, 2009 at 04:20, Thiago H. de Paula
> Figueiredo<th...@gmail.com> wrote:
>> Em Mon, 17 Aug 2009 21:07:43 -0300, Andrey Larionov <an...@gmail.com>
>> escreveu:
>>
>>> As i understand, i should in first component create a field of type of
>>> second component and anotate this field as non required parameter?
>>
>> Yes.
>>
>>> How do i inject second component in first? From template? Or on class
>>> side?
>>
>> From template, you can pass a component to a component parameter:
>> t:parametername="component:componentId".
>> In a page or component class that uses the given component, @InjectComponent
>> private ComponentType component;
>>
>> --
>> 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
>>
>>
>

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


Re: How to create Master-Detail view

Posted by Andrey Larionov <an...@gmail.com>.
Thanks. I'll try it.

On Tue, Aug 18, 2009 at 04:20, Thiago H. de Paula
Figueiredo<th...@gmail.com> wrote:
> Em Mon, 17 Aug 2009 21:07:43 -0300, Andrey Larionov <an...@gmail.com>
> escreveu:
>
>> As i understand, i should in first component create a field of type of
>> second component and anotate this field as non required parameter?
>
> Yes.
>
>> How do i inject second component in first? From template? Or on class
>> side?
>
> From template, you can pass a component to a component parameter:
> t:parametername="component:componentId".
> In a page or component class that uses the given component, @InjectComponent
> private ComponentType component;
>
> --
> 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
>
>

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


Re: How to create Master-Detail view

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 17 Aug 2009 21:07:43 -0300, Andrey Larionov <an...@gmail.com>  
escreveu:

> As i understand, i should in first component create a field of type of
> second component and anotate this field as non required parameter?

Yes.

> How do i inject second component in first? From template? Or on class  
> side?

 From template, you can pass a component to a component parameter:  
t:parametername="component:componentId".
In a page or component class that uses the given component,  
@InjectComponent private ComponentType component;

-- 
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: How to create Master-Detail view

Posted by Andrey Larionov <an...@gmail.com>.
As i understand, i should in first component create a field of type of
second component and anotate this field as non required parameter?
How do i inject second component in first? From template? Or on class side?

On Tue, Aug 18, 2009 at 03:53, Thiago H. de Paula
Figueiredo<th...@gmail.com> wrote:
> Em Mon, 17 Aug 2009 20:44:55 -0300, Andrey Larionov <an...@gmail.com>
> escreveu:
>
>> By linking i mean next:
>> When i perform (for example) select action on first component, second
>> should get selected value and display corresponding changes. But if
>> one of components is absent, then components should work standalone
>> without interaction with each other.
>
> You could do that by:
>
> * Having the first component has a non-required parameter that is the linked
> component
> * Actions are handled by events. The first component, handling some event,
> would then invoke methods in the second component to change its state.
> Components (and pages too) are simple stateful objects, so they can interact
> with each other just by invoking methods.
> * Components (both or just the linked one) is rerendered.
>
> Better explained now? :) Most of the time, doing something in Tapestry is
> simpler than we think at first.
>
> --
> 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
>
>

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


Re: How to create Master-Detail view

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 17 Aug 2009 20:44:55 -0300, Andrey Larionov <an...@gmail.com>  
escreveu:

> By linking i mean next:
> When i perform (for example) select action on first component, second
> should get selected value and display corresponding changes. But if
> one of components is absent, then components should work standalone
> without interaction with each other.

You could do that by:

* Having the first component has a non-required parameter that is the  
linked component
* Actions are handled by events. The first component, handling some event,  
would then invoke methods in the second component to change its state.  
Components (and pages too) are simple stateful objects, so they can  
interact with each other just by invoking methods.
* Components (both or just the linked one) is rerendered.

Better explained now? :) Most of the time, doing something in Tapestry is  
simpler than we think at first.

-- 
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: How to create Master-Detail view

Posted by Andrey Larionov <an...@gmail.com>.
By linking i mean next:
When i perform (for example) select action on first component, second
should get selected value and display corresponding changes. But if
one of components is absent, then components should work standalone
without interaction with each other.

On Tue, Aug 18, 2009 at 03:36, Thiago H. de Paula
Figueiredo<th...@gmail.com> wrote:
> Em Mon, 17 Aug 2009 20:05:41 -0300, Andrey Larionov <an...@gmail.com>
> escreveu:
>
>> By "component" i mean Tapestry component.
>
> Ok!
>
>> I try to understand how to place two components on page.
>
> Just declare them in the template.
>
>> And make they optionaly linked.
>
> What do you mean by linked in this scenario?
>
> Anyway, take a look here:
> http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/AjaxFormLoop.html.
> It provides a master/detail example.
>
> --
> 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
>
>

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


Re: How to create Master-Detail view

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 17 Aug 2009 20:05:41 -0300, Andrey Larionov <an...@gmail.com>  
escreveu:

> By "component" i mean Tapestry component.

Ok!

> I try to understand how to place two components on page.

Just declare them in the template.

> And make they optionaly linked.

What do you mean by linked in this scenario?

Anyway, take a look here:  
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/AjaxFormLoop.html.  
It provides a master/detail example.

-- 
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: How to create Master-Detail view

Posted by Andrey Larionov <an...@gmail.com>.
By "component" i mean Tapestry component. I try to understand how to
place two components on page. And make they optionaly linked.

On Tue, Aug 18, 2009 at 02:02, Thiago H. de Paula
Figueiredo<th...@gmail.com> wrote:
> Em Mon, 17 Aug 2009 18:33:36 -0300, Andrey Larionov <an...@gmail.com>
> escreveu:
>
>> Actualy not. It's only a tools.
>
> But they're tools that make the task of implementing a master/detail form
> easier. ;)
> Solution outline:
>
> * Create a Zone in your template with a Form inside it to edit the detail
> object.
> * Create one EventLink for each object. Don't forget to set their context
> parameter with the object id and the zone parameter.
> * In the method that handles the EventLink, set the object that is edited by
> the form above.
>
>> I'm asking advice on how to decompose and interact between two components.
>
> What are you calling a component here? Anyway, your question is quite vague.
> Components interact with each other by parameters, triggering events or
> through an environmental variable.
>
> --
> 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
>
>

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


Re: How to create Master-Detail view

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 17 Aug 2009 18:33:36 -0300, Andrey Larionov <an...@gmail.com>  
escreveu:

> Actualy not. It's only a tools.

But they're tools that make the task of implementing a master/detail form  
easier. ;)
Solution outline:

* Create a Zone in your template with a Form inside it to edit the detail  
object.
* Create one EventLink for each object. Don't forget to set their context  
parameter with the object id and the zone parameter.
* In the method that handles the EventLink, set the object that is edited  
by the form above.

> I'm asking advice on how to decompose and interact between two  
> components.

What are you calling a component here? Anyway, your question is quite  
vague.
Components interact with each other by parameters, triggering events or  
through an environmental variable.

-- 
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: How to create Master-Detail view

Posted by Andrey Larionov <an...@gmail.com>.
Actualy not. It's only a tools. I'm asking advice on how to decompose
and interact between two components.
There is an explanation of this UI pattern
http://en.wikipedia.org/wiki/Master-detail

On Tue, Aug 18, 2009 at 01:07, Juan E. Maya<ma...@gmail.com> wrote:
> if i understand u. Maybe what u need is just a
> ActionLink or EventLink that updates a zone containing the details.

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


Re: How to create Master-Detail view

Posted by "Juan E. Maya" <ma...@gmail.com>.
I am not sure if i understand u. Maybe what u need is just a
ActionLink or EventLink that updates a zone containing the details.

U can see examples here:
http://jumpstart.doublenegative.com.au:8080/jumpstart/examples/javascript/ajax

or here:
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/ActionLink.html



On Mon, Aug 17, 2009 at 10:55 PM, Andrey Larionov<an...@gmail.com> wrote:
> Hi, everyone
> I start to explore world of Tapestry 5. It so exciting. But at first
> time is very difficult to find simple elegant (maybe pattern-like)
> solution. And i want to ask, can any point or give advice on creating
> Master-Detail presentation. I want to have two independent component
> but with posibility to link. Selecting element in one is display
> coresponding subset of data in another. But also i want to use it
> independent (especialy Master view) for managing Master datasource.
>
> 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