Scenario:
I am working on a Java/ZK Subscriber Management application. There are 2 tabs: Basic Info
and STB-VC
. The first one for creating a new subscriber and the second one for assigning STB/VC(Set-top box and viewing card).
I am trying to achieve/ensure Someone can only click/use the second tabpanel only after creating a new subscriber and not before.
I have the following code which does that. Is there a better way to achieve the task?
Subscriber.zul
<window id="main" title="" border="normal"
apply="com.sss.composer.SubscriberComposer" width="100%"
height="100%">
<div align="right">
<image id="home" src="/img/home.png" width="30px" />
<image id="logout" src="/img/logout.png" width="30px" />
</div>
<tabbox id="tb">
<tabs id="tabs">
<tab id="A" label="Basic Info" />
<tab id="B" label="STB-VC" />
</tabs>
<tabpanels>
<tabpanel id="basic">
<!-- Subscriber Creation Form -->
<include id="inc1" src="basic.zul"></include>
</tabpanel>
<tabpanel id="stbvc">
<include id="inc2"></include>
</tabpanel>
<tabpanel>
<label id="x3" value="x3"></label>
</tabpanel>
<tabpanel>
<label id="x4" value="x4"></label>
<tabpanel>
<label id="x5" value="x5"></label>
</tabpanel>
</tabpanels>
</tabbox>
</window>
SubscriberComposer
public void onSelect$tb(ForwardEvent fe) {
try {
Object o = fe.getOrigin().getTarget();
if (o instanceof Tab) {
Tab t = (Tab) o;
Tabpanel tp = t.getLinkedPanel();
tp.invalidate();
if ((tp.getId().equals("stbvc") && (Sessions.getCurrent()
.getAttribute("subscriber") == null))) {
Messagebox.show(
"Create Subscriber first,then assign STB/VC!",
"Warning", Messagebox.OK, Messagebox.INFORMATION);
tb.setSelectedPanel(basic);
} else {
inc2.setSrc("stbvc.zul");
System.out.println("Subscriber ID set in session...");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}