Revision history [back]

click to hide/show revision 1
initial version

answered 2015-06-17 10:48:31 +0800

WilliamB gravatar image WilliamB

Well I found something that kind of works.

I needed to add the @ComponentAnnotation on my Getter like described : http://books.zkoss.org/wiki/ZKDeveloper%27sReference/MVVM/Advanced/BindingAnnotationforaCustom_Component

I had to add support for the onBlur event in my DualListbox.java with

static {
    addClientEvent(DualListbox.class, Events.ON_BLUR, CE_DUPLICATE_IGNORE);
}

Then the annotation on my getter :

@ComponentAnnotation("@ZKBIND(ACCESS=save, SAVE_EVENT=onBlur)")
public List<String> getChosenDataList() {
    return new ArrayList<String>(chosenDataModel);
}

Well I found something that kind of works.

I needed to add You gotta use the @ComponentAnnotation on my Getter annotation like described : http://books.zkoss.org/wiki/ZKDeveloper%27sReference/MVVM/Advanced/BindingAnnotationforaCustom_Component

So first I had to add support for the onBlur event in my DualListbox.java withsince it inherits from Div which doesn't support it.

static {
    addClientEvent(DualListbox.class, Events.ON_BLUR, CE_DUPLICATE_IGNORE);
}

Then the annotation on my getter :

@ComponentAnnotation("@ZKBIND(ACCESS=save, SAVE_EVENT=onBlur)")
public List<String> getChosenDataList() {
    return new ArrayList<String>(chosenDataModel);
}

Now it triggers when I click out of the component and also when i click on the buttons.

If there is a clearner way to do it to only triggers on button clicks please share.

Well I Sharing since i found something that kind of works.out how to do it.

You gotta use the @ComponentAnnotation annotation like described : http://books.zkoss.org/wiki/ZKDeveloper%27sReference/MVVM/Advanced/BindingAnnotationforaCustom_Component

So first In DualListbox, I had to add support for the onBlur event in my DualListbox.java since it inherits from Div which doesn't support it.

static {
added     addClientEvent(DualListbox.class, Events.ON_BLUR, CE_DUPLICATE_IGNORE);
}

Then the annotation on my getter :

@ComponentAnnotation("@ZKBIND(ACCESS=save, SAVE_EVENT=onBlur)")
SAVE_EVENT=onChoose)")
public List<String> getChosenDataList() {
    return new ArrayList<String>(chosenDataModel);
}

Now it triggers And then you only need to make sure you send the "onChoose" event when I click out of the component and also when i you click on the buttons. buttons. In the ZK exemple it's already the case for the onChoose & unchooseItem methods. So you only need to make it so that the chooseAllItem & unchooseAll also send this event and voilà.

If Btw am I right in thinking that in the current use case, there is a clearner way no use for the data attribut of the ChooseEvent object?

It's just in case someone want to do intercept it to only triggers on button clicks please share.see what is getting changed right?

Sharing since i found out how to do it.

You gotta use the @ComponentAnnotation annotation like described : http://books.zkoss.org/wiki/ZKDeveloper%27sReference/MVVM/Advanced/BindingAnnotationforaCustom_Component

In DualListbox, I added the annotation on my getter :

@ComponentAnnotation("@ZKBIND(ACCESS=save, SAVE_EVENT=onChoose)")
public List<String> getChosenDataList() {
    return new ArrayList<String>(chosenDataModel);
}

And then you only need to make sure you send the "onChoose" event when you click on the buttons. buttons.

Events.postEvent(new ChooseEvent(this, set));

In the ZK exemple it's already the case for the onChoose & unchooseItem methods. So you only need to make it so that the chooseAllItem & unchooseAll also send this event and voilà.

Btw am I right in thinking that in the current use case, there is no use for the data attribut of the ChooseEvent object?

It's just in case someone want to intercept it to see what is getting changed right?

Sharing since i found out how to do it.

You gotta use the @ComponentAnnotation annotation like described : http://books.zkoss.org/wiki/ZKDeveloper%27sReference/MVVM/Advanced/BindingAnnotationforaCustom_Component

In DualListbox, I added the annotation on my getter :

@ComponentAnnotation("@ZKBIND(ACCESS=save, SAVE_EVENT=onChoose)")
public List<String> getChosenDataList() {
    return new ArrayList<String>(chosenDataModel);
}

And then you only need to make sure you send the "onChoose" event when you click on the buttons.

Events.postEvent(new ChooseEvent(this, set));

In the ZK exemple it's already the case for the onChoose & unchooseItem methods. So you only need to make it so that the chooseAllItem & unchooseAll also send this event and voilà.


Btw am I right in thinking that in the current use case, there is no use for the data attribut of the ChooseEvent object?

It's just in case someone want to intercept it to see what is getting changed right?

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More