Re: custom html page
Hi Martin, Yes, you are very right about that. Thanks. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/custom-html-page-tp2234086p2235861.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: custom html page
Hmm.. I wouldn't use string constants like that... use Class.getName() instead. ** Martin 2010/5/28 msalman : > > Martin, > > Thanks for your response. > > I did try ((CastToYourSession) Session.get()) and that part works. I wanted > to do something as following: > > > public class MyOwnStreamLocator extends ResourceStreamLocator > { > > //protected > > protected App app; > > > > public MyOwnStreamLocator(App app) > { > this.app = app; > } > > > public IResourceStream locate(final Class clazz, final String path) > { > if > (clazz.getName().compareTo("com.michni.wicket.request.search.specificsupplier.PageSpcificSupplierSearchRequest")==0 > ) > { > UserSession session = (UserSession)Session.get(); > > Supplier supplier = session.getSpecificSupplier(); > > if (supplier.getId() == 2) > { > String path2 = > "PageSpcificSupplierSearchRequest_custom.html"; > > IResourceStream located = super.locate(clazz, > trimFolders(path2)); > > if (located != null) > { > return located; > } > } > } > > IResourceStream located = super.locate(clazz, trimFolders(path)); > > if (located != null) > { > return located; > } > located = super.locate(clazz, path); > > return located; > } > > > > But I have found that the locate method for each Page class is called only > once and so what ever html file is set for a Page once is used all the time. > > Is there a way to set the html file location in the Page class? So when > ever that page is constructed the right custom html file is picked. I have > a feeling that the key lies in the MarkupStream but I don't know how to use > it. > > > Thanks. > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/custom-html-page-tp2234086p2234882.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: custom html page
Martin, Thanks for your response. I did try ((CastToYourSession) Session.get()) and that part works. I wanted to do something as following: public class MyOwnStreamLocator extends ResourceStreamLocator { //protected protected App app; public MyOwnStreamLocator(App app) { this.app = app; } public IResourceStream locate(final Class clazz, final String path) { if (clazz.getName().compareTo("com.michni.wicket.request.search.specificsupplier.PageSpcificSupplierSearchRequest")==0 ) { UserSession session = (UserSession)Session.get(); Supplier supplier = session.getSpecificSupplier(); if (supplier.getId() == 2) { String path2 = "PageSpcificSupplierSearchRequest_custom.html"; IResourceStream located = super.locate(clazz, trimFolders(path2)); if (located != null) { return located; } } } IResourceStream located = super.locate(clazz, trimFolders(path)); if (located != null) { return located; } located = super.locate(clazz, path); return located; } But I have found that the locate method for each Page class is called only once and so what ever html file is set for a Page once is used all the time. Is there a way to set the html file location in the Page class? So when ever that page is constructed the right custom html file is picked. I have a feeling that the key lies in the MarkupStream but I don't know how to use it. Thanks. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/custom-html-page-tp2234086p2234882.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: custom html page
Hi! You can always get session ((CastToYourSession) Session.get()) Also wicket has few built-in ways to vary the style of your application: * https://cwiki.apache.org/WICKET/localization-and-skinning-of-applications.html * http://javathoughts.capesugarbird.com/2007/08/branding-wicket-application-take-2.html ** Martin 2010/5/28 msalman : > > Hi, > > Is it possible for a Page to have to have customized html files depending on > certain parameter (user, customer, etc)? I want to allow users to for a > certain page to be able to provide their own html file for that page or > panel. So depending on the user or customer id I can pick up the right html > file and use that. > > I tried to do this in the my ResourceStreamLocator extension class but I > can't get the session object there. I guess that is the place to set the > html location for the application. > > I also found this code on the web. The problem with it is that the > markupStream object passed in is null. > > @Override > protected void onRender(MarkupStream markupStream) > { > markupStream.next(); > try > { > WebRequestCycle cycle = (WebRequestCycle)RequestCycle.get(); > ServletRequest request = > cycle.getWebRequest().getHttpServletRequest(); > ServletResponse response = > cycle.getWebResponse().getHttpServletResponse(); > > > ServletContext context = > ((WebApplication)getApplication()).getServletContext(); > RequestDispatcher rd = > context.getRequestDispatcher("/com/michni/wicket/../specificsupplier_custom.html"); > rd.include(request, response); > > //context.getRequestDispatcher("/" + getId() + > ".html").include(request, response); > } > catch (Exception e) > { > throw new WicketRuntimeException(e); > } > } > > > > Any ideas or suggestions please? > > Thanks, > > -Mohammad > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/custom-html-page-tp2234086p2234086.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
custom html page
Hi, Is it possible for a Page to have to have customized html files depending on certain parameter (user, customer, etc)? I want to allow users to for a certain page to be able to provide their own html file for that page or panel. So depending on the user or customer id I can pick up the right html file and use that. I tried to do this in the my ResourceStreamLocator extension class but I can't get the session object there. I guess that is the place to set the html location for the application. I also found this code on the web. The problem with it is that the markupStream object passed in is null. @Override protected void onRender(MarkupStream markupStream) { markupStream.next(); try { WebRequestCycle cycle = (WebRequestCycle)RequestCycle.get(); ServletRequest request = cycle.getWebRequest().getHttpServletRequest(); ServletResponse response = cycle.getWebResponse().getHttpServletResponse(); ServletContext context = ((WebApplication)getApplication()).getServletContext(); RequestDispatcher rd = context.getRequestDispatcher("/com/michni/wicket/../specificsupplier_custom.html"); rd.include(request, response); //context.getRequestDispatcher("/" + getId() + ".html").include(request, response); } catch (Exception e) { throw new WicketRuntimeException(e); } } Any ideas or suggestions please? Thanks, -Mohammad -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/custom-html-page-tp2234086p2234086.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org