First time here? Check out the FAQ!
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
if(Status.equals('Y'){
<textbox/>
}
else {
<label value='additional information' />
}
How to do in ZUL,
Appreciates ur feedback guys
Thanks
Shuk
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 {
super.doAfterCompose(comp);}
public void onClick$btn(Event e) throws InterruptedException{
Messagebox.show("Hi btn");
}
}
<zk>
<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[
lbl.setVisible(true);
tbx.setVisible(false);
]]>
</attribute>
</button>
<button label="shows textbox">
<attribute name="onClick"><![CDATA[
lbl.setVisible(false);
tbx.setVisible(true);
]]>
</attribute>
</button>
</window>
</zk>
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}" />
<listcell>
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"/>
</listcell>
</listitem>
Hope you understand my problem, :D
Many thanks,
Shukrimb
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:
in your case... you will be doing something like:
public void render(Listitem item, YourBean bean, int index) throws Exception {
item.setValue(bean);
Listcell c1 = new Listcell();
c1.setParent(item);
if (bean.isTrue()) {
new Textbox().setParent(item);
} else {
new Label("no need").setParent(item);
}
}
hope it helps! Giovanni
Asked: 2012-03-14 04:58:24 +0800
Seen: 730 times
Last updated: Apr 30 '13