You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Everton Agner <ev...@yahoo.com.br> on 2009/11/25 14:36:47 UTC

Change Event on Select Component

Hi,

Which is the simplier way to capture the "onChange" event of a Select component and treat it in the page Class on the appropriate Event Handler? My goal is to create a Component that renders a Select component to locale switching.

I only could do that (in another situation) using the "ZoneUpdater" mixin in the Select... And I found that i could do it with the "OnEvent" mixin of Chenille... But I can't do it without the mixins?

Thanks!

Everton



      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

Re: Change Event on Select Component

Posted by Inge Solvoll <in...@gmail.com>.
See this post for something to base your own implementation on.

http://tinybits.blogspot.com/2009/05/simple-onevent-mixin.html

On Wed, Nov 25, 2009 at 7:32 PM, Everton Agner
<ev...@yahoo.com.br>wrote:

> For this situation, that would be a workaround...
>
> I think I'll add ChenilleKit core dependency to the project (and later for
> the Library) and use the OnEvent mixin for properly handling Change event on
> Select components...
>
> Thanks!
>
> Everton
>
>
>
>
> ________________________________
> De: Ilya Obshadko <il...@gmail.com>
> Para: Tapestry users <us...@tapestry.apache.org>
> Enviadas: Quarta-feira, 25 de Novembro de 2009 15:35:03
> Assunto: Re: Change Event on Select Component
>
> You need to simluate submit button click, so you could clearly separate
> form
> events.
>
> A few days before I posted complete mixin code for similar issue.
> If you cannot find it in archives, let me know - I could send the source.
>
> On Wed, Nov 25, 2009 at 8:08 PM, Everton Agner
> <ev...@yahoo.com.br>wrote:
>
> > Thanks for the answers.
> >
> > I thought I could do it without forcing form submission, like I said with
> > the "onChange" manipulation in the page Class (that i think it uses
> Ajax).
> >
> > The form submission that you said works fine, but I have a problem.
> >
> > Like I said, I'm creating a component that renders this Select component
> > for Locale Changing. I'll show a bit of the code for Login page, Layout
> > component and LocaleSwitcher component so I can explain the problem after
> > it.
> >
> > - Layout component (Template)
> >
> > <html ...>
> >    ...
> >    <t:localeSwitcher />
> >    ...
> >    <t:body />
> >    ...
> > </html>
> >
> > - Login page (Template)
> >
> > <t:layout ...>
> >    <t:form t:id="loginForm">
> >        ...
> >    </t:form>
> > </t:layout>
> >
> > - Login page (Class)
> >
> > @Component
> > private Form loginForm;
> >
> > void onValidateForm(){
> >    ...
> > }
> >
> > - LocaleSwitcher component (Template)
> >
> > <t:form t:id="localeSwitcherForm" ...>
> >    <t:select t:id="locales" model="locales" value="locale"
> > onChange="this.form.submit()" />
> > </t:form>
> >
> > - LocaleSwitcher component (Class)
> >
> >
> > @Component
> > private Form localeSwitcherForm;
> >
> > void onValidateFormFromLocaleSwitcherForm(){
> >    ...
> > }
> >
> > ---
> >
> > So, when i fire the onChange() event of the Select component, the
> > localeSwitcherForm is submitted, and the
> > onValidateFormFromLocaleSwitcherForm() method is called in the component
> > Class. After that, because my Login page Class has a generic
> > onValidateForm() method, it is also fired too, and then weird things
> > happens.
> >
> > So, i always need to implement specific submission lifecycle methods for
> my
> > Forms in every new Page I create (because the Page is inside the Layout
> that
> > renders my LocaleSwitcher component).
> >
> > And if I want to package this component in a Library, this will happen
> with
> > anyone that tries to use id, and it will be confused for them.
> >
> > I hope I could explain this problem clearly...
> >
> > And again, if there is another way I could treat the "change" Event of my
> > Select Component without this form submission, this new problem would be
> > avoided...
> >
> > Thanks!
> >
> > Everton
> >
> >
> >
> > ________________________________
> > De: Bryan Lewis <jb...@gmail.com>
> > Para: Tapestry users <us...@tapestry.apache.org>
> > Enviadas: Quarta-feira, 25 de Novembro de 2009 13:14:47
> > Assunto: Re: Change Event on Select Component
> >
> > It's on page 225 of my paper copy.   A simple bit of javascript:
> >
> >  <t:select value="selectedLocale" ... onchange="this.form.submit()"/>
> >
> >
> >
> > On Wed, Nov 25, 2009 at 9:49 AM, Jim O'Callaghan <jc1000001@yahoo.co.uk
> > >wrote:
> >
> > > Hi,
> > >
> > > I had a requirement to do this previously and used the example provided
> > in
> > > Tapestry 5: Building Web Applications, around page 281 - the book (or
> at
> > > least excerpts) is available on the net I think if you Google - no
> point
> > in
> > > me pasting a code example, as my code is heavily customised.  Hope this
> > > helps.
> > >
> > > Regards,
> > > Jim.
> > >
> > > -----Original Message-----
> > > From: Everton Agner [mailto:everton_agner@yahoo.com.br]
> > > Sent: 25 November 2009 13:37
> > > To: Tapestry Users
> > > Subject: Change Event on Select Component
> > >
> > >
> > > Hi,
> > >
> > > Which is the simplier way to capture the "onChange" event of a Select
> > > component and treat it in the page Class on the appropriate Event
> > Handler?
> > > My goal is to create a Component that renders a Select component to
> > locale
> > > switching.
> > >
> > > I only could do that (in another situation) using the "ZoneUpdater"
> mixin
> > > in
> > > the Select... And I found that i could do it with the "OnEvent" mixin
> of
> > > Chenille... But I can't do it without the mixins?
> > >
> > > Thanks!
> > >
> > > Everton
> > >
> > >
> > >
> > >
> >  ______________________________________________________________________
> > > ______________
> > > Veja quais são os assuntos do momento no Yahoo! +Buscados
> > > http://br.maisbuscados.yahoo.com
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> >
> >
> >
>  ____________________________________________________________________________________
> > Veja quais são os assuntos do momento no Yahoo! +Buscados
> > http://br.maisbuscados.yahoo.com
> >
>
>
>
> --
> Ilya Obshadko
>
>
>
>
>  ____________________________________________________________________________________
> Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbuscados.yahoo.com
>

