Re: extending Select component
There is no need to extend the Select component for your use case. Just create an instance of EnumSelectModel [1] and pass it to the Select component. [1] http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/util/EnumSelectModel.html 2011/4/15 Keio Kraaner k.kraa...@gmail.com Hi I'm trying to extend Tapestry's Select component. My idea is to create EnumSelect class (class EnumSelect extends Select) that takes an Enum class as a parameter, and based on this creates SelectModel and ValueEncoder. Everything works fine, but each EnumSelect in a tml-file results in 2 rendered selects in output - at first Tapestry invokes render methods of EnumSelect and then Select. What should I do to get only 1 select in rendered output? Is it even possible to extend existing AbstarctField implementation? I do not see such an example in tapestry-core library. Regards Keio Kraaner - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Best regards, Igor Drobiazko http://tapestry5.de
Re: extending Select component
Thanks for the suggestion, Igor. I made up this use case just to keep it very simple. My real question is still the following: is it possible to extend Select (or any other tapestry-core component that extends AbstractField)? - Original Message - From: Igor Drobiazko igor.drobia...@gmail.com There is no need to extend the Select component for your use case. Just create an instance of EnumSelectModel [1] and pass it to the Select component. [1] http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/util/EnumSelectModel.html 2011/4/15 Keio Kraaner k.kraa...@gmail.com Hi I'm trying to extend Tapestry's Select component. My idea is to create EnumSelect class (class EnumSelect extends Select) that takes an Enum class as a parameter, and based on this creates SelectModel and ValueEncoder. Everything works fine, but each EnumSelect in a tml-file results in 2 rendered selects in output - at first Tapestry invokes render methods of EnumSelect and then Select. What should I do to get only 1 select in rendered output? Is it even possible to extend existing AbstarctField implementation? I do not see such an example in tapestry-core library. Regards Keio Kraaner - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Best regards, Igor Drobiazko http://tapestry5.de - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: extending Select component
Of course. Tapestry components are valid Java classes; you can extend any existing component. On Fri, Apr 15, 2011 at 11:43 AM, Keio Kraaner k.kraa...@gmail.com wrote: Thanks for the suggestion, Igor. I made up this use case just to keep it very simple. My real question is still the following: is it possible to extend Select (or any other tapestry-core component that extends AbstractField)? - Original Message - From: Igor Drobiazko igor.drobia...@gmail.com There is no need to extend the Select component for your use case. Just create an instance of EnumSelectModel [1] and pass it to the Select component. [1] http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/util/EnumSelectModel.html 2011/4/15 Keio Kraaner k.kraa...@gmail.com Hi I'm trying to extend Tapestry's Select component. My idea is to create EnumSelect class (class EnumSelect extends Select) that takes an Enum class as a parameter, and based on this creates SelectModel and ValueEncoder. Everything works fine, but each EnumSelect in a tml-file results in 2 rendered selects in output - at first Tapestry invokes render methods of EnumSelect and then Select. What should I do to get only 1 select in rendered output? Is it even possible to extend existing AbstarctField implementation? I do not see such an example in tapestry-core library. Regards Keio Kraaner - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Best regards, Igor Drobiazko http://tapestry5.de - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Best regards, Igor Drobiazko http://tapestry5.de
Re: extending Select component
And what about the weird behaviour which results when rendering a child of a Tapestry component? Of course. Tapestry components are valid Java classes; you can extend any existing component. On Fri, Apr 15, 2011 at 11:43 AM, Keio Kraaner k.kraa...@gmail.com wrote: Thanks for the suggestion, Igor. I made up this use case just to keep it very simple. My real question is still the following: is it possible to extend Select (or any other tapestry-core component that extends AbstractField)? - Original Message - From: Igor Drobiazko igor.drobia...@gmail.com There is no need to extend the Select component for your use case. Just create an instance of EnumSelectModel [1] and pass it to the Select component. [1] http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/util/EnumSelectModel.html 2011/4/15 Keio Kraaner k.kraa...@gmail.com Hi I'm trying to extend Tapestry's Select component. My idea is to create EnumSelect class (class EnumSelect extends Select) that takes an Enum class as a parameter, and based on this creates SelectModel and ValueEncoder. Everything works fine, but each EnumSelect in a tml-file results in 2 rendered selects in output - at first Tapestry invokes render methods of EnumSelect and then Select. What should I do to get only 1 select in rendered output? Is it even possible to extend existing AbstarctField implementation? I do not see such an example in tapestry-core library. Regards Keio Kraaner - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Best regards, Igor Drobiazko http://tapestry5.de - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Best regards, Igor Drobiazko http://tapestry5.de - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: extending Select component
On Fri, 15 Apr 2011 07:18:14 -0300, Keio Kraaner k.kraa...@gmail.com wrote: And what about the weird behaviour which results when rendering a child of a Tapestry component? Which weird behaviour? Any way, Tapestry-provided components are not meant to be subclassed. It is recommended to create mixins when possible. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: extending Select component
The weird behaviour is the following: eash subclass declaration in a tml-file results in 2 rendered fields in output - at first Tapestry renders subclass instance, which is correct, but after this it also renders the parent instance too, which is not needed. - Original Message - From: Thiago H. de Paula Figueiredo thiag...@gmail.com To: Tapestry users users@tapestry.apache.org Sent: Friday, April 15, 2011 2:54 PM Subject: Re: extending Select component On Fri, 15 Apr 2011 07:18:14 -0300, Keio Kraaner k.kraa...@gmail.com wrote: And what about the weird behaviour which results when rendering a child of a Tapestry component? Which weird behaviour? Any way, Tapestry-provided components are not meant to be subclassed. It is recommended to create mixins when possible. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: extending Select component
On Fri, 15 Apr 2011 10:38:10 -0300, Keio Kraaner k.kraa...@gmail.com wrote: The weird behaviour is the following: eash subclass declaration in a tml-file results in 2 rendered fields in output - at first Tapestry renders subclass instance, which is correct, but after this it also renders the parent instance too, which is not needed. Please post your component code and template. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: extending Select component
Any way, Tapestry-provided components are not meant to be subclassed. It is recommended to create mixins when possible. Or use composition (not inheritance) - that's usually a good advice in OOP. -- Chris - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org