Re: Re: Re: @Asset problem
Thank you all... Will try them all out. Srini. On 11/28/06, Sam Gendler <[EMAIL PROTECTED]> wrote: Incidentally, in our case, we have a mechanism within spring that will detect the existence of a context file in a location outside the war file and use that to override bean definitions in the context file(s) inside the war file. I don't konw that such a mechanism is possible within hivemind (but it probably is), and even without it, it is much easier to modify an xml file in a war file when you deploy than it is to recompile a java class and push that into the war. --sam
Re: Re: Re: @Asset problem
Incidentally, in our case, we have a mechanism within spring that will detect the existence of a context file in a location outside the war file and use that to override bean definitions in the context file(s) inside the war file. I don't konw that such a mechanism is possible within hivemind (but it probably is), and even without it, it is much easier to modify an xml file in a war file when you deploy than it is to recompile a java class and push that into the war. --sam On 11/28/06, Sam Gendler <[EMAIL PROTECTED]> wrote: OK, here's a bit of a convoluted solution, but it works. In my case, I'm using spring, but you could do the exact same thing within hivemind. I've got an object that has some string properties that I want to configure at run time. Let's call is CssOverrides. It can be populated with a list of strings from the config file (either applicationContext.xml or hivemodule.xml). Inject that object into your Header component: @InjectObject("spring:cssOverrides") public abstract CssOverrides getCssOverrides(); Then I've got the following code in my Header component. public void finishLoad(IRequestCycle cycle, IPageLoader loader, IComponentSpecification specification) { super.finishLoad(cycle, loader, specification); CssOverrides overrides = getCssOverrides(); if (overrides!=null && overrides.getCssFileList()!=null) { int i = 0; additionalStylesheets = new ArrayList(overrides.getCssFileList().size()); for (String cssFile : overrides.getCssFileList()) { if (cssFile==null || cssFile.length()==0) { continue; } IAsset styleAsset; if (PageUtils.isAbsoluteUrl(cssFile)) { styleAsset = new ExternalAsset(cssFile, getLocation()); } else { if (!cssFile.startsWith("/")) { cssFile = "/" + cssFile; //pathinfo must start with '/' } styleAsset = new ContextAsset( getWebRequest().getContextPath(), new ContextResource(getServletContext(), cssFile), getLocation(), cycle); } additionalStylesheets.add(styleAsset); } } } You've now got a list of IAssets in the additionalStylesheets list, and you can use them just as you would a normal asset. In our case, we've got defaults that specifically uglify the interface and then override them with the correct values in the production environment. This makes it readily apparent when you are working on a production box and when you are on a dev or qa box. --sam On 11/27/06, andyhot <[EMAIL PROTECTED]> wrote: > Srinivas Yermal wrote: > > Thanks guys! > > I think I will just go with the "putting it in html" solution. The only > > problem with this is that it creates two head elements, since I use > > @Shell. > > http://wiki.apache.org/tapestry/CustomTagsInShell > > > > > BTW, I couldnt find import component or annotation. Can you please > > point me > > to any documentation that you have. > > > > Thanks, > > Srini. > > > > On 11/27/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >> > >> We do something similar; you can have your @Border *always* pull in a > >> single stylesheet that has a single line: > >> > >> @import ("http://your.style.server/blah.css";) > >> > >> You host blah.css off Apache (or Tomcat, or whatever) outside of the > >> context of your webapp and change at will. You can use nested @imports > >> (e.g., blah.css is maybe just a collection of @imports as well). > >> > >> HTH, > >> Tom > >> > > > > > -- > Andreas Andreou - [EMAIL PROTECTED] - http://andyhot.di.uoa.gr > Tapestry / Tacos developer > Open Source / J2EE Consulting > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: @Asset problem
OK, here's a bit of a convoluted solution, but it works. In my case, I'm using spring, but you could do the exact same thing within hivemind. I've got an object that has some string properties that I want to configure at run time. Let's call is CssOverrides. It can be populated with a list of strings from the config file (either applicationContext.xml or hivemodule.xml). Inject that object into your Header component: @InjectObject("spring:cssOverrides") public abstract CssOverrides getCssOverrides(); Then I've got the following code in my Header component. public void finishLoad(IRequestCycle cycle, IPageLoader loader, IComponentSpecification specification) { super.finishLoad(cycle, loader, specification); CssOverrides overrides = getCssOverrides(); if (overrides!=null && overrides.getCssFileList()!=null) { int i = 0; additionalStylesheets = new ArrayList(overrides.getCssFileList().size()); for (String cssFile : overrides.getCssFileList()) { if (cssFile==null || cssFile.length()==0) { continue; } IAsset styleAsset; if (PageUtils.isAbsoluteUrl(cssFile)) { styleAsset = new ExternalAsset(cssFile, getLocation()); } else { if (!cssFile.startsWith("/")) { cssFile = "/" + cssFile; //pathinfo must start with '/' } styleAsset = new ContextAsset( getWebRequest().getContextPath(), new ContextResource(getServletContext(), cssFile), getLocation(), cycle); } additionalStylesheets.add(styleAsset); } } } You've now got a list of IAssets in the additionalStylesheets list, and you can use them just as you would a normal asset. In our case, we've got defaults that specifically uglify the interface and then override them with the correct values in the production environment. This makes it readily apparent when you are working on a production box and when you are on a dev or qa box. --sam On 11/27/06, andyhot <[EMAIL PROTECTED]> wrote: Srinivas Yermal wrote: > Thanks guys! > I think I will just go with the "putting it in html" solution. The only > problem with this is that it creates two head elements, since I use > @Shell. http://wiki.apache.org/tapestry/CustomTagsInShell > > BTW, I couldnt find import component or annotation. Can you please > point me > to any documentation that you have. > > Thanks, > Srini. > > On 11/27/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> >> We do something similar; you can have your @Border *always* pull in a >> single stylesheet that has a single line: >> >> @import ("http://your.style.server/blah.css";) >> >> You host blah.css off Apache (or Tomcat, or whatever) outside of the >> context of your webapp and change at will. You can use nested @imports >> (e.g., blah.css is maybe just a collection of @imports as well). >> >> HTH, >> Tom >> > -- Andreas Andreou - [EMAIL PROTECTED] - http://andyhot.di.uoa.gr Tapestry / Tacos developer Open Source / J2EE Consulting - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]