If Else in ZUL

asked 2012-03-14 04:58:24 +0800

shukrimb gravatar image shukrimb

Good day guys,

How to do a condition in ZUL page. I just want to display textbox if fullfil the condition else displat a label.
Sample JSP is something like this
else {
<label value='additional information' />

How to do in ZUL,

Appreciates ur feedback guys



delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2012-03-14 11:40:13 +0800

mhj gravatar image mhj flag of Brazil
806 1 7

hi shukrimb!
i don't understood very good your problem, maybe the code below can help you...


package j1m2gpn5$v1;

import org.zkoss.zk.ui.*;
import org.zkoss.zk.ui.event.*;
import org.zkoss.zk.ui.util.*;
import org.zkoss.zk.ui.ext.*;
import org.zkoss.zk.au.*;
import org.zkoss.zk.au.out.*;
import org.zkoss.zul.*;

public class TestComposer extends GenericForwardComposer{

public void doAfterCompose(Component comp) throws Exception {


public void onClick$btn(Event e) throws InterruptedException{
Messagebox.show("Hi btn");

<window border="normal" title="hello" apply="j1m2gpn5$v1.TestComposer">
<label id="lbl" visible="false" value="blablablablablablablablabla"/>
<textbox id="tbx" visible="false" value="blablablablablablablablabla"/>
<button label="shows label">
<attribute name="onClick"><![CDATA[
<button label="shows textbox">
<attribute name="onClick"><![CDATA[

any question, can ask.

link publish delete flag offensive edit

answered 2012-03-14 13:00:19 +0800

shukrimb gravatar image shukrimb

Hi mhj,
Really appreciated your respond. Below is my code snippet :

<listitem self="@{each=docs}" value="@{docs}">
<listcell label="@{docs.docId}" />
<listcell label="@{docs.docName}" />
<listcell label="@{docs.docComply}" />
<listcell label="@{docs.docStatus}" />
Here is the problem
Base on the object given (docs.docAdd), I need to display is either textbox or label base on below condition
but, its displayed both
Database records
doc add = N
doc add = N
doc add = N
doc add = Y
doc add = Y
My Question is, it is correct to do a if condition like this ?

<textbox if="${docs.docAdd==Y}" value="Please Keyin Data" />
<label if="${docs.docAdd==N}" value="No Info Required"/>


Hope you understand my problem, :D
Many thanks,


link publish delete flag offensive edit

answered 2013-04-30 14:55:49 +0800

Niltus gravatar image Niltus
10 1

hey did you solve your problem? im trying to do the same

link publish delete flag offensive edit

answered 2013-04-30 15:10:43 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6

updated 2013-04-30 15:15:55 +0800

From what i understood, this scenario better fits to a custom renderer:

Using a ListModel and ListitemRenderer

There are many examples around about renderers... this one is about grids:

dynamic render

in your case... you will be doing something like:

public void render(Listitem item, YourBean bean, int index) throws Exception {
    Listcell c1 = new Listcell();
    if (bean.isTrue()) {
        new Textbox().setParent(item);
    } else {
        new Label("no need").setParent(item);

hope it helps! Giovanni

link publish delete flag offensive edit
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




Asked: 2012-03-14 04:58:24 +0800

Seen: 730 times

Last updated: Apr 30 '13

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