Revision history [back]

click to hide/show revision 1
initial version

asked 2015-03-30 14:10:48 +0800

viachris gravatar image viachris

Determine the binding (the bean backing a textbox) of a component in a HtmlMacroComponent

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);
        }

       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 anyithing 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?

Determine the binding (the bean backing a textbox) of a component in a HtmlMacroComponent

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);
        }

       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 anyithing 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?

Determine the binding (the bean backing a textbox) of a component in a HtmlMacroComponent

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?

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