You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ilya Obshadko <xf...@xfyre.com> on 2016/04/15 12:52:50 UTC

child component lookup

Is there any way to search for specific component down the component
hierarchy?

Consider the following use case:

- I have a component responsible for rendering Bootstrap modal
- this modal may (or may not) contain a form
- if modal contains a form and submission is successful, the modal should
be automatically dismissed
- it modal contains a form and submission is unsuccessful, the modal should
not close (regardless of client validation being on/off)

I've been looking around ComponentSource/ComponentResources classes, but
couldn't find anything relevant yet.

Environment service can't help either, because modal is a form's parent and
at the time of modal rendering FormSupport is not yet available.

-- 
Ilya Obshadko

Re: child component lookup

Posted by Ilya Obshadko <il...@gmail.com>.
Solved - I had to use @MixinAfter. Thanks everyone!

On Sat, Apr 16, 2016 at 9:14 AM, Ilya Obshadko <il...@gmail.com>
wrote:

> Well, this is actually quite straightforward approach. However I have
> encountered a problem that looks weird. This is my mixin code:
>
> *public* *class* ModalIntegration {
>
>     @InjectContainer
>
>     *private* Form form;
>
>
>     *void* afterRender ( MarkupWriter markupWriter ) {
>
>         markupWriter.attributes ( "data-submission-failed", form.getHasErrors
> () );
>
>     }
>
> }
>
> It's supposed to render an additional form attribute which modal JS later
> can use to determine if it should dismiss or not.
> Somehow this attribute is being rendered not on the form itself, as I
> naturally expected, but on the form's parent element (containing zone).
>
> Is there any explanation for that? I'm using 5.4-beta6.
>
>
> On Sat, Apr 16, 2016 at 1:08 AM, Thiago H de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
>
>> On Fri, 15 Apr 2016 17:34:03 -0300, Barry Books <tr...@gmail.com> wrote:
>>
>> yes
>>>
>>
>> Tapestry mixins may not be easy to understand at first, but when you do,
>> you realize how powerful they are, specially when combined with a class
>> transformation when you need to apply them to several component instances
>> at once. :)
>>
>>
>>
>>> On Friday, April 15, 2016, Ilya Obshadko <il...@gmail.com>
>>> wrote:
>>>
>>> Barry, thanks for your suggestion - I think this is what I need.
>>>>
>>>> Do you mean an implementation of ComponentClassTransformWorker2?
>>>>
>>>> On Fri, Apr 15, 2016 at 2:12 PM, Barry Books <trsvax@gmail.com
>>>> <javascript:;>> wrote:
>>>>
>>>> > I'm not exactly sure I understand the requirements but I think you
>>>> could
>>>> do
>>>> > this with a mixin on the form. At the very least this would allow
>>>> > communication with the form mixin and the modal via the Environment
>>>> > service. The modal could put something in the environment and the
>>>> mixin
>>>> > could add some status. No status means no form. The mixin could be
>>>> applied
>>>> > to all forms via a worker.
>>>> >
>>>> > On Friday, April 15, 2016, Ilya Obshadko <xfyre@xfyre.com
>>>> <javascript:;>>
>>>> wrote:
>>>> >
>>>> > > Is there any way to search for specific component down the component
>>>> > > hierarchy?
>>>> > >
>>>> > > Consider the following use case:
>>>> > >
>>>> > > - I have a component responsible for rendering Bootstrap modal
>>>> > > - this modal may (or may not) contain a form
>>>> > > - if modal contains a form and submission is successful, the modal
>>>> should
>>>> > > be automatically dismissed
>>>> > > - it modal contains a form and submission is unsuccessful, the modal
>>>> > should
>>>> > > not close (regardless of client validation being on/off)
>>>> > >
>>>> > > I've been looking around ComponentSource/ComponentResources classes,
>>>> but
>>>> > > couldn't find anything relevant yet.
>>>> > >
>>>> > > Environment service can't help either, because modal is a form's
>>>> parent
>>>> > and
>>>> > > at the time of modal rendering FormSupport is not yet available.
>>>> > >
>>>> > > --
>>>> > > Ilya Obshadko
>>>> > >
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Ilya Obshadko
>>>>
>>>>
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> --
> Ilya Obshadko
>
>


-- 
Ilya Obshadko

Re: child component lookup

Posted by Ilya Obshadko <il...@gmail.com>.
Well, this is actually quite straightforward approach. However I have
encountered a problem that looks weird. This is my mixin code:

*public* *class* ModalIntegration {

    @InjectContainer

    *private* Form form;


    *void* afterRender ( MarkupWriter markupWriter ) {

        markupWriter.attributes ( "data-submission-failed", form.getHasErrors
() );

    }

}

