0

HTML support in Label or label-like component?

asked 2010-01-22 02:08:16 +0800

lovetide gravatar image lovetide
169 1 7

updated 2010-01-22 02:10:23 +0800

HTML support in Label or label-like component?

Think about these:
1. Display spaces by setting label of Listitem to "   " to achieve text padding (Listbox.mold='select')
2. Display copyright or other special characters by setting value/label of Label/LabelElement/etc to "©"

Can't achieve those in the following sample code:

<?xml version="1.0" encoding="UTF-8"?>
<zk>
<textbox id='tb' multiline='true' width='100%' rows='10'/>
<button label='Fill with these text' onClick='SetLabel()'/>

<separator/>
Listitem: <listbox id='lb' mold='select'/>

<separator/>
Label: <label id='l' value='a label is here'/>

<separator/>
Html: <html id='ht' content='a html is here'/>

<zscript>
<![CDATA[

String sInitLines=
	"Can you see 1+ spaces between the following brackets? [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]\n" +
	"Can you see a copyright character? [&copy;]\n" +
	"   1   TRACE       TRACE log level\n" +
	"  10   INFO        INFO log level\n" +
	" 100   WARNING     WARNING detail log level\n" +
	"1000   ERROR       ERROR log level\n" +
	"...1...TRACE.......TRACE.log.level\n" +
	"..10...INFO........INFO.log.level\n" +
	".100...WARNING.....WARNING.detail.log.level\n" +
	"1000...ERROR.......ERROR.log.level\n" +
	"";
tb.setValue (sInitLines);

public void SetLabel ()
{
	lb.getChildren().clear();
	String sLines = tb.getValue();
	java.io.LineNumberReader lnr = new java.io.LineNumberReader (new java.io.StringReader(sLines));
	while (true)
	{
		String sLine = lnr.readLine ();
		if (sLine == null) break;
		
		if (lnr.getLineNumber() == 1)
		{
			l.setValue (sLine);
			ht.setContent (sLine);
		}
		
		Listitem li = new Listitem (sLine);
		lb.appendChild (li);
	}
	lnr.close();
}

]]>
</zscript>

</zk>


Will it be supported in future?

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2010-01-26 22:18:33 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

Since this is Java code (in zscript), you shall think you are setting some "special" characters into the listitem. Can you use \uxxxx unicode directly?

link publish delete flag offensive edit

answered 2010-03-18 16:08:19 +0800

Stas283 gravatar image Stas283
93 2
www.trade4stas.com

updated 2010-03-18 16:08:58 +0800

Padding can be achieved trough using z-class

  .mylabel
   {
        padding: 1 1 1 1;
   }

It is unclear how to set &nbsp; as label value

<label zclass="mylabel"  id="descriptionLabel" style="color: red" value="\u00A0" /> 

does not work

link publish delete flag offensive edit

answered 2010-03-24 20:53:07 +0800

tmillsclare gravatar image tmillsclare
799 2 5 30

Hey Stas283,

You need to set the pre property of the label.

<label pre="true" value="  "/>

This will then preserve white space in the value. The equivalent javadoc is here.

link publish delete flag offensive edit

answered 2012-04-11 06:55:34 +0800

AmandeepJ gravatar image AmandeepJ
15 1

You can do that here's an example :

<zk xmlns:h="http://www.w3.org/1999/xhtml">
<h:div class="z-toolbarbutton-cnt">
Hello
<h:b> THIS MUST BE BOLD </h:b>
Here goes normal
</h:div>
</zk>
you just need to set proper class of the HTML DIV. I your case class will be different.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-01-22 02:08:16 +0800

Seen: 2,606 times

Last updated: Apr 11 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More