0

Changing font theme - 2 different form factors in one server

asked 2008-11-18 18:30:00 +0800

ansancle gravatar image ansancle
317 9

I have a problem where I have both Iphones/Itouch devices and desktops connecting to the same application. I can handle changing the stylesheets depending upon which device connects - but have run into a problem with font sizes which I had been setting in zk.xml using the library-property settings :

	<library-property>
		<name>org.zkoss.zul.theme.fontSizeM</name>
		<value>60px</value>
	</library-property>

Using the library-property for setting the font theme doesn't work since both the desktops and hand-helds end up sharing the same value - which means it's either too big for the desktop or too small for the hand-helds. I hate to have to create 2 additional custom stylesheets for just changing all the font sizes, is there another way I can setup the org.zkoss.zul.theme.fontSizeM so each client gets the correct value for the display area?

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2008-11-19 01:25:21 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

So far ZK don't provide a way to easily check the browser whether it is iphone/itouch or not.
However you can check them as follows.

(( javax.servlet.http.HttpServletRequest)Executions.getCurrent().getNativeRequest()).getHeader("user-agent")

Then,
if (iphone) {
    org.zkoss.lang.Library.setProperty("org.zkoss.zul.theme.fontSizeM", "60px")
} else {
    ....
}

link publish delete flag offensive edit

answered 2008-11-19 14:42:18 +0800

ansancle gravatar image ansancle
317 9

Yeah,
I have been using the following to determine browser type :

<zk>
<zscript>
    String browserType = (String)Executions.getCurrent().getNativeRequest().getHeader("User-Agent");
    if (browserType.indexOf("iPhone") != -1)
    {
         ........

And this actually works fine. From here I was able to select and include the correct style sheet for all of my images etc...
The problem I was then having is I had been setting the org.zkoss.zul.theme.fontSizeM etc.. in the zk.xml file. I then tried setting these values at run time but since all the different browsers are sharing the same server - one setting in the Library for fonts was being used by all browsers. I tried to figure out how to use the ThemeProvider so I could override the fonts per client but was unable to get that to work correctly. My provider was called but when I tried to override the norm*.css.dsp files with all of my own versions it just didn't work. I had created new versions called mynorm*.css.dsp for all the norm*.css.dsp files and then gave the correct paths etc.. but the changes did not show up. Any additional sample code on using ThemeProviders and the accompanying css.dsp files would be a great help - I searched the existing documentation/forums/etc.. at length.

Thanks!

link publish delete flag offensive edit

answered 2008-11-21 01:31:31 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hello,

You can refer to org.zkoss.zkdemo.userguide.FontSizeThemeProvider class, which can be found in zkdemo.war.

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: 2008-11-18 18:30:00 +0800

Seen: 239 times

Last updated: Nov 21 '08

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