It's supposed to render an additional form attribute which modal JS later
can use to determine if it should dismiss or not.
Somehow this attribute is being rendered not on the form itself, as I
naturally expected, but on the form's parent element (containing zone).

Is there any explanation for that? I'm using 5.4-beta6.


On Sat, Apr 16, 2016 at 1:08 AM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Fri, 15 Apr 2016 17:34:03 -0300, Barry Books <tr...@gmail.com> wrote:
>
> yes
>>
>
> Tapestry mixins may not be easy to understand at first, but when you do,
> you realize how powerful they are, specially when combined with a class
> transformation when you need to apply them to several component instances
> at once. :)
>
>
>
>> On Friday, April 15, 2016, Ilya Obshadko <il...@gmail.com> wrote:
>>
>> Barry, thanks for your suggestion - I think this is what I need.
>>>
>>> Do you mean an implementation of ComponentClassTransformWorker2?
>>>
>>> On Fri, Apr 15, 2016 at 2:12 PM, Barry Books <trsvax@gmail.com
>>> <javascript:;>> wrote:
>>>
>>> > I'm not exactly sure I understand the requirements but I think you
>>> could
>>> do
>>> > this with a mixin on the form. At the very least this would allow
>>> > communication with the form mixin and the modal via the Environment
>>> > service. The modal could put something in the environment and the mixin
>>> > could add some status. No status means no form. The mixin could be
>>> applied
>>> > to all forms via a worker.
>>> >
>>> > On Friday, April 15, 2016, Ilya Obshadko <xfyre@xfyre.com
>>> <javascript:;>>
>>> wrote:
>>> >
>>> > > Is there any way to search for specific component down the component
>>> > > hierarchy?
>>> > >
>>> > > Consider the following use case:
>>> > >
>>> > > - I have a component responsible for rendering Bootstrap modal
>>> > > - this modal may (or may not) contain a form
>>> > > - if modal contains a form and submission is successful, the modal
>>> should
>>> > > be automatically dismissed
>>> > > - it modal contains a form and submission is unsuccessful, the modal
>>> > should
>>> > > not close (regardless of client validation being on/off)
>>> > >
>>> > > I've been looking around ComponentSource/ComponentResources classes,
>>> but
>>> > > couldn't find anything relevant yet.
>>> > >
>>> > > Environment service can't help either, because modal is a form's
>>> parent
>>> > and
>>> > > at the time of modal rendering FormSupport is not yet available.
>>> > >
>>> > > --
>>> > > Ilya Obshadko
>>> > >
>>> >
>>>
>>>
>>>
>>> --
>>> Ilya Obshadko
>>>
>>>
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Ilya Obshadko

Re: child component lookup

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 15 Apr 2016 17:34:03 -0300, Barry Books <tr...@gmail.com> wrote:

> yes

Tapestry mixins may not be easy to understand at first, but when you do,  
you realize how powerful they are, specially when combined with a class  
transformation when you need to apply them to several component instances  
at once. :)

>
> On Friday, April 15, 2016, Ilya Obshadko <il...@gmail.com> wrote:
>
>> Barry, thanks for your suggestion - I think this is what I need.
>>
>> Do you mean an implementation of ComponentClassTransformWorker2?
>>
>> On Fri, Apr 15, 2016 at 2:12 PM, Barry Books <trsvax@gmail.com
>> <javascript:;>> wrote:
>>
>> > I'm not exactly sure I understand the requirements but I think you  
>> could
>> do
>> > this with a mixin on the form. At the very least this would allow
>> > communication with the form mixin and the modal via the Environment
>> > service. The modal could put something in the environment and the  
>> mixin
>> > could add some status. No status means no form. The mixin could be
>> applied
>> > to all forms via a worker.
>> >
>> > On Friday, April 15, 2016, Ilya Obshadko <xfyre@xfyre.com  
>> <javascript:;>>
>> wrote:
>> >
>> > > Is there any way to search for specific component down the component
>> > > hierarchy?
>> > >
>> > > Consider the following use case:
>> > >
>> > > - I have a component responsible for rendering Bootstrap modal
>> > > - this modal may (or may not) contain a form
>> > > - if modal contains a form and submission is successful, the modal
>> should
>> > > be automatically dismissed
>> > > - it modal contains a form and submission is unsuccessful, the modal
>> > should
>> > > not close (regardless of client validation being on/off)
>> > >
>> > > I've been looking around ComponentSource/ComponentResources classes,
>> but
>> > > couldn't find anything relevant yet.
>> > >
>> > > Environment service can't help either, because modal is a form's  
>> parent
>> > and
>> > > at the time of modal rendering FormSupport is not yet available.
>> > >
>> > > --
>> > > Ilya Obshadko
>> > >
>> >
>>
>>
>>
>> --
>> Ilya Obshadko
>>


