Revision history [back]

click to hide/show revision 1
initial version

answered 2015-01-28 16:46:10 +0800

chillworld gravatar image chillworld flag of Belgium

https://github.com/chillw...

You don't have any component behind and that's actually what you are missing.

I have create for myself an component like you want to create :

Declaration is :

<?component name="catalog" macroURI="/WEB-INF/webpages/zk/common/catalog.zul" class="be.chillworld.web.vm.common.BindingCatalogMacroComponent"?>

As you can see that I have now a class behind this component.

This is mine zul :

<?xml version="1.0" encoding="UTF-8"?>
<zk xmlns="http://www.zkoss.org/2005/zul" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul                        http://www.zkoss.org/2005/zul/zul.xsd">
  <hbox align="center" id="${arg.id}">
    <image src="/img/detail.png" id="detail" />
    <textbox cols="9" ctrlKeys="^l" id="code" readonly="${arg.readonly}" sclass="T_TB_code">
      <custom-attributes validation="${arg.constraint}" />
    </textbox>
    <separator width="5px" />
    <textbox readonly="true" cols="30" id="description" tabindex="-1" sclass="T_TB_description" />
  </hbox>
</zk>

And as last the class behind :

@ComponentAnnotation("value:@ZKBIND(ACCESS=both,SAVE_EVENT=onEdited)")
public class BindingCatalogMacroComponent extends HtmlMacroComponent {
    @Wire
    protected InputElement code;
    @Wire
    protected Textbox description;
    @Wire
    protected Image detail;

What's really important is that you implement the MineObject getValue() and SetValue(MineObject obj)

The setup is done in the doAfterCompose. I have put the constraint in custom attribute because I have to call the getValue when I open a popup and when constraint fails at that moment I'll have that popup from failing constraint on top of mine popup. (So I actually check the constraint when I need it)

I'll hope if this already can help you.

greetz chill.

You don't have any component behind and that's actually what you are missing.

I have create for myself an component like you want to create :

Declaration is :

<?component name="catalog" macroURI="/WEB-INF/webpages/zk/common/catalog.zul" class="be.chillworld.web.vm.common.BindingCatalogMacroComponent"?>

As you can see that I have now a class behind this component.

This is mine zul :

<?xml version="1.0" encoding="UTF-8"?>
<zk xmlns="http://www.zkoss.org/2005/zul" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul                        http://www.zkoss.org/2005/zul/zul.xsd">
  <hbox align="center" id="${arg.id}">
    <image src="/img/detail.png" id="detail" />
    <textbox cols="9" ctrlKeys="^l" id="code" readonly="${arg.readonly}" sclass="T_TB_code">
      <custom-attributes validation="${arg.constraint}" />
    </textbox>
    <separator width="5px" />
    <textbox readonly="true" cols="30" id="description" tabindex="-1" sclass="T_TB_description" />
  </hbox>
</zk>

And as last the a part of the class behind :

@ComponentAnnotation("value:@ZKBIND(ACCESS=both,SAVE_EVENT=onEdited)")
public class BindingCatalogMacroComponent extends HtmlMacroComponent {
    @Wire
    protected InputElement code;
    @Wire
    protected Textbox description;
    @Wire
    protected Image detail;

What's really important is that you implement the MineObject getValue() and SetValue(MineObject obj)

The setup is done in the doAfterCompose. I have put the constraint in custom attribute because I have to call the getValue when I open a popup and when constraint fails at that moment I'll have that popup from failing constraint on top of mine popup. (So I actually check the constraint when I need it)

I'll hope if this already can help you.

greetz chill.

You don't have any component behind and that's actually what you are missing.

I have create for myself an component like you want to create :

Declaration is :

<?component name="catalog" macroURI="/WEB-INF/webpages/zk/common/catalog.zul" class="be.chillworld.web.vm.common.BindingCatalogMacroComponent"?>

As you can see that I have now a class behind this component.

This is mine zul :

<?xml version="1.0" encoding="UTF-8"?>
<zk xmlns="http://www.zkoss.org/2005/zul" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul                        http://www.zkoss.org/2005/zul/zul.xsd">
  <hbox align="center" id="${arg.id}">
    <image src="/img/detail.png" id="detail" />
    <textbox cols="9" ctrlKeys="^l" id="code" readonly="${arg.readonly}" sclass="T_TB_code">
      <custom-attributes validation="${arg.constraint}" />
    </textbox>
    <separator width="5px" />
    <textbox readonly="true" cols="30" id="description" tabindex="-1" sclass="T_TB_description" />
  </hbox>
</zk>

And as last the a part of the class behind :

@ComponentAnnotation("value:@ZKBIND(ACCESS=both,SAVE_EVENT=onEdited)")
public class BindingCatalogMacroComponent extends HtmlMacroComponent {
    @Wire
    protected InputElement code;
    @Wire
    protected Textbox description;
    @Wire
    protected Image detail;

What's really important is that you implement the MineObject getValue() and SetValue(MineObject obj)

The setup is done in the doAfterCompose. I have put the constraint in custom attribute because I have to call the getValue when I open a popup and when constraint fails at that moment I'll have that popup from failing constraint on top of mine popup. (So I actually check the constraint when I need it)

I'll hope if this already can help you.

Edit :

Forget to say, I set the textbox value in the setValue method.
If you need more info, just ask.

greetz chill.

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