0

problem in styling window title

asked 2011-04-27 10:08:40 +0800

paula gravatar image paula
74 2

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!

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2011-04-27 12:11:21 +0800

mjablonski gravatar image mjablonski
1284 3 5
http://www.jease.org/

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

link publish delete flag offensive edit

answered 2011-04-27 16:29:16 +0800

paula gravatar image paula
74 2

updated 2011-04-27 16:32:39 +0800

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

link publish delete flag offensive edit

answered 2011-04-28 03:02:15 +0800

tawa gravatar image tawa
162 1

try this:

<zk>
<style><![CDATA[
.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>

link publish delete flag offensive edit

answered 2011-04-28 09:56:13 +0800

paula gravatar image paula
74 2

updated 2011-04-28 10:05:21 +0800

Hi, tawa:

I tried your solution. the createComponent() still return a Style object instead of Window

Thank U

link publish delete flag offensive edit

answered 2011-04-28 15:43:53 +0800

paula gravatar image paula
74 2

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?

link publish delete flag offensive edit

answered 2011-04-28 18:09:26 +0800

twiegand gravatar image twiegand
1807 3

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

link publish delete flag offensive edit

answered 2011-04-29 09:46:28 +0800

paula gravatar image paula
74 2

Thank you very much Todd.

It works fine. Now the caption of my window centered perfectly

Have a nice day

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: 2011-04-27 10:08:40 +0800

Seen: 850 times

Last updated: Apr 29 '11

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