Re: How to NOT cause a hot redeploy with Jetty when HTML files change
Thanks for the tips. This is working much better for me now and I'm now much more productive. -- Jason Martijn Dashorst wrote: Not recommended per se, but it works for me. However, it will not reload structural changes, you'll need to restart jetty when you add a property, method, or change the signature of a method, etc. The debugger can only modify the contents of methods, not add them (unfortunately). The reloading filter should mitigate that, but I haven't used it. Martijn On 10/5/07, Jason Mihalick [EMAIL PROTECTED] wrote: Thanks Eelco. However, I am using the Maven Jetty plugin (http://www.mortbay.org/maven-plugin/index.html) for jetty usage under Maven. Perhaps that is what you meant. I am also using the Maven2 eclipse plugin (http://m2eclipse.codehaus.org/) for dependency management within eclipse, but that plugin is not affecting this problem. So is using Martin's suggestion the preferred way to develop with Wicket under Eclipse and it will avoid my reloading issues? Thanks for the replies. I'm really enjoying development with Wicket. -- Jason Eelco Hillenius wrote: I think most developers have given up on using the eclipse jetty plugin, and use an embedded container instead. Jason uses the Maven Eclipse plugin, which is a completely different bird, and which actually is used by quite a few developers from what I hear. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/How-to-NOT-cause-a-hot-redeploy-with-Jetty-when-HTML-files-change-tf4571849.html#a13057239 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Buy Wicket in Action: http://manning.com/dashorst Apache Wicket 1.3.0-beta3 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/How-to-NOT-cause-a-hot-redeploy-with-Jetty-when-HTML-files-change-tf4571849.html#a13072479 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to NOT cause a hot redeploy with Jetty when HTML files change
Thanks Eelco. However, I am using the Maven Jetty plugin (http://www.mortbay.org/maven-plugin/index.html) for jetty usage under Maven. Perhaps that is what you meant. I am also using the Maven2 eclipse plugin (http://m2eclipse.codehaus.org/) for dependency management within eclipse, but that plugin is not affecting this problem. So is using Martin's suggestion the preferred way to develop with Wicket under Eclipse and it will avoid my reloading issues? Thanks for the replies. I'm really enjoying development with Wicket. -- Jason Eelco Hillenius wrote: I think most developers have given up on using the eclipse jetty plugin, and use an embedded container instead. Jason uses the Maven Eclipse plugin, which is a completely different bird, and which actually is used by quite a few developers from what I hear. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/How-to-NOT-cause-a-hot-redeploy-with-Jetty-when-HTML-files-change-tf4571849.html#a13057239 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to NOT cause a hot redeploy with Jetty when HTML files change
I have been successfully developing a Wicket application with Eclipse, Maven, and the Maven Jetty plugin with hot redeploy enabled. However, I don't want Jetty to do a hot redeploy of the application when I make a change to my HTML files. I assume that Wicket will pick up these changes automatically when running in Development mode, so there should be no need to reload the whole app. I have both Eclipse and Maven compiling classes to the same directory (target/classes) so that when I make a change to a class in eclipse, Jetty picks up the change and does a hot redeploy. This is a good thing. Since my HTML files are located along side my classes, my HTML files are also automatically copied by eclipse into my target/classes dir structure. This should be a good thing too, but read on... The problem is that whenever an HTML file changes and eclipse copies it to my target/classes dir, jetty picks this up and reploys the application. I've tried adding a ScanTargetPatterns section to my jetty plugin configuration, but it doesn't work. Here is what I added: scanTargetPatterns scanTargetPattern directorytarget/classes/directory excludes exclude**/*.html/exclude /excludes /scanTargetPattern /scanTargetPatterns Has anyone else got this to work, and if so, how? Your help is much appreciated. -- Jason -- View this message in context: http://www.nabble.com/How-to-NOT-cause-a-hot-redeploy-with-Jetty-when-HTML-files-change-tf4571849.html#a13049928 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Updating a Dynamic Image with AJAX (and JFreeChart)
I am integrating JFreeChart into my application and I've followed the JFreeChart example on the wiki. That works very nicely. I was impressed. What I want to do now is update the graph that I display based on the selection from a drop down list. I've successfully added the DropDownChoice component and added a AjaxFormComponentUpdatingBehavior to it. I've verified that my onUpdate( AjaxRequestTarget ) method is being invoked and I'm receiving the updated value, which is very cool. Here is my onUpdate implementation for the DropDownChoice control: protected void onUpdate( AjaxRequestTarget target ) { log.debug( graphStyles onUpdate invoked! SelectedGraphStyle = + FieldResultsPanel.this.getSelectedGraphStyle() ); FieldResultsPanel.this.updateGraph(); // Update the model and re-create the JFreeChart Image // fieldGraph is my JFreeChartImage instance (derived from Image) // This is supposed to indicate back to the browser that the image needs updated. I think this // is working properly target.addComponent( FieldResultsPanel.this.fieldGraph ); } Even though I am updating the model of my JFreeChartImage, it appears that the getImageData method is never invoked afterwards. What do I need to do in order to get the image data to be re-read? Here is my JFreeChartImage class: public class JFreeChartImage extends Image { private static final Logger log = LoggerFactory.getLogger( JFreeChartImage.class ); private int width; private int height; public JFreeChartImage( String id ) { super( id ); } public JFreeChartImage( String id, int width, int height ) { this( id ); this.width = width; this.height = height; } public JFreeChartImage( String id, JFreeChart chart, int width, int height ) { super(id, new Model( chart ) ); this.width = width; this.height = height; } public Component setModel( JFreeChart chart ) { log.debug( setModel invoked with chart: + chart ); return super.setModel( new Model( chart ) ); } @Override protected Resource getImageResource() { return new DynamicImageResource(){ private static final long serialVersionUID = 1L; @Override protected byte[] getImageData() { log.debug( Invoking getImageData... ); JFreeChart chart = (JFreeChart)getModelObject(); log.debug( Chart object: + chart ); return toImageData( chart.createBufferedImage( width, height ) ); } @Override protected void setHeaders( WebResponse response ) { if ( isCacheable() ) { super.setHeaders(response); } else { response.setHeader( Pragma, no-cache ); response.setHeader( Cache-Control, no-cache ); response.setDateHeader( Expires, 0 ); } } }; } Any help is much appreciated! -- Jason -- View this message in context: http://www.nabble.com/Updating-a-Dynamic-Image-with-AJAX-%28and-JFreeChart%29-tf4517009.html#a12884455 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Updating a Dynamic Image with AJAX (and JFreeChart)
Thanks for the tip. That worked! That was too easy. :-) -- Jason David Bernard-2 wrote: Hi, Have you try to extend NonCachingImage instead of Image (and comments setHeaders(...))? /david Jason Mihalick wrote: I am integrating JFreeChart into my application and I've followed the JFreeChart example on the wiki. That works very nicely. I was impressed. What I want to do now is update the graph that I display based on the selection from a drop down list. I've successfully added the DropDownChoice component and added a AjaxFormComponentUpdatingBehavior to it. I've verified that my onUpdate( AjaxRequestTarget ) method is being invoked and I'm receiving the updated value, which is very cool. Here is my onUpdate implementation for the DropDownChoice control: protected void onUpdate( AjaxRequestTarget target ) { log.debug( graphStyles onUpdate invoked! SelectedGraphStyle = + FieldResultsPanel.this.getSelectedGraphStyle() ); FieldResultsPanel.this.updateGraph(); // Update the model and re-create the JFreeChart Image // fieldGraph is my JFreeChartImage instance (derived from Image) // This is supposed to indicate back to the browser that the image needs updated. I think this // is working properly target.addComponent( FieldResultsPanel.this.fieldGraph ); } Even though I am updating the model of my JFreeChartImage, it appears that the getImageData method is never invoked afterwards. What do I need to do in order to get the image data to be re-read? Here is my JFreeChartImage class: public class JFreeChartImage extends Image { private static final Logger log = LoggerFactory.getLogger( JFreeChartImage.class ); private int width; private int height; public JFreeChartImage( String id ) { super( id ); } public JFreeChartImage( String id, int width, int height ) { this( id ); this.width = width; this.height = height; } public JFreeChartImage( String id, JFreeChart chart, int width, int height ) { super(id, new Model( chart ) ); this.width = width; this.height = height; } public Component setModel( JFreeChart chart ) { log.debug( setModel invoked with chart: + chart ); return super.setModel( new Model( chart ) ); } @Override protected Resource getImageResource() { return new DynamicImageResource(){ private static final long serialVersionUID = 1L; @Override protected byte[] getImageData() { log.debug( Invoking getImageData... ); JFreeChart chart = (JFreeChart)getModelObject(); log.debug( Chart object: + chart ); return toImageData( chart.createBufferedImage( width, height ) ); } @Override protected void setHeaders( WebResponse response ) { if ( isCacheable() ) { super.setHeaders(response); } else { response.setHeader( Pragma, no-cache ); response.setHeader( Cache-Control, no-cache ); response.setDateHeader( Expires, 0 ); } } }; } Any help is much appreciated! -- Jason - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Updating-a-Dynamic-Image-with-AJAX-%28and-JFreeChart%29-tf4517009.html#a12885649 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to render character entities such as nbsp
Thanks to all for the feedback on this. I ended up solving my issue with a combination of the two approaches. I hadn't noticed the setEscapeModelStrings method, so I definitely appreciate you pointing it out. Very handy. -- Jason Eelco Hillenius wrote: Is it possible to render a character entity such as nbsp; in a Label? I've tried a few things, but I can't seem to get it to happen. setEscapeModelStrings(false) Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/How-to-render-character-entities-such-as-nbsp-tf4433127.html#a12727886 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Locating CSS under WEB-INF, please help
Rüdiger, Thanks for posting this information. It's given me some new ideas on how I want to work with Wicket and Dreamweaver, as it just so happens that we are using Dreamweaver as well. -- Jason Rüdiger_Schulz wrote: 2007/9/10, Jason Mihalick [EMAIL PROTECTED]: Thanks Rüdiger. I'm trying the wicket:remove method now. Very clever. Do you know of any links to documentation or examples on how to use the live method for css, js, and image resources? I don't have a real example I can give you at the moment, sorry. I blogged a little about how we used Dreamweaver and Wicket in our project here: http://www.2rue.de/hacking/wicket/leveraging-wicket-templates-for-offline-viewing-with-dreamweaver/ We use a lot of wicket:remove and other stuff in our templates, because that way we can do most of the styling and cross-browser testing (which is always a PITA) using just an html editor and a browser. And as far as I am concerned, it is really worth it. You can point all your links and images to offline resources, as long as you bind that tag to a wicket component. Wicket normally doesn't care what your src attribute in an is when you e.g. bind it to a org.apache.wicket.markup.html.image.Image I planned to write more about this topic though, as I'm really convinced that this is one of the really great features of Wicket. -- Jason Rüdiger_Schulz wrote: Another tipp on this topic: You could provide the CSS twice. Once within a wicket:remove for offline preview and editing, and again outside that pointing to an url which works only on your live environment. Or you can add the live CSS with a header contributor in your base page. I use the latter one, but I have my CSS located along with my java files... 2007/9/10, Jason Mihalick [EMAIL PROTECTED]: Thanks for the reply. Where are your css resources located under this configuration? I have a similar setup. I have a BasePage.html that refers to the css: head meta http-equiv=Content-Type content=text/html; charset=UTF-8 / !-- Stylesheets -- link href=css/styles.cssrel=stylesheet type=text/css / ... /head But since my BasePage.html is located with my Java classes (at src/main/java/com///ui/web/page/BasePage.html) and my css resources are located at src/main/webapp/css , if I try to load the BasePage.htmlfile in an HTML editor, it will be unable to resolve the css resources. -- Jason Johan Maasing-2 wrote: Perhaps template inheritance can help you here. I have a 'base' page that contains the HTML head tag that all my pages use. For example I have a Basepage.html: html xmlns=http://www.w3.org/1999/xhtml; xmlns:wicket=http://wicket.apache.org/; head link rel=stylesheet type=text/css href=css/main.css/ link rel=stylesheet type=text/css href=css/header.css/ /head body wicket:child / ... and a Basepage.java (which does some stuff common to all pages, like setting a feedbackpanel or whatever you like to have for all pages) Then in my real pages I do like this RealPage.java public class Index extends BasePage { public Index() { ... but the real funny stuff goes on in the template for the real page: html xmlns=http://www.w3.org/1999/xhtml; xmlns:wicket=http://wicket.apache.org/; head link rel=stylesheet type=text/css href=../../../../../../WebContent/css/main.css/ link rel=stylesheet type=text/css href=../../../../../../WebContent/css/header.css/ /head body wicket:extend Real content here /wicket:extend /body ... In this way the template can be edited as a static HTML and include the right CSS relative to the sources in the filesystem. In runtime wicket will discard anythiong outside the wicket:extend in the template and use the HTML from the 'base' page. Hope this can help you somewhat. Cheers, Johan M On 9/10/07, Jason Mihalick [EMAIL PROTECTED] wrote: sigh Ok, thanks for the help on this. My objective was to be able to have a structure of HTML and resource dependencies (css, js, img, etc) that could be easily edited in an HTML editor such that the editor doesn't have problems resolving the resources and such that Wicket doesn't have problems resolving the resources. From reading your comments and those of others, however, this doesn't seem to be an easy task at all. So, I've gone back to the standard Wicket approach where I have placed all HTML files along side my Java classes and have located my resources (css, js, img, etc) at the root of my web context (in the maven world, this is under the webapp dir, as a sibling to WEB-INF). This keeps Wicket very happy at runtime, but makes it difficult
How to render character entities such as nbsp
Is it possible to render a character entity such as nbsp; in a Label? I've tried a few things, but I can't seem to get it to happen. I am working with the PageableListView and AjaxPagingNavigator and trying to get the AjaxPagingNavigator to render in a fixed location at the bottom of the HTML rows that are bound to the PageableListView. The way it seems to work by default is that the AjaxPagingNavigator renders at the bottom of the table and when there are less rows on the last page than the rowsPerPage given to the PageableListView constructor, the AjaxPagingNavigator renders higher on the page since there aren't enough rows on the page to meet the rowsPerPage count specified. My quick fix for this was going to be to render blank rows using nbsp; in order to fill out the table and keep a consistent size for the table, but I haven't seen a way to do this yet. If there's another approach to achieving my above desired result, please feel free to offer your suggestion. Thanks in advance, Jason -- View this message in context: http://www.nabble.com/How-to-render-character-entities-such-as-nbsp-tf4433127.html#a12647458 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Locating CSS under WEB-INF, please help
sigh Ok, thanks for the help on this. My objective was to be able to have a structure of HTML and resource dependencies (css, js, img, etc) that could be easily edited in an HTML editor such that the editor doesn't have problems resolving the resources and such that Wicket doesn't have problems resolving the resources. From reading your comments and those of others, however, this doesn't seem to be an easy task at all. So, I've gone back to the standard Wicket approach where I have placed all HTML files along side my Java classes and have located my resources (css, js, img, etc) at the root of my web context (in the maven world, this is under the webapp dir, as a sibling to WEB-INF). This keeps Wicket very happy at runtime, but makes it difficult for me to edit my site using a HTML editor. Maybe this won't be that big of a deal in practice. I guess I will find out in time. Thanks again guys! igor.vaynberg wrote: oi. the basic problem is that WEB-INF is inaccessible via direct urls. this is because it houses stuff like classes and you dont want the user to have access to those. so there is a way to make it work, but it will involve wicket or another servlet streaming those static resources, which is a lot of overhead. my suggestion is to move all the css/js/foo out of WEB-INF -igor On 9/8/07, Jason Mihalick [EMAIL PROTECTED] wrote: I've been searching the forums and wiki on this half the night and I just can't figure out what I'm doing wrong here, so please bear with me if there is an obvious answer to this. Wicket is not finding my css or js resources when the application is deployed. I followed the wiki instructions for Wicket 1.3 on how to Control where HTML files are loaded from ( http://cwiki.apache.org/WICKET/control-where-html-files-are-loaded-from.html#ControlwhereHTMLfilesareloadedfrom-InWicket1.3 ). I have the following structure under WEB-INF: WEB-INF/ +--- content/ +--- css/ +--- help/ +--- img/ +--- js/ BasePage.html Page1.html Page2.html etc. web.xml In the init() method of my application class, I have added this code as per the wiki: IResourceSettings resourceSettings = this.getResourceSettings(); resourceSettings.addResourceFolder( WEB-INF/content ); resourceSettings.setResourceStreamLocator( new PathStripperLocator() ); My implementation of the PathStripperLocator class matches that found on the wiki. When I view the source of Page1.html (which inherits from my BasePage) in my browser after wicket has served it, I see that Wicket is rewriting the location of the css resources as follows: link href=../css/styles.css rel=stylesheet type=text/css/ I expected the href value to instead be css/styles.css (without the ../). What do I need to do here in order to make this work? Your help is greatly appreciated! -- Jason -- View this message in context: http://www.nabble.com/Locating-CSS-under-WEB-INF%2C-please-help-tf4408084.html#a12575952 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Locating-CSS-under-WEB-INF%2C-please-help-tf4408084.html#a12592027 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Locating CSS under WEB-INF, please help
Thanks for the reply. Where are your css resources located under this configuration? I have a similar setup. I have a BasePage.html that refers to the css: head meta http-equiv=Content-Type content=text/html; charset=UTF-8 / !-- Stylesheets -- link href=css/styles.cssrel=stylesheet type=text/css / ... /head But since my BasePage.html is located with my Java classes (at src/main/java/com///ui/web/page/BasePage.html) and my css resources are located at src/main/webapp/css , if I try to load the BasePage.html file in an HTML editor, it will be unable to resolve the css resources. -- Jason Johan Maasing-2 wrote: Perhaps template inheritance can help you here. I have a 'base' page that contains the HTML head tag that all my pages use. For example I have a Basepage.html: html xmlns=http://www.w3.org/1999/xhtml; xmlns:wicket=http://wicket.apache.org/; head link rel=stylesheet type=text/css href=css/main.css/ link rel=stylesheet type=text/css href=css/header.css/ /head body wicket:child / ... and a Basepage.java (which does some stuff common to all pages, like setting a feedbackpanel or whatever you like to have for all pages) Then in my real pages I do like this RealPage.java public class Index extends BasePage { public Index() { ... but the real funny stuff goes on in the template for the real page: html xmlns=http://www.w3.org/1999/xhtml; xmlns:wicket=http://wicket.apache.org/; head link rel=stylesheet type=text/css href=../../../../../../WebContent/css/main.css/ link rel=stylesheet type=text/css href=../../../../../../WebContent/css/header.css/ /head body wicket:extend Real content here /wicket:extend /body ... In this way the template can be edited as a static HTML and include the right CSS relative to the sources in the filesystem. In runtime wicket will discard anythiong outside the wicket:extend in the template and use the HTML from the 'base' page. Hope this can help you somewhat. Cheers, Johan M On 9/10/07, Jason Mihalick [EMAIL PROTECTED] wrote: sigh Ok, thanks for the help on this. My objective was to be able to have a structure of HTML and resource dependencies (css, js, img, etc) that could be easily edited in an HTML editor such that the editor doesn't have problems resolving the resources and such that Wicket doesn't have problems resolving the resources. From reading your comments and those of others, however, this doesn't seem to be an easy task at all. So, I've gone back to the standard Wicket approach where I have placed all HTML files along side my Java classes and have located my resources (css, js, img, etc) at the root of my web context (in the maven world, this is under the webapp dir, as a sibling to WEB-INF). This keeps Wicket very happy at runtime, but makes it difficult for me to edit my site using a HTML editor. Maybe this won't be that big of a deal in practice. I guess I will find out in time. Thanks again guys! igor.vaynberg wrote: oi. the basic problem is that WEB-INF is inaccessible via direct urls. this is because it houses stuff like classes and you dont want the user to have access to those. so there is a way to make it work, but it will involve wicket or another servlet streaming those static resources, which is a lot of overhead. my suggestion is to move all the css/js/foo out of WEB-INF -igor On 9/8/07, Jason Mihalick [EMAIL PROTECTED] wrote: I've been searching the forums and wiki on this half the night and I just can't figure out what I'm doing wrong here, so please bear with me if there is an obvious answer to this. Wicket is not finding my css or js resources when the application is deployed. I followed the wiki instructions for Wicket 1.3 on how to Control where HTML files are loaded from ( http://cwiki.apache.org/WICKET/control-where-html-files-are-loaded-from.html#ControlwhereHTMLfilesareloadedfrom-InWicket1.3 ). I have the following structure under WEB-INF: WEB-INF/ +--- content/ +--- css/ +--- help/ +--- img/ +--- js/ BasePage.html Page1.html Page2.html etc. web.xml In the init() method of my application class, I have added this code as per the wiki: IResourceSettings resourceSettings = this.getResourceSettings(); resourceSettings.addResourceFolder( WEB-INF/content ); resourceSettings.setResourceStreamLocator( new PathStripperLocator() ); My implementation of the PathStripperLocator class matches that found on the wiki. When I view the source of Page1.html (which inherits from my BasePage) in my browser after wicket has served it, I see that Wicket is rewriting the location of the css resources as follows: link href=../css/styles.css rel
Re: Locating CSS under WEB-INF, please help
Thanks Rüdiger. I'm trying the wicket:remove method now. Very clever. Do you know of any links to documentation or examples on how to use the live method for css, js, and image resources? -- Jason Rüdiger_Schulz wrote: Another tipp on this topic: You could provide the CSS twice. Once within a wicket:remove for offline preview and editing, and again outside that pointing to an url which works only on your live environment. Or you can add the live CSS with a header contributor in your base page. I use the latter one, but I have my CSS located along with my java files... 2007/9/10, Jason Mihalick [EMAIL PROTECTED]: Thanks for the reply. Where are your css resources located under this configuration? I have a similar setup. I have a BasePage.html that refers to the css: head meta http-equiv=Content-Type content=text/html; charset=UTF-8 / !-- Stylesheets -- link href=css/styles.cssrel=stylesheet type=text/css / ... /head But since my BasePage.html is located with my Java classes (at src/main/java/com///ui/web/page/BasePage.html) and my css resources are located at src/main/webapp/css , if I try to load the BasePage.htmlfile in an HTML editor, it will be unable to resolve the css resources. -- Jason Johan Maasing-2 wrote: Perhaps template inheritance can help you here. I have a 'base' page that contains the HTML head tag that all my pages use. For example I have a Basepage.html: html xmlns=http://www.w3.org/1999/xhtml; xmlns:wicket=http://wicket.apache.org/; head link rel=stylesheet type=text/css href=css/main.css/ link rel=stylesheet type=text/css href=css/header.css/ /head body wicket:child / ... and a Basepage.java (which does some stuff common to all pages, like setting a feedbackpanel or whatever you like to have for all pages) Then in my real pages I do like this RealPage.java public class Index extends BasePage { public Index() { ... but the real funny stuff goes on in the template for the real page: html xmlns=http://www.w3.org/1999/xhtml; xmlns:wicket=http://wicket.apache.org/; head link rel=stylesheet type=text/css href=../../../../../../WebContent/css/main.css/ link rel=stylesheet type=text/css href=../../../../../../WebContent/css/header.css/ /head body wicket:extend Real content here /wicket:extend /body ... In this way the template can be edited as a static HTML and include the right CSS relative to the sources in the filesystem. In runtime wicket will discard anythiong outside the wicket:extend in the template and use the HTML from the 'base' page. Hope this can help you somewhat. Cheers, Johan M On 9/10/07, Jason Mihalick [EMAIL PROTECTED] wrote: sigh Ok, thanks for the help on this. My objective was to be able to have a structure of HTML and resource dependencies (css, js, img, etc) that could be easily edited in an HTML editor such that the editor doesn't have problems resolving the resources and such that Wicket doesn't have problems resolving the resources. From reading your comments and those of others, however, this doesn't seem to be an easy task at all. So, I've gone back to the standard Wicket approach where I have placed all HTML files along side my Java classes and have located my resources (css, js, img, etc) at the root of my web context (in the maven world, this is under the webapp dir, as a sibling to WEB-INF). This keeps Wicket very happy at runtime, but makes it difficult for me to edit my site using a HTML editor. Maybe this won't be that big of a deal in practice. I guess I will find out in time. Thanks again guys! igor.vaynberg wrote: oi. the basic problem is that WEB-INF is inaccessible via direct urls. this is because it houses stuff like classes and you dont want the user to have access to those. so there is a way to make it work, but it will involve wicket or another servlet streaming those static resources, which is a lot of overhead. my suggestion is to move all the css/js/foo out of WEB-INF -igor On 9/8/07, Jason Mihalick [EMAIL PROTECTED] wrote: I've been searching the forums and wiki on this half the night and I just can't figure out what I'm doing wrong here, so please bear with me if there is an obvious answer to this. Wicket is not finding my css or js resources when the application is deployed. I followed the wiki instructions for Wicket 1.3 on how to Control where HTML files are loaded from ( http://cwiki.apache.org/WICKET/control-where-html-files-are-loaded-from.html#ControlwhereHTMLfilesareloadedfrom-InWicket1.3 ). I have the following structure under WEB-INF: WEB-INF/ +--- content/ +--- css
Re: Using Include and placing pages under WEB-INF
Ah, that's true, wicket takes care of resolving the URL and including the content. I see your point. My concern was for containers that don't explode the WAR when deployed, but I think yours should work for that too, and it avoids the subclass. Thanks! Jason Mihalick wrote: Thanks, yes, my solution was close to this, but I opted instead to subclass the Include class. I think the solution that you propose below may cause wicket to create an absolute URL to the HTML files under the WEB-INF dir which will be inaccessible by the browser. /quote No. The URL is never sent to the browser. In fact, logically your code is exactly the same as mine. -- View this message in context: http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12576277 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: AW: Locating CSS under WEB-INF, please help
If I remove this code: IResourceSettings resourceSettings = this.getResourceSettings(); resourceSettings.addResourceFolder( WEB-INF/content ); resourceSettings.setResourceStreamLocator( new then Wicket cannot find my pages (i.e., BasePage.html, Page1.html, Page2.html), which are located under the content dir. I.e., my pages are located at: WEB-INF/content/BasePage.html WEB-INF/content/Page1.html WEB-INF/content/Page2.html Exception that I get: WicketMessage: Markup of type 'html' for component 'com.x.ui.web.page.HomePage' not found. Enable debug messages for org.apache.wicket.util.resource to get a list of all filenames tried: I tried your suggestion below: link rel=stylesheet type=text/css href=WEB-INF/content/css/style.css/ and I still have the same problem. The css resources are not resolved, and Wicket is altering the link tag to this: link rel=stylesheet type=text/css href=../WEB-INF/content/css/styles.css/ Can you think of anything else that I should look at? Thanks for the continued help. -- Jason Stefan Lindner wrote: You don't need the IResourceSettings resourceSettings = this.getResourceSettings(); resourceSettings.addResourceFolder( WEB-INF/content ); resourceSettings.setResourceStreamLocator( new In your application. The path to your resource is the relative to the root of your war file. In your example: If your style.css is at to level just write head wicket:head link rel=stylesheet type=text/css href=style.css/ /wicket:head /head If your style.css is at WEB-INF/ +--- content/ +--- css/ head wicket:head link rel=stylesheet type=text/css href=WEB-INF/content/css/style.css/ /wicket:head /head This works perfectly for me. WEB-INF/ +--- content/ +--- css/ +--- help/ +--- img/ +--- js/ BasePage.html Page1.html Page2.html etc. web.xml -Ursprüngliche Nachricht- Von: Jason Mihalick [mailto:[EMAIL PROTECTED] Gesendet: Sonntag, 9. September 2007 13:59 An: users@wicket.apache.org Betreff: Re: AW: Locating CSS under WEB-INF, please help Hi Stefan. Thanks for the reply. What you suggest is exactly what I have in my BasePage.html, which renders my css and js resources just fine when I point a browser directly at BasePage.html. Is that what you meant by yourpath/your.css? Here is my raw markup from BasePage.html: head meta http-equiv=Content-Type content=text/html; charset=UTF-8 / !-- Stylesheets -- link href=css/styles.cssrel=stylesheet type=text/css / titlePage Title/title /head For some reason, the Wicket runtime is changing the above href from css/styles.css to ../css/styles.css Any other ideas? Thanks, Jason Stefan Lindner wrote: Why don't you just put the following code into the head-part of your BasePage? head link rel=stylesheet type=text/css href=yourpath/your.css / /head Wicket does not touch thie header if it's the head in your BasePage. If you place some panels at your page and the panels should use their own css files you can make wicket add the panel's head to the main head section with head wicket:head link rel=stylesheet type=text/css href=yourpath/yourpanel.css/ script language=JavaScript type=text/javascript src=yourpath/yourscript.js/script /wicket:head /head -Ursprüngliche Nachricht- Von: Jason Mihalick [mailto:[EMAIL PROTECTED] Gesendet: Sonntag, 9. September 2007 06:37 An: users@wicket.apache.org Betreff: Locating CSS under WEB-INF, please help I've been searching the forums and wiki on this half the night and I just can't figure out what I'm doing wrong here, so please bear with me if there is an obvious answer to this. Wicket is not finding my css or js resources when the application is deployed. I followed the wiki instructions for Wicket 1.3 on how to Control where HTML files are loaded from (http://cwiki.apache.org/WICKET/control-where-html-files-are-loaded-from.html#ControlwhereHTMLfilesareloadedfrom-InWicket1.3). I have the following structure under WEB-INF: WEB-INF/ +--- content/ +--- css/ +--- help/ +--- img/ +--- js/ BasePage.html Page1.html Page2.html etc. web.xml In the init() method of my application class, I have added this code as per the wiki: IResourceSettings resourceSettings = this.getResourceSettings(); resourceSettings.addResourceFolder( WEB-INF/content ); resourceSettings.setResourceStreamLocator( new PathStripperLocator() ); My implementation of the PathStripperLocator class matches that found on the wiki. When
Re: Using Include and placing pages under WEB-INF
Thank you for the suggestion. This looks like it ought to work fine for exploded WARs, but it seems like it would be a problem when then app is deployed in a WAR. Is there any way to do this that will work when the app is deployed in a WAR archive? Or is there perhaps another wicket component that I should be using that won't require me to create a companion Java class for each help snippet? Thanks. -- Jason Kent Tong wrote: Jason Mihalick wrote: However, if I try to move my pages under WEB-INF, wicket has a problem loading resources that are bound via the org.apache.wicket.markup.html.include.Include class. In my case, I have several static pages that I want to load dynamically which are located in my 'help/' directory (see above). Try: File context = new File(((WebApplication)getApplication()).getServletContext().getRealPath(/)); File file = new File(context, WEB-INF/help/Topic1.html); Include i = new Include(i, file.toURL().toString()); -- View this message in context: http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12574436 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Locating CSS under WEB-INF, please help
I've been searching the forums and wiki on this half the night and I just can't figure out what I'm doing wrong here, so please bear with me if there is an obvious answer to this. Wicket is not finding my css or js resources when the application is deployed. I followed the wiki instructions for Wicket 1.3 on how to Control where HTML files are loaded from (http://cwiki.apache.org/WICKET/control-where-html-files-are-loaded-from.html#ControlwhereHTMLfilesareloadedfrom-InWicket1.3). I have the following structure under WEB-INF: WEB-INF/ +--- content/ +--- css/ +--- help/ +--- img/ +--- js/ BasePage.html Page1.html Page2.html etc. web.xml In the init() method of my application class, I have added this code as per the wiki: IResourceSettings resourceSettings = this.getResourceSettings(); resourceSettings.addResourceFolder( WEB-INF/content ); resourceSettings.setResourceStreamLocator( new PathStripperLocator() ); My implementation of the PathStripperLocator class matches that found on the wiki. When I view the source of Page1.html (which inherits from my BasePage) in my browser after wicket has served it, I see that Wicket is rewriting the location of the css resources as follows: link href=../css/styles.css rel=stylesheet type=text/css/ I expected the href value to instead be css/styles.css (without the ../). What do I need to do here in order to make this work? Your help is greatly appreciated! -- Jason -- View this message in context: http://www.nabble.com/Locating-CSS-under-WEB-INF%2C-please-help-tf4408084.html#a12575952 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using Include and placing pages under WEB-INF
Thanks, yes, my solution was close to this, but I opted instead to subclass the Include class. I think the solution that you propose below may cause wicket to create an absolute URL to the HTML files under the WEB-INF dir which will be inaccessible by the browser. Here is my subclass of the Include class, which is working well for me: public class ResourceInclude extends Include { private static final long serialVersionUID = 1L; private final static Logger log = LoggerFactory.getLogger( ResourceInclude.class ); /** * Constructs a new ResourceInclude object. * @param id The identifier of the wicket markup that this ResourceInclude is bound to. * @param resourcePath The resource location of the content to load. This should be * a resource path that is reachable from the ServletContext via a call to * ServletContext.getResource(String). */ public ResourceInclude( String id, String resourcePath ) { super( id, resourcePath ); } /** * Override of the importAsString method to load the content from the resource path that was * provided during consturction. * @see org.apache.wicket.markup.html.include.Include#importAsString() */ @Override protected String importAsString() { String url = this.getModelObjectAsString(); if ( !isAbsolute( url ) ) { try { UrlResourceStream resourceStream = new UrlResourceStream( ((WebApplication)this.getApplication()).getServletContext().getResource( url ) ); return resourceStream.asString(); } catch ( Exception ex ) { log.error( Error loading help file at resource location: + this.getModelObjectAsString(), ex ); return super.importAsString(); } } else { return super.importAsString(); } } } Kent Tong wrote: Jason Mihalick wrote: Thank you for the suggestion. This looks like it ought to work fine for exploded WARs, but it seems like it would be a problem when then app is deployed in a WAR. Is there any way to do this that will work when the app is deployed in a WAR archive? Or is there perhaps another wicket component that I should be using that won't require me to create a companion Java class for each help snippet? Try: URL url = ((WebApplication) getApplication()).getServletContext().getResource(/WEB-INF/help/topic1.html); add(new Include(i, url.toString())); -- View this message in context: http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12576080 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Using Include and placing pages under WEB-INF
Hello, I have followed the instructions on the wiki for placing HTML pages in an alternative location (http://cwiki.apache.org/WICKET/control-where-html-files-are-loaded-from.html). The location I chose was at the context root. I.e., webapp/ +--- WEB-INF/ +--- css/ +--- img/ +--- js/ +--- help/ +--- Page1.html +--- Page2.html ... etc. When I locate the pages there and add the appropriate resource folder (using IResourceSettings.addResourceFolder(String) ), everything works fine in my wicket application. However, if I try to move my pages under WEB-INF, wicket has a problem loading resources that are bound via the org.apache.wicket.markup.html.include.Include class. In my case, I have several static pages that I want to load dynamically which are located in my 'help/' directory (see above). When the user loads Page1.html, I want to load HTML from a corresponding help page and place that HTML into a panel. When they load Page2.html, I want to load HTML from another help page, etc. This is all working great with the wicket Include mechanism ... until I move the pages under the WEB-INF dir. When I do that, I get messages like this... [ERROR] 09/07/07 12.49.11.011 org.apache.wicket.RequestCycle:1255 - Unable to read resource as String org.apache.wicket.WicketRuntimeException: Unable to read resource as String at org.apache.wicket.util.resource.AbstractResourceStream.asString(AbstractResourceStream.java:77) at org.apache.wicket.markup.html.include.Include.importUrl(Include.java:266) at org.apache.wicket.markup.html.include.Include.importAbsoluteUrl(Include.java:248) at org.apache.wicket.markup.html.include.Include.importRelativeUrl(Include.java:234) at org.apache.wicket.markup.html.include.Include.importAsString(Include.java:158) at org.apache.wicket.markup.html.include.Include.onComponentTagBody(Include.java:172) Is it possible to do what I'm attempting to do? Thanks in advance! (Thanks also to the wicket developers for creating such a great framework!) -- Jason -- View this message in context: http://www.nabble.com/Using-Include-and-placing-pages-under-WEB-INF-tf4403861.html#a12563577 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]