Re: Relative Path and Resource loading in wicket
On Fri, Nov 16, 2012 at 7:55 AM, delta458 delta...@hotmail.com wrote: Hello, Im sitting now 6 hours non-stop on this problem and cant get it work. I want a simple thing. I have a Invoice.js file in my resource folder. I want to get this file and write something to it: so I did: /URL url = getClass().getResource(Invoice.js); Your problems is here ^^. getClass().getResource() looks in the classpath. File file = new File(url.getPath()); System.out.println(url.getPath()); BufferedWriter out = new BufferedWriter(new FileWriter(file), 32768); out.write(TEST); out.close();/ But thats not working. He writes into the file successfully, but saves the file into the maven target folder :( I need to read from that file later, so I need to use it again. How can I make wicket to write to the relative path and not save it in the target folder... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Relative-Path-and-Resource-loading-in-wicket-tp4653930.html Sent from the Users forum 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 P.S. There is nothing Wicket related in this question. -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com http://jweekend.com/
Re: Relative Path and Resource loading in wicket
@Ernest I just need to write some variables to the .js file like var price; var user; @MartinGrigorov so what should I do to make this work? How can I set my resource to the classpath? and what should I call to make it work? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Relative-Path-and-Resource-loading-in-wicket-tp4653930p4653945.html Sent from the Users forum 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: Relative Path and Resource loading in wicket
I had a similar problem and considered Martin's approach, but ended up creating a div wicket:id=myVar class=myVarvar value/div on my page and accessed it from JS file using $(div.myVar).text() or something like that. The advantage of div approach is that you can test it statically without deploying the webapp and your JS file can be safely cached by the browser improving load time. Alec On Fri, Nov 16, 2012 at 7:58 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: You can do something like On your panel public void renderHead(final IHeaderResponse response) { PackagedTextTemplate template = new PackagedTextTemplate(MyPanel.class, test.js); MapString, Object vars = new MiniMapString, Object(1); vars.put(val1, MyValue); response.renderOnDomReadyJavascript(template.asString(vars)); } test.js= var bla = '${val1}'; On Fri, Nov 16, 2012 at 3:51 PM, delta458 delta...@hotmail.com wrote: @Ernest I just need to write some variables to the .js file like var price; var user; @MartinGrigorov so what should I do to make this work? How can I set my resource to the classpath? and what should I call to make it work? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Relative-Path-and-Resource-loading-in-wicket-tp4653930p4653945.html Sent from the Users forum 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 -- Regards - Ernesto Reinaldo Barreiro Antilia Soft http://antiliasoft.com/ http://antiliasoft.com/antilia - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Relative Path and Resource loading in wicket
Hello, Im sitting now 6 hours non-stop on this problem and cant get it work. I want a simple thing. I have a Invoice.js file in my resource folder. I want to get this file and write something to it: so I did: /URL url = getClass().getResource(Invoice.js); File file = new File(url.getPath()); System.out.println(url.getPath()); BufferedWriter out = new BufferedWriter(new FileWriter(file), 32768); out.write(TEST); out.close();/ But thats not working. He writes into the file successfully, but saves the file into the maven target folder :( I need to read from that file later, so I need to use it again. How can I make wicket to write to the relative path and not save it in the target folder... -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Relative-Path-and-Resource-loading-in-wicket-tp4653930.html Sent from the Users forum 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