-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4664445
By: frankiec
Have recently started using this feature (very nice)
What is the lifecycle? I assumed it was per instantiation of each page or component of a page that it was attached to. To reduce this (OO has a very definitive cradle/grave overhead on instatiations) I made it a singleton and I assign it to a session variable which is then
apply="${_wdNewUserCompletion}"
I've verified that the afterCompose is always called on the singleton but I didn't know if I was redundantly adding to something that was already managed by ZK.
Anything?
Frank
Hi,
I think you need a 'middle object' to be the bridge between JMS and ZK component,
for example,
in zul page:
<window id="backupDialog" ...> <progressMeter id="curr_pm" ... > .... <timer id="timer" delay="1000" repeats="true" ...> ...
in composer
int curr_value = 0; ... public void onMessage(Message message) { ... curr_value = Integer.parseInt(msgs[0]); ... } public void onTimer$timer () { curr_pm.setValue(curr_value); }
Regards,
Ben
Hi Frank,
I was blocked by a component lifecycle issue.
I want to upgrade Progressmeter infomation in backup.zul with processed message from JMS server. The page's bind class is following:
-------------------------------------------------
@Controller("backupDialogCtrl")
@Scope("prototype")
public class BackupCtrl extends GenericForwardComposer implements MessageListener {
private Window backupDialog;
private Textbox tDbIp, tDataPath, tAppVersion, tDescription;
private Label resultLabel;
private Progressmeter curr_pm;
public void doAfterCompose(Component comp) throws Exception{
super.doAfterCompose(comp);
}
public void onClick$backup() {
try {
resultLabel.setValue("Starting..."); // All the components is available.
desktop.enableServerPush(true);
DBBkRestI dbBkRest = DBBkRestImpl.getInstance();
dbBkRest.backupDB(); Call JMS server method which will send message to consumers. The following method of onMessage() is the listener. It will accept and display all the messages.
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onMessage(Message message) { This method is extends javax.jms.MessageListener. It will be invoked whenever there are messages send from JMS server.
try {
if (message instanceof TextMessage) {
msgProcess = ((TextMessage)message).getText();
String[] msgs = msgProcess.split(",");
Executions.activate(desktop); // when jvm run at here, desktop is Null, include all of the components in the page.
curr_pm.setValue(Integer.parseInt(msgs[0]));
resultLabel.setValue(msgs[1]);
Executions.deactivate(desktop);
} else {
System.out.println("Message of wrong type: "
+ message.getClass().getName());
}
} catch (JMSException e) {
... ...
} catch (Throwable t) {
... ...
} finally {
... ...
}
}
}
-----------------------------------
When the onMessage() is invoked, all the components is Null(include the window of backupDialog). How can I use the components in the method of onMessage().
Thank you a lot!
Alex
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4666997
By: frankiec
Thanks,
It's working like a baby and am happy with this feature. It does fit the MVC pattern fairly well.
Thanks!
Frank
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4666930
By: jebberwocky
1. Page Initial Phrase => init
2. Component creation phrase
2-1. if and unless attribute
2-2. forEach
2-3. Create component
2-4. Initialize attributes
2-5. Interprets the nested elements
2-6. Invokes AfterCompose
2-7. onCreate
Asked: 2007-12-07 19:43:33 +0800
Seen: 201 times
Last updated: Apr 09 '12