0

onCreate event

asked 2006-02-16 11:27:27 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3579465

By: nobody


Hi,

When I used rc6, I used the following in my code:

public void onCreateAtClient() {
setContent();
super.onCreateAtClient();
}

I had to use it because when I didn't I had the exception that say's:
"the component doesn't belong to any page"

(the setContent is actually, setting an image for subclass of button and
toolbarbutton:

public void setContent(){

file = new File("some jpg file");

try {
imagedata = new AImage(file);
} catch (IOException e) {
e.printStackTrace();
}
this.setImageContent(imagedata);
}
so it seems that I could only set the content after the component was created en belongs to an ID space ?

So I had to overwrite the method onCreateAtClient() of the superclass (button,
toolbarbutton)

this was working in rc6.
Now I use rc8 (great work bye the way, I will try to test on a more regular
base) and it seems that you moved the On"event" methods out of the way.

Then I thought, I use a eventlistener (like I probebly better had done in the firts place?) for the onCreate event:

addEventListener("onCreate", new EventListener(){

public void onEvent(Event e) {
Fotoview foto = (Fotoview)e.getTarget();
foto.setContent();
}
public boolean isAsap() {
return false;
}
});

(where Fotoview is the subclass of button)

This isn't working and I get the same message as before.
Did I miss something, or is there a other/better way ?

thankx
eduard, brussels




delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2006-02-16 11:46:40 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3579484

By: tomyeh

Your codes shall work fine without such "patching". Please post the stack trace of the exception. It could be a bug.

PS: onCreate is sent in the event processing phase, while RC6's onCreateAtClient is designed for different purpose.

link publish delete flag offensive edit

answered 2006-02-16 16:07:37 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3580169

By: the-e-factory


The stacktrace:

com.potix.zk.ui.sys.UiEngineImpl handleError:433
SEVERE: >>java.lang.IllegalStateException: This component doesn't belong to any page
>> at com.potix.zk.ui.AbstractComponent.getViewURI(AbstractComponent.java:326)
>> at
>>com.potix.zul.html.impl.LabelImageElement.setImageContent(LabelImageEl
>>emen
t.java:113)
>> at com.fotoalbum.Fotoview.setContent(Fotoview.java:58)
>> at com.fotoalbum.Fotoview.<init>(Fotoview.java:30)
>> at com.fotoalbum.Fotos.makeFotos(Fotos.java:45)
>> at com.fotoalbum.Fotolistener.onEvent(Fotolistener.java:27)
>> at
>>com.potix.zk.ui.sys.EventProcessingThread.process0(EventProcessingThre
>>ad.j
ava:381)
>> at
>>com.potix.zk.ui.sys.EventProcessingThread.run(EventProcessingThread.ja
>>va:2
71)

The event processing thread stops

ps: do I have to use a eventlistener to set the content of the image or can I just do it in the constructor ?


link publish delete flag offensive edit

answered 2006-02-16 16:35:26 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3580220

By: tomyeh

It is a bug (seems a false alarm). Please post it to Bugs. I'll fix it later.
Thanks.

link publish delete flag offensive edit

answered 2006-02-16 17:15:11 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3580287

By: tomyeh

Before fix, you could work around this by assigning the new created component with a parent/page first, before calling setImageContent.

link publish delete flag offensive edit

answered 2006-02-16 18:57:04 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3580486

By: the-e-factory


The bug is posted.

the work around is working, thankx

link publish delete flag offensive edit

answered 2006-04-12 17:00:32 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3683361

By: the-e-factory


Hi, when I ad a onCreate event listener to a component in plain java code, the event is not send to the component ?
If I make the same component with the use atribute in a zul file it works!

Is it okAc if I assume that I can code directly against the api (without zuml, just one .zul with use atribute as entrypoint) and al the features etc are the same ?

The code: .zul file:
<?xml version="1.0" encoding="UTF-8"?>
<?page title="Test modal window"?>
<zk>
<div use="com.fotoalbum.view.TButton" >
</div>
</zk>

TButton class:
package com.fotoalbum.view;

import com.potix.zk.ui.event.Event;
import com.potix.zk.ui.event.EventListener;
import com.potix.zul.html.Button;
import com.potix.zul.html.Div;
import com.potix.zul.html.Window;

public class TButton extends Div {


public TButton(){
this.setId("div");
maaklayout();
}

private void maaklayout() {
Button b = new Button("make oncreate window");
this.appendChild(b);
b.addEventListener("onClick", new EventListener(){

public void onEvent(Event e) {


OncreateWindow window = new OncreateWindow();
e.getPage().getFellow("div").appendChild(window);


}

public boolean isAsap() {
return true;
}

});


}
}

OncreateWindow class:
package com.fotoalbum.view;

import com.potix.zk.ui.event.Event;
import com.potix.zk.ui.event.EventListener;
import com.potix.zul.html.Label;
import com.potix.zul.html.Window;

public class OncreateWindow extends Window {


public OncreateWindow(){
makeLayout();
}

private void makeLayout() {

this.setTitle("oncreatewindow");
this.setWidth("150px");
this.setHeight("150px");
this.setClosable(true);
this.setBorder("normal");

this.addEventListener("onCreate", new EventListener(){

public void onEvent(Event e) {
e.getTarget().appendChild(new Label("added with the oncreate event"));

}

public boolean isAsap() {
return false;
}

});

}
}

thanks



link publish delete flag offensive edit

answered 2006-04-13 01:24:55 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3684017

By: henrichen

Yes, you can construct the server side component tree with java api directly.

/henri

link publish delete flag offensive edit

answered 2006-04-13 06:18:16 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3684199

By: the-e-factory


Is there someting wrong with my code then, or why the onCreate event is not send to the component on creation?
thanks

link publish delete flag offensive edit

answered 2006-04-13 13:20:28 +0800

admin gravatar image admin
18691 1 10 129
ZK Team


Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3684784

By: henrichen

onCreate event would not be fired unless the window is rendered inside a zuml page. (Yes, it is special!)

/henri

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: 2006-02-16 11:27:27 +0800

Seen: 1,315 times

Last updated: Apr 13 '06

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