Search code examples
zk

How do I underline some text in a label using ZK framework?


I am using ZK framework. I have a static line of text in a label:

        <label
            value="If you have already submitted a leave application or need to modify 
                   an existing leave, do not submit an online application.  " />

I need to underline only some parts of this sentence. I've tried putting <u> </u> around the text I wish to underline, but this is not allowed in ZK.

I've also tried creating separate labels, with style="text-decoration: underline;" which does underline the specified text. However this way of underlining makes each label display on it's own line.

Is there some way that I can underline only certain parts of my label?


Solution

  • There is no way you could append style to certain parts of a label.

    Like @Link already commented you could use multiple labels and set the sclass different of each label.

    If you have real HTML in your text, you could use the following :

    HtmlNativeComponent n = new HtmlNativeComponent("html", "<h2>title</h2>","<p>your text</p>");
    

    Explication of constructor :

    • "html" => the element where all your text is between. (wrapper element)
    • "<h2>title</h2>" => the first part. If you append more children to the native component, its after this they will come.
    • "<p>your text</p>" => the second part. If you append more children to the native component, its before this they will come.