answered
2015-01-28 16:46:10 +0800
chillworld 5367 ● 4 ● 9
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 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.
Your macro, does it extends some component class?
chillworld ( 2015-01-28 15:32:11 +0800 )editThere was a slight problem in formatting of my post - the component declaration was invisible (now edited). You can see that it is just a text based macro (I think extending HtmlMacroComponent?).
KlausWr ( 2015-01-28 16:26:55 +0800 )edit@chill: As newbie I neither can comment directly on your answer - nor can I add my own answer. So I choose this way to tell you thanks. Will try your solution. I guess there is no EASY way like I tried before ... means I WILL need a class and I need to know the controls per component, hugh :-(
KlausWr ( 2015-01-28 19:15:58 +0800 )editJust upvoted the question, so you have a little more karma. I can help you with creating a simple examle so you could use it. (linkedin is in mine profile)
chillworld ( 2015-01-28 20:25:14 +0800 )edit