-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: child component lookup

Posted by Barry Books <tr...@gmail.com>.
yes

On Friday, April 15, 2016, Ilya Obshadko <il...@gmail.com> wrote:

> Barry, thanks for your suggestion - I think this is what I need.
>
> Do you mean an implementation of ComponentClassTransformWorker2?
>
> On Fri, Apr 15, 2016 at 2:12 PM, Barry Books <trsvax@gmail.com
> <javascript:;>> wrote:
>
> > I'm not exactly sure I understand the requirements but I think you could
> do
> > this with a mixin on the form. At the very least this would allow
> > communication with the form mixin and the modal via the Environment
> > service. The modal could put something in the environment and the mixin
> > could add some status. No status means no form. The mixin could be
> applied
> > to all forms via a worker.
> >
> > On Friday, April 15, 2016, Ilya Obshadko <xfyre@xfyre.com <javascript:;>>
> wrote:
> >
> > > Is there any way to search for specific component down the component
> > > hierarchy?
> > >
> > > Consider the following use case:
> > >
> > > - I have a component responsible for rendering Bootstrap modal
> > > - this modal may (or may not) contain a form
> > > - if modal contains a form and submission is successful, the modal
> should
> > > be automatically dismissed
> > > - it modal contains a form and submission is unsuccessful, the modal
> > should
> > > not close (regardless of client validation being on/off)
> > >
> > > I've been looking around ComponentSource/ComponentResources classes,
> but
> > > couldn't find anything relevant yet.
> > >
> > > Environment service can't help either, because modal is a form's parent
> > and
> > > at the time of modal rendering FormSupport is not yet available.
> > >
> > > --
> > > Ilya Obshadko
> > >
> >
>
>
>
> --
> Ilya Obshadko
>

Re: child component lookup

Posted by Ilya Obshadko <il...@gmail.com>.
Pavel, thanks!

My point is to handle this on modal level: this should be completely
transparent for the form itself.

On Fri, Apr 15, 2016 at 2:33 PM, Pavel Chernyak <fj...@fjfalcon.ru>
wrote:

> Ilya, greetings.
>
> As for submit button i search inside modal body for form component or
> specify form name in modal component.
> So, after clicking button form submits.
> Onsuccess i invoke hideModal function(via hidemodal event).
> OnFailure i do nothing except updating formzone to show messages/errors
> e.t.c.
> If you want i can send you some examples.
>
>
> On 15 April 2016 at 14:27, Ilya Obshadko <il...@gmail.com> wrote:
>
> > Barry, thanks for your suggestion - I think this is what I need.
> >
> > Do you mean an implementation of ComponentClassTransformWorker2?
> >
> > On Fri, Apr 15, 2016 at 2:12 PM, Barry Books <tr...@gmail.com> wrote:
> >
> > > I'm not exactly sure I understand the requirements but I think you
> could
> > do
> > > this with a mixin on the form. At the very least this would allow
> > > communication with the form mixin and the modal via the Environment
> > > service. The modal could put something in the environment and the mixin
> > > could add some status. No status means no form. The mixin could be
> > applied
> > > to all forms via a worker.
> > >
> > > On Friday, April 15, 2016, Ilya Obshadko <xf...@xfyre.com> wrote:
> > >
> > > > Is there any way to search for specific component down the component
> > > > hierarchy?
> > > >
> > > > Consider the following use case:
> > > >
> > > > - I have a component responsible for rendering Bootstrap modal
> > > > - this modal may (or may not) contain a form
> > > > - if modal contains a form and submission is successful, the modal
> > should
> > > > be automatically dismissed
> > > > - it modal contains a form and submission is unsuccessful, the modal
> > > should
> > > > not close (regardless of client validation being on/off)
> > > >
> > > > I've been looking around ComponentSource/ComponentResources classes,
> > but
> > > > couldn't find anything relevant yet.
> > > >
> > > > Environment service can't help either, because modal is a form's
> parent
> > > and
> > > > at the time of modal rendering FormSupport is not yet available.
> > > >
> > > > --
> > > > Ilya Obshadko
> > > >
> > >
> >
> >
> >
> > --
> > Ilya Obshadko
> >
>
>
>
> --
> С уважением,
> Черняк Павел Александрович
>



-- 
Ilya Obshadko

