0

Lifecycle of Composers?

asked 2007-12-07 19:43:33 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2007-12-10 00:49:55 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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


link publish delete flag offensive edit

answered 2007-12-10 02:11:19 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


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

link publish delete flag offensive edit

answered 2012-04-01 07:56:05 +0800

tsinglongwu gravatar image tsinglongwu
30 2

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

link publish delete flag offensive edit

answered 2012-04-09 15:32:59 +0800

benbai gravatar image benbai
2228 6
http://www.zkoss.org

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

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

Follow

RSS

Stats

Asked: 2007-12-07 19:43:33 +0800

Seen: 195 times

Last updated: Apr 09 '12

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