you should use session.setstyle() and have a seperate style per screen resolution variant
-igor 2009/5/26 Anirban Basak <[email protected]>: > Hi! > > I’m 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. I’m 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]
