Thanks Igor! But in my case, this is not about changing the css properties only. I need few html changes as well. For example, in higher resolution screen form input fields needs to be displayed besides label to make it look professional. Is there any other way (or hack!) to determine markup file location at runtime (on every request - so that I can load/locate html based on device category)!
Warm Regards, Anirban Basak Ph : 91 33 2357 7177 Extn: 277 -----Original Message----- From: Igor Vaynberg [mailto:[email protected]] Sent: Tuesday, May 26, 2009 11:06 PM To: [email protected] Subject: Re: how to control/locate which html to load you should use session.setstyle() and have a seperate style per screen resolution variant -igor 2009/5/26 Anirban Basak <[email protected]>: > Hi! > > Im writing a mobile web interface using wicket. Since there are mobile > devices with various screen resolutions, I need to maintain separate set of > htmls (per component class) based on category/resolution. Im able to define > custom place for htmls (thanks to > http://cwiki.apache.org/WICKET/control-where-html-files-are-loaded-from.html > ), but having problem with locating correct file at runtime. Wicket is > invoking locate(Class clazz, String path) of my custom ResourceStreamLocator > for the 1st time only. Then, I assume, its remembering the file path or > stream and always showing htmls for the 1st requesting device category! Is > there any way (a hack may be!) to instruct/force wicket to invoke locate( ) > everytime a request comes? > > > > Below a snippet of my current implementation: > > > > public class MyWebApplication extends WebApplication { > > > > > > protected void init() { > > IResourceSettings resourceSettings = > getResourceSettings(); > > resourceSettings.setResourceStreamLocator(new > MyResourceLocator()); > > } > > } > > > > public class MyResourceLocator extends ResourceStreamLocator { > > > > > > public IResourceStream locate(final Class clazz, final String path) { > > MySession session = MySession.get(); > > IResourceStream located = locateByClassLoader(clazz, > getHtmlPath(path, session.getDevice())); > > return located; > > } > > > > private String getHtmlPath(String path, PlainDevice d) { > > if (<category-1>) { > > return <category-1-folder-path> + > path.substring(path.lastIndexOf("/") + 1); > > } else { > > return <category-2-folder-path> + > path.substring(path.lastIndexOf("/") + 1); > > } > > } > > > > protected IResourceStream locateByClassLoader(final Class clazz, > final String path) { > > ClassLoader classLoader = null; > > > > if (classLoader == null) { > > // use context classloader when no specific classloader is set > > // (package resources for instance) > > classLoader = Thread.currentThread().getContextClassLoader(); > > } > > > > if (clazz != null) { > > classLoader = clazz.getClassLoader(); > > } > > > > if (classLoader == null) { > > // use Wicket classloader when no specific classloader is set > > classLoader = getClass().getClassLoader(); > > } > > > > logger.debug("path : " + path); > > // Try loading path using classloader > > final URL url = classLoader.getResource(path); > > if (url != null) { > > return new UrlResourceStream(url); > > } > > return null; > > } > > } > > > > > > /Anirban > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.339 / Virus Database: 270.12.41/2136 - Release Date: 05/26/09 20:20:00 No virus found in this outgoing message. Checked by AVG - www.avg.com Version: 8.5.339 / Virus Database: 270.12.41/2136 - Release Date: 05/26/09 20:20:00 --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
