On 9/19/07, dtoffe <[EMAIL PROTECTED]> wrote:
>
>
> Hi !
>
>     I want to make an Enum field in a bean to fire an event. With plain
> Wicket I can do something like:
>
>         DropDownChoice ddc = new DropDownChoice("person", options) {
>
>                 public void onSelectionChanged(java.lang.Object
> newSelection) {
>                     info("Changed!");
>                 }
>
>                 protected boolean wantOnSelectionChangedNotifications() {
>                     return true;
>                 }
>             }
>
>     How can I do this in Web Beans, is there any beanprops that I can use
> ?


WWB is oriented around changes to bean properties. You work with your bean
directly and not the Wicket components. Changing a form drop-down that's
associated with an enum property on your bean causes WWB to call the setter
on your bean as soon as the change occurs. You can update your model from
that point as appropriate. You can also fire PropertyChangeEvents from your
bean to cause other related fields to be refreshed. I think for most cases,
this is sufficient.

However, if you want to perform your exact example above (calling info()),
you have two basic choices:

1. Have your Page/Component containing the BeanForm listen to your bean for
PropertyChangeEvents and invoke info() when the enum property changes.
2. Create a sub-class of EnumField and register it with ComponentRegistry.
You custom enum field can implement the code you have above directly.

I assume your real-life case is more involved than just calling info(). See
the Introduction/Getting Started documentation at
http://wicketwebbeans.sourceforge.net for an examples on how to implement
PropertyChangeEvents and how to do #2 above.

-Dan

Thanks !
>
> Daniel
>

Reply via email to