简体   繁体   English

如何在Java文件中使用html:label

[英]how to use html:label in java file

How do I use html:label in java file? 如何在Java文件中使用html:label?

Say, I want to produce the following from my java file: 说,我想从我的java文件中产生以下内容:

<html:label> test label </html:label> 

I tried this: 我尝试了这个:

import org.zkoss.zul.Html;

public class TestLabel {

private Label testLabel;

TestLabel() {

testLabel.setTextContent("test label");

}

}

This throws an error as there is no such method as setTextContent for a label. 由于没有标签的setTextContent这样的方法,因此会引发错误。 Which method do I use to achieve this? 我该使用哪种方法来实现?

Thanks, Sony 谢谢,索尼

I am using a Zhtml Label rather than a regular Html Label. 我使用的是Zhtml标签,而不是常规的HTML标签。 So, what I did is I added a regular Html child to Zhtml Label. 因此,我要做的是向Zhtml Label添加了一个常规的HTML子级。 Meaning, 含义,

public class TestLabel {

private org.zkoss.zhtml.Label testLabel;

TestLabel() {
Html update = new Html("a");
testLabel.appendChild(update);
testLabel.setVisible(true);

}

}

The above is just a small test case. 以上只是一个小的测试案例。 But, originally the purpose of doing this is to send the id of a Zhtml label to the java file and perform operations on zhtml label when a particular condition is met. 但是,最初这样做的目的是将Zhtml标签的ID发送到Java文件,并在满足特定条件时对zhtml标签执行操作。 Next, the client performs other operations such as clearing a cache when this zhtml label changes. 接下来,客户端执行其他操作,例如当此zhtml标签更改时清除缓存。

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

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