tags:

views:

39

answers:

2

Hi,

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

A: 

setValue(String value)?

http://www.zkoss.org/javadoc/3.6/zk/org/zkoss/zul/Label.html#setValue(java.lang.String)

TuomasR
setValue(String value) method is applicable on a HtmlBasedComponent but not on a html label. I am using import org.zkoss.zul.Html; I am passing a html:label from my .zul file to java file and am trying to set the value of the label in my java file. But, setValue method doesn't work. Note that I am not using: org.zkoss.zul.Label. I am using zhtml label. Thanks!
sony
A: 

Hi,

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.

sony