ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

HTML support in Label or label-like component?

lovetide
22 Jan 2010 02:08:16 GMT
22 Jan 2010 02:08:16 GMT

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?

henrichen
26 Jan 2010 22:18:33 GMT
26 Jan 2010 22:18:33 GMT

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?

Stas283
18 Mar 2010 16:08:19 GMT
18 Mar 2010 16:08:19 GMT

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

tmillsclare
24 Mar 2010 20:53:07 GMT
24 Mar 2010 20:53:07 GMT

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.