asked
2015-03-30 14:10:48 +0800
viachris 27 ● 5 Hello everyone,
i created a Macro-component:
<zk>
<textbox id="textbox" value="${arg.value}" width="${empty arg.width ? '98%' : arg.width}"/>
<popup id="popup" width="200px" />
</zk>
With a custom Java-Class, extending HtmlMacroComponent:
@ComponentAnnotation("value:@ZKBIND(ACCESS=both,SAVE_EVENT=onEdited)")
public class MyMacro extends HtmlMacroComponent {
private static final long serialVersionUID = 1L;
@Wire
private Textbox textbox;
@Wire
private Popup popup;
private Label label;
public MyMacro() {
label = new Label();
setMacroURI("/zul/components/myMacro.zul");
setStyle("display:block");
afterCompose();
popup.appendChild(label);
}
@Listen("onFocus=#textbox")
public void textboxFocus() {
label.setValue("some Text");
popup.open(textbox, "end_before");
}
public void setValue(String value) {
textbox.setValue(value);
}
public String getValue() {
return textbox.getValue();
}
@Listen("onChange=#textbox")
public void textboxChange() {
Events.postEvent("onEdited", this, textbox.getValue());
}
}
In this HtmlMacroComponent i would like to determine the Binding, that is forwarded in the place the macro is used:
<myMacro value="@bind(vm.bean.field)" /> <!-- vm is the ViewModel Class -->
By this i mean the name of the bean and the field and not the content.
It could be the class of the bean or the getter of the vm or anything else really, that helps me to unequivocally identify the bean and field.
To make it more clear, i'm searching for a method like:
textbox.getBinding() // Returns "field.bean" or [org.package.Bean.class, "field"] or something like that
Can someone help me with that?