Re: child component lookup

Posted by Pavel Chernyak <fj...@fjfalcon.ru>.
Ilya, greetings.

As for submit button i search inside modal body for form component or
specify form name in modal component.
So, after clicking button form submits.
Onsuccess i invoke hideModal function(via hidemodal event).
OnFailure i do nothing except updating formzone to show messages/errors
e.t.c.
If you want i can send you some examples.


On 15 April 2016 at 14:27, Ilya Obshadko <il...@gmail.com> wrote:

> Barry, thanks for your suggestion - I think this is what I need.
>
> Do you mean an implementation of ComponentClassTransformWorker2?
>
> On Fri, Apr 15, 2016 at 2:12 PM, Barry Books <tr...@gmail.com> wrote:
>
> > I'm not exactly sure I understand the requirements but I think you could
> do
> > this with a mixin on the form. At the very least this would allow
> > communication with the form mixin and the modal via the Environment
> > service. The modal could put something in the environment and the mixin
> > could add some status. No status means no form. The mixin could be
> applied
> > to all forms via a worker.
> >
> > On Friday, April 15, 2016, Ilya Obshadko <xf...@xfyre.com> wrote:
> >
> > > Is there any way to search for specific component down the component
> > > hierarchy?
> > >
> > > Consider the following use case:
> > >
> > > - I have a component responsible for rendering Bootstrap modal
> > > - this modal may (or may not) contain a form
> > > - if modal contains a form and submission is successful, the modal
> should
> > > be automatically dismissed
> > > - it modal contains a form and submission is unsuccessful, the modal
> > should
> > > not close (regardless of client validation being on/off)
> > >
> > > I've been looking around ComponentSource/ComponentResources classes,
> but
> > > couldn't find anything relevant yet.
> > >
> > > Environment service can't help either, because modal is a form's parent
> > and
> > > at the time of modal rendering FormSupport is not yet available.
> > >
> > > --
> > > Ilya Obshadko
> > >
> >
>
>
>
> --
> Ilya Obshadko
>



-- 
С уважением,
Черняк Павел Александрович

Re: child component lookup

Posted by Ilya Obshadko <il...@gmail.com>.
Barry, thanks for your suggestion - I think this is what I need.

Do you mean an implementation of ComponentClassTransformWorker2?

On Fri, Apr 15, 2016 at 2:12 PM, Barry Books <tr...@gmail.com> wrote:

> I'm not exactly sure I understand the requirements but I think you could do
> this with a mixin on the form. At the very least this would allow
> communication with the form mixin and the modal via the Environment
> service. The modal could put something in the environment and the mixin
> could add some status. No status means no form. The mixin could be applied
> to all forms via a worker.
>
> On Friday, April 15, 2016, Ilya Obshadko <xf...@xfyre.com> wrote:
>
> > Is there any way to search for specific component down the component
> > hierarchy?
> >
> > Consider the following use case:
> >
> > - I have a component responsible for rendering Bootstrap modal
> > - this modal may (or may not) contain a form
> > - if modal contains a form and submission is successful, the modal should
> > be automatically dismissed
> > - it modal contains a form and submission is unsuccessful, the modal
> should
> > not close (regardless of client validation being on/off)
> >
> > I've been looking around ComponentSource/ComponentResources classes, but
> > couldn't find anything relevant yet.
> >
> > Environment service can't help either, because modal is a form's parent
> and
> > at the time of modal rendering FormSupport is not yet available.
> >
> > --
> > Ilya Obshadko
> >
>



-- 
Ilya Obshadko

Re: child component lookup

Posted by Barry Books <tr...@gmail.com>.
I'm not exactly sure I understand the requirements but I think you could do
this with a mixin on the form. At the very least this would allow
communication with the form mixin and the modal via the Environment
service. The modal could put something in the environment and the mixin
could add some status. No status means no form. The mixin could be applied
to all forms via a worker.

On Friday, April 15, 2016, Ilya Obshadko <xf...@xfyre.com> wrote:

> Is there any way to search for specific component down the component
> hierarchy?
>
> Consider the following use case:
>
> - I have a component responsible for rendering Bootstrap modal
> - this modal may (or may not) contain a form
> - if modal contains a form and submission is successful, the modal should
> be automatically dismissed
> - it modal contains a form and submission is unsuccessful, the modal should
> not close (regardless of client validation being on/off)
>
> I've been looking around ComponentSource/ComponentResources classes, but
> couldn't find anything relevant yet.
>
> Environment service can't help either, because modal is a form's parent and
> at the time of modal rendering FormSupport is not yet available.
>
> --
> Ilya Obshadko
>