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

发布于 2024-09-25 14:22:58 字数 402 浏览 0 评论 0原文

如何在java文件中使用html:label?

比如说,我想从我的 java 文件中生成以下内容:

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

我尝试了以下方法:

import org.zkoss.zul.Html;

public class TestLabel {

private Label testLabel;

TestLabel() {

testLabel.setTextContent("test label");

}

}

这会引发错误,因为标签没有 setTextContent 这样的方法。我应该使用哪种方法来实现这一目标?

谢谢, 索尼

How do I use html:label in java file?

Say, I want to produce the following from my java file:

<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. Which method do I use to achieve this?

Thanks,
Sony

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ぇ气 2024-10-02 14:22:58

我使用的是 Zhtml 标签而不是常规的 Html 标签。所以,我所做的就是向 Zhtml Label 添加一个常规的 Html 子元素。意思是,

public class TestLabel {

private org.zkoss.zhtml.Label testLabel;

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

}

}

上面只是一个小测试用例。但是,这样做的最初目的是将 Zhtml 标签的 id 发送到 java 文件,并在满足特定条件时对 zhtml 标签执行操作。接下来,客户端执行其他操作,例如当此 zhtml 标签更改时清除缓存。

I am using a Zhtml Label rather than a regular Html Label. So, what I did is I added a regular Html child to Zhtml Label. 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. Next, the client performs other operations such as clearing a cache when this zhtml label changes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文