-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I need to add some styling to my window title. I found following thread:
http://www.zkoss.org/forum/listComment/11371;jsessionid=3E272C341E6088004B5B308A23F84880.zkzh
However, when I tried to run the simple test page from my existing web app, I got a ClasscastException.
The test page is like following:
<zk>
<style>
.z-window-embedded-header { color:white; font-size:50px}
</style>
<window id="winCbos" title="CBOS" style="text-align:center;" width="100%" border="normal" >
</window>
</zk>
Exception stack trace is:
org.zkoss.zk.ui.impl.UiEngineImpl handleError:1172
SEVERE: >>java.lang.ClassCastException: org.zkoss.zul.Style
Exception is thrown out when I tried to create the window component:
Window window = (Window) Executions.getCurrent().createComponents("user/admin/admin.zul", null, null);
Can anyone help me with this?
Thank You!
Please check the return type of Executions.getCurrent().createComponents("user/admin/admin.zul", null, null)... seems to be that it might be a Style-Component and not a Window.
Cheers, Maik
Hi,Maik:
Yes you are right.
I found the return type of Executions.getCurrent().createComponents("user/admin/admin.zul", null, null) is "org.zkoss.zul.Style" instead of "org.zkoss.zul.Window" when I run the test page. That's why I had this ClassCastException.
So I put the style block into the window. Then the return type changes back to org.zkoss.zul.Window so page is displayed. However the style is not working.
any idea?
Thank you
Hi, tawa:
I tried your solution. the createComponent() still return a Style object instead of Window
Thank U
I've tried to implement this in an alternative way. Instead of using the text as title for the Window, I use the text as caption. It is fine for me either way. The code is like following:
<zk>
<window id="winCbos" width="100%" border="normal" >
<caption label="CBOS" style="color:white; font-size:50px; align:center;" />
</window>
</zk>
The style about font size and font color are picked up correctly. But text is always align to the left. It seems the "align:center" does not take effect at all. I then tried to set alignment for caption directly and was told setAlign() is not available for Caption. maybe that's the reason that the alignment setting is ignored.
So what i should do if I want to set alignment for caption text?
Paula,
If you always want your window caption to be aligned center, try the following:
<zk> <style> .z-caption .z-caption-l, .z-caption .z-caption-r { text-align: center; } </style> <window id="winCbos" width="100%" border="normal" > <caption label="CBOS" style="color:white; font-size:50px;" /> </window> </zk>
Otherwise, you could probably modify the <caption> to use an sclass.
You can find more information on the style for <caption> here.
Hope that helps,
Todd
Asked: 2011-04-27 10:08:40 +0800
Seen: 850 times
Last updated: Apr 29 '11