Res: Change Event on Select Component

Posted by Everton Agner <ev...@yahoo.com.br>.
For this situation, that would be a workaround... 

I think I'll add ChenilleKit core dependency to the project (and later for the Library) and use the OnEvent mixin for properly handling Change event on Select components...

Thanks!

Everton




________________________________
De: Ilya Obshadko <il...@gmail.com>
Para: Tapestry users <us...@tapestry.apache.org>
Enviadas: Quarta-feira, 25 de Novembro de 2009 15:35:03
Assunto: Re: Change Event on Select Component

You need to simluate submit button click, so you could clearly separate form
events.

A few days before I posted complete mixin code for similar issue.
If you cannot find it in archives, let me know - I could send the source.

On Wed, Nov 25, 2009 at 8:08 PM, Everton Agner
<ev...@yahoo.com.br>wrote:

> Thanks for the answers.
>
> I thought I could do it without forcing form submission, like I said with
> the "onChange" manipulation in the page Class (that i think it uses Ajax).
>
> The form submission that you said works fine, but I have a problem.
>
> Like I said, I'm creating a component that renders this Select component
> for Locale Changing. I'll show a bit of the code for Login page, Layout
> component and LocaleSwitcher component so I can explain the problem after
> it.
>
> - Layout component (Template)
>
> <html ...>
>    ...
>    <t:localeSwitcher />
>    ...
>    <t:body />
>    ...
> </html>
>
> - Login page (Template)
>
> <t:layout ...>
>    <t:form t:id="loginForm">
>        ...
>    </t:form>
> </t:layout>
>
> - Login page (Class)
>
> @Component
> private Form loginForm;
>
> void onValidateForm(){
>    ...
> }
>
> - LocaleSwitcher component (Template)
>
> <t:form t:id="localeSwitcherForm" ...>
>    <t:select t:id="locales" model="locales" value="locale"
> onChange="this.form.submit()" />
> </t:form>
>
> - LocaleSwitcher component (Class)
>
>
> @Component
> private Form localeSwitcherForm;
>
> void onValidateFormFromLocaleSwitcherForm(){
>    ...
> }
>
> ---
>
> So, when i fire the onChange() event of the Select component, the
> localeSwitcherForm is submitted, and the
> onValidateFormFromLocaleSwitcherForm() method is called in the component
> Class. After that, because my Login page Class has a generic
> onValidateForm() method, it is also fired too, and then weird things
> happens.
>
> So, i always need to implement specific submission lifecycle methods for my
> Forms in every new Page I create (because the Page is inside the Layout that
> renders my LocaleSwitcher component).
>
> And if I want to package this component in a Library, this will happen with
> anyone that tries to use id, and it will be confused for them.
>
> I hope I could explain this problem clearly...
>
> And again, if there is another way I could treat the "change" Event of my
> Select Component without this form submission, this new problem would be
> avoided...
>
> Thanks!
>
> Everton
>
>
>
> ________________________________
> De: Bryan Lewis <jb...@gmail.com>
> Para: Tapestry users <us...@tapestry.apache.org>
> Enviadas: Quarta-feira, 25 de Novembro de 2009 13:14:47
> Assunto: Re: Change Event on Select Component
>
> It's on page 225 of my paper copy.   A simple bit of javascript:
>
>  <t:select value="selectedLocale" ... onchange="this.form.submit()"/>
>
>
>
> On Wed, Nov 25, 2009 at 9:49 AM, Jim O'Callaghan <jc1000001@yahoo.co.uk
> >wrote:
>
> > Hi,
> >
> > I had a requirement to do this previously and used the example provided
> in
> > Tapestry 5: Building Web Applications, around page 281 - the book (or at
> > least excerpts) is available on the net I think if you Google - no point
> in
> > me pasting a code example, as my code is heavily customised.  Hope this
> > helps.
> >
> > Regards,
> > Jim.
> >
> > -----Original Message-----
> > From: Everton Agner [mailto:everton_agner@yahoo.com.br]
> > Sent: 25 November 2009 13:37
> > To: Tapestry Users
> > Subject: Change Event on Select Component
> >
> >
> > Hi,
> >
> > Which is the simplier way to capture the "onChange" event of a Select
> > component and treat it in the page Class on the appropriate Event
> Handler?
> > My goal is to create a Component that renders a Select component to
> locale
> > switching.
> >
> > I only could do that (in another situation) using the "ZoneUpdater" mixin
> > in
> > the Select... And I found that i could do it with the "OnEvent" mixin of
> > Chenille... But I can't do it without the mixins?
> >
> > Thanks!
> >
> > Everton
> >
> >
> >
> >
>  ______________________________________________________________________
> > ______________
> > Veja quais são os assuntos do momento no Yahoo! +Buscados
> > http://br.maisbuscados.yahoo.com
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
>
>  ____________________________________________________________________________________
> Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbuscados.yahoo.com
>



-- 
Ilya Obshadko



      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

Re: Change Event on Select Component

Posted by Ilya Obshadko <il...@gmail.com>.
You need to simluate submit button click, so you could clearly separate form
events.

A few days before I posted complete mixin code for similar issue.
If you cannot find it in archives, let me know - I could send the source.

On Wed, Nov 25, 2009 at 8:08 PM, Everton Agner
<ev...@yahoo.com.br>wrote:

> Thanks for the answers.
>
> I thought I could do it without forcing form submission, like I said with
> the "onChange" manipulation in the page Class (that i think it uses Ajax).
>
> The form submission that you said works fine, but I have a problem.
>
> Like I said, I'm creating a component that renders this Select component
> for Locale Changing. I'll show a bit of the code for Login page, Layout
> component and LocaleSwitcher component so I can explain the problem after
> it.
>
> - Layout component (Template)
>
> <html ...>
>    ...
>    <t:localeSwitcher />
>    ...
>    <t:body />
>    ...
> </html>
>
> - Login page (Template)
>
> <t:layout ...>
>    <t:form t:id="loginForm">
>        ...
>    </t:form>
> </t:layout>
>
> - Login page (Class)
>
> @Component
> private Form loginForm;
>
> void onValidateForm(){
>    ...
> }
>
> - LocaleSwitcher component (Template)
>
> <t:form t:id="localeSwitcherForm" ...>
>    <t:select t:id="locales" model="locales" value="locale"
> onChange="this.form.submit()" />
> </t:form>
>
> - LocaleSwitcher component (Class)
>
>
> @Component
> private Form localeSwitcherForm;
>
> void onValidateFormFromLocaleSwitcherForm(){
>    ...
> }
>
> ---
>
> So, when i fire the onChange() event of the Select component, the
> localeSwitcherForm is submitted, and the
> onValidateFormFromLocaleSwitcherForm() method is called in the component
> Class. After that, because my Login page Class has a generic
> onValidateForm() method, it is also fired too, and then weird things
> happens.
>
> So, i always need to implement specific submission lifecycle methods for my
> Forms in every new Page I create (because the Page is inside the Layout that
> renders my LocaleSwitcher component).
>
> And if I want to package this component in a Library, this will happen with
> anyone that tries to use id, and it will be confused for them.
>
> I hope I could explain this problem clearly...
>
> And again, if there is another way I could treat the "change" Event of my
> Select Component without this form submission, this new problem would be
> avoided...
>
> Thanks!
>
> Everton
>
>
>
> ________________________________
> De: Bryan Lewis <jb...@gmail.com>
> Para: Tapestry users <us...@tapestry.apache.org>
> Enviadas: Quarta-feira, 25 de Novembro de 2009 13:14:47
> Assunto: Re: Change Event on Select Component
>
> It's on page 225 of my paper copy.   A simple bit of javascript:
>
>  <t:select value="selectedLocale" ... onchange="this.form.submit()"/>
>
>
>
> On Wed, Nov 25, 2009 at 9:49 AM, Jim O'Callaghan <jc1000001@yahoo.co.uk
> >wrote:
>
> > Hi,
> >
> > I had a requirement to do this previously and used the example provided
> in
> > Tapestry 5: Building Web Applications, around page 281 - the book (or at
> > least excerpts) is available on the net I think if you Google - no point
> in
> > me pasting a code example, as my code is heavily customised.  Hope this
> > helps.
> >
> > Regards,
> > Jim.
> >
> > -----Original Message-----
> > From: Everton Agner [mailto:everton_agner@yahoo.com.br]
> > Sent: 25 November 2009 13:37
> > To: Tapestry Users
> > Subject: Change Event on Select Component
> >
> >
> > Hi,
> >
> > Which is the simplier way to capture the "onChange" event of a Select
> > component and treat it in the page Class on the appropriate Event
> Handler?
> > My goal is to create a Component that renders a Select component to
> locale
> > switching.
> >
> > I only could do that (in another situation) using the "ZoneUpdater" mixin
> > in
> > the Select... And I found that i could do it with the "OnEvent" mixin of
> > Chenille... But I can't do it without the mixins?
> >
> > Thanks!
> >
> > Everton
> >
> >
> >
> >
>  ______________________________________________________________________
> > ______________
> > Veja quais são os assuntos do momento no Yahoo! +Buscados
> > http://br.maisbuscados.yahoo.com
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
>
>  ____________________________________________________________________________________
> Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbuscados.yahoo.com
>



-- 
Ilya Obshadko

Res: Change Event on Select Component

Posted by Everton Agner <ev...@yahoo.com.br>.
Thanks for the answers.

I thought I could do it without forcing form submission, like I said with the "onChange" manipulation in the page Class (that i think it uses Ajax).

The form submission that you said works fine, but I have a problem.

Like I said, I'm creating a component that renders this Select component for Locale Changing. I'll show a bit of the code for Login page, Layout component and LocaleSwitcher component so I can explain the problem after it.

- Layout component (Template)

<html ...>
    ...
    <t:localeSwitcher />
    ...
    <t:body />
    ...
</html>

- Login page (Template)

<t:layout ...>
    <t:form t:id="loginForm">
        ...
    </t:form>
</t:layout>

- Login page (Class)

@Component
private Form loginForm;

void onValidateForm(){
    ...
}

- LocaleSwitcher component (Template)

<t:form t:id="localeSwitcherForm" ...>
    <t:select t:id="locales" model="locales" value="locale" onChange="this.form.submit()" />
</t:form>

- LocaleSwitcher component (Class)


@Component
private Form localeSwitcherForm;

void onValidateFormFromLocaleSwitcherForm(){
    ...
}

---

So, when i fire the onChange() event of the Select component, the localeSwitcherForm is submitted, and the onValidateFormFromLocaleSwitcherForm() method is called in the component Class. After that, because my Login page Class has a generic onValidateForm() method, it is also fired too, and then weird things happens.

So, i always need to implement specific submission lifecycle methods for my Forms in every new Page I create (because the Page is inside the Layout that renders my LocaleSwitcher component).

And if I want to package this component in a Library, this will happen with anyone that tries to use id, and it will be confused for them.

I hope I could explain this problem clearly...

And again, if there is another way I could treat the "change" Event of my Select Component without this form submission, this new problem would be avoided...

Thanks!

Everton



________________________________
De: Bryan Lewis <jb...@gmail.com>
Para: Tapestry users <us...@tapestry.apache.org>
Enviadas: Quarta-feira, 25 de Novembro de 2009 13:14:47
Assunto: Re: Change Event on Select Component

It's on page 225 of my paper copy.   A simple bit of javascript:

  <t:select value="selectedLocale" ... onchange="this.form.submit()"/>



On Wed, Nov 25, 2009 at 9:49 AM, Jim O'Callaghan <jc...@yahoo.co.uk>wrote:

> Hi,
>
> I had a requirement to do this previously and used the example provided in
> Tapestry 5: Building Web Applications, around page 281 - the book (or at
> least excerpts) is available on the net I think if you Google - no point in
> me pasting a code example, as my code is heavily customised.  Hope this
> helps.
>
> Regards,
> Jim.
>
> -----Original Message-----
> From: Everton Agner [mailto:everton_agner@yahoo.com.br]
> Sent: 25 November 2009 13:37
> To: Tapestry Users
> Subject: Change Event on Select Component
>
>
> Hi,
>
> Which is the simplier way to capture the "onChange" event of a Select
> component and treat it in the page Class on the appropriate Event Handler?
> My goal is to create a Component that renders a Select component to locale
> switching.
>
> I only could do that (in another situation) using the "ZoneUpdater" mixin
> in
> the Select... And I found that i could do it with the "OnEvent" mixin of
> Chenille... But I can't do it without the mixins?
>
> Thanks!
>
> Everton
>
>
>
>      ______________________________________________________________________
> ______________
> Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbuscados.yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

Re: Change Event on Select Component

Posted by Bryan Lewis <jb...@gmail.com>.
It's on page 225 of my paper copy.   A simple bit of javascript:

  <t:select value="selectedLocale" ... onchange="this.form.submit()"/>



On Wed, Nov 25, 2009 at 9:49 AM, Jim O'Callaghan <jc...@yahoo.co.uk>wrote:

> Hi,
>
> I had a requirement to do this previously and used the example provided in
> Tapestry 5: Building Web Applications, around page 281 - the book (or at
> least excerpts) is available on the net I think if you Google - no point in
> me pasting a code example, as my code is heavily customised.  Hope this
> helps.
>
> Regards,
> Jim.
>
> -----Original Message-----
> From: Everton Agner [mailto:everton_agner@yahoo.com.br]
> Sent: 25 November 2009 13:37
> To: Tapestry Users
> Subject: Change Event on Select Component
>
>
> Hi,
>
> Which is the simplier way to capture the "onChange" event of a Select
> component and treat it in the page Class on the appropriate Event Handler?
> My goal is to create a Component that renders a Select component to locale
> switching.
>
> I only could do that (in another situation) using the "ZoneUpdater" mixin
> in
> the Select... And I found that i could do it with the "OnEvent" mixin of
> Chenille... But I can't do it without the mixins?
>
> Thanks!
>
> Everton
>
>
>
>      ______________________________________________________________________
> ______________
> Veja quais são os assuntos do momento no Yahoo! +Buscados
> http://br.maisbuscados.yahoo.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

RE: Change Event on Select Component

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Hi,

I had a requirement to do this previously and used the example provided in
Tapestry 5: Building Web Applications, around page 281 - the book (or at
least excerpts) is available on the net I think if you Google - no point in
me pasting a code example, as my code is heavily customised.  Hope this
helps.

Regards,
Jim.

-----Original Message-----
From: Everton Agner [mailto:everton_agner@yahoo.com.br]
Sent: 25 November 2009 13:37
To: Tapestry Users
Subject: Change Event on Select Component


Hi,

Which is the simplier way to capture the "onChange" event of a Select
component and treat it in the page Class on the appropriate Event Handler?
My goal is to create a Component that renders a Select component to locale
switching.

I only could do that (in another situation) using the "ZoneUpdater" mixin in
the Select... And I found that i could do it with the "OnEvent" mixin of
Chenille... But I can't do it without the mixins?

Thanks!

Everton



      ______________________________________________________________________
______________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com


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