-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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
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.
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 ?
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.
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.
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
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
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
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
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
Asked: 2006-02-16 11:27:27 +0800
Seen: 1,320 times
Last updated: Apr 13 '06