Binding property of a component

View: New views
2 Messages — Rating Filter:   Alert me  

Binding property of a component

by Daniele Dellafiore :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all. My problem is simple: I want to bind a given property (say:
'enabled', or 'visible') of a component to a variable that is on
another object, just like I bind the text value of a TextField with a
String on onother object.

This is becouse I do not like this code:

      Button button =  new Button("save") {
         @Override
         public boolean isEnabled() {
            return isEditEnabled();
         }
      };

where isEditEnabled() is a method of the parent Page.
I would like to write something like:

bind(button, "enabled", "editEnabled")

and put that bind(Component, String, String) method on the page, or on
a static class, doesn't matter.

there is a preferred way to achieve this? A way that involves the use
of the wicket models to bind properties...

Thanks.

--
Daniele Dellafiore
http://blog.ildella.net/

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


Re: Binding property of a component

by Mr Mean :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry, there is nothing currently in wicket that does what you want.
PropertyModel might get you there partially but you would still need
to hack a lot to get it working the way you want.
Maybe there is an external library that does what you want, i don't
know. But whatever solution you eventually come up with it will
involve a hell of a lot more then simply overriding the isEnabled
method on a component.
IMO it is not worth the effort to it any other way.

Maurice

On Tue, Jul 8, 2008 at 12:21 PM, Daniele Dellafiore <ildella@...> wrote:

> Hi all. My problem is simple: I want to bind a given property (say:
> 'enabled', or 'visible') of a component to a variable that is on
> another object, just like I bind the text value of a TextField with a
> String on onother object.
>
> This is becouse I do not like this code:
>
>      Button button =  new Button("save") {
>         @Override
>         public boolean isEnabled() {
>            return isEditEnabled();
>         }
>      };
>
> where isEditEnabled() is a method of the parent Page.
> I would like to write something like:
>
> bind(button, "enabled", "editEnabled")
>
> and put that bind(Component, String, String) method on the page, or on
> a static class, doesn't matter.
>
> there is a preferred way to achieve this? A way that involves the use
> of the wicket models to bind properties...
>
> Thanks.
>
> --
> Daniele Dellafiore
> http://blog.ildella.net/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

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

LightInTheBox - Buy quality products at wholesale price