简体   繁体   English

复合组件中的错误

[英]Error in composite component

i have created an class com.test.test.But 我创建了一个类com.test.test.But

public class But extends Bandbox {
private Label mc_who;
public But() {
Executions.createComponents("/WEB-INF/username.zul", this, null);
Components.wireVariables(this, this, '$', true, true);
Components.addForwards(this, this, '$');
}
public String getWho() {
return mc_who.getValue();
}
public void setWho(String who) {
mc_who.setValue(who);
}

}

and an username.zul 和一个username.zul

<zk>
<label id="mc_who"></label>
</zk>

and index.zul 和index.zul

<window id="test" >
<bandbox>
<bandpopup>
<username who="Joe"/>
<username who="Hellen"/>
</bandpopup>
</bandbox>

</window>

and i am getting this exception 我得到这个例外

org.zkoss.zk.ui.UiException: Unsupported parent for row: <Bandpopup g4HQ2>
org.zkoss.zul.Row.beforeParentChanged(Row.java:264)
org.zkoss.zk.ui.AbstractComponent.setParent(AbstractComponent.java:959)
org.zkoss.zk.ui.impl.AbstractUiFactory.newComponent(AbstractUiFactory.java:91)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:714)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:685)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:629)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:596)
org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.ja

I went through several iterations as well, and found that the most reliable way is to use the div tag as follows: 我也经历了几次迭代,发现最可靠的方法是使用div标签,如下所示:

<zk>
<div>
<label id="mc_who"></label>
</div>
</zk>

This is an example of the component being used: 这是使用的组件的示例:

<window id="test" >
<bandbox>
<bandpopup>
<username who="Joe"/>
<username who="Hellen"/>
</bandpopup>
</bandbox>

</window>

And the source code: 以及源代码:

package com.pontusnetworks.zkwidgets;

import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Div;
import org.zkoss.zul.Row;
import org.zkoss.zul.Textbox;

public class Username extends Div implements IdSpace {
   @Wire
   private Textbox mc_who; //will be wired when Components.wireVariables is called

   public Username() {
       //1. Render the template
       Executions.createComponents("/composite/username.zul", this, null);

       //2. Wire variables, components and event listeners (optional)
       Selectors.wireVariables(this, this, null);
       Selectors.wireComponents(this, this, false);
       Selectors.wireEventListeners(this, this);
   }
   public String getWho() {
       return mc_who.getValue();
   }
   public void setWho(String who) {
       mc_who.setValue(who);
   }
   //public void onOK() {..} //Add event listeners if required, and wired by Components.addForwards
}

Your example is not complete since I don't see row (and grid) in your sample code, while the exception said there is one. 您的示例不完整,因为在示例代码中看不到行(和网格),但例外情况是其中有一个。 Please make a sample that can reproduce the issue. 请制作可以重现该问题的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM