-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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?
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")
if (iphone) { org.zkoss.lang.Library.setProperty("org.zkoss.zul.theme.fontSizeM", "60px") } else { .... }
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!
Hello,
You can refer to org.zkoss.zkdemo.userguide.FontSizeThemeProvider class, which can be found in zkdemo.war.
Asked: 2008-11-18 18:30:00 +0800
Seen: 240 times
Last updated: Nov 21 '08