Re: [Wicket-user] javascript handlers in html - quotes escaping
Hmm, it is actually working, and I do agree that you write wouldn't work... This is the output on the html generated by wicket: As you see the \" apparently are escaped to ' when processed by wicket.. Im running on wicket 1.2. About the pattern script, yeah it does not feel like the best solution, but currently I cant see any other. Regards Nino -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Klochkov Sent: 8. december 2006 13:35 To: wicket-user@lists.sourceforge.net Subject: Re: [Wicket-user] javascript handlers in html - quotes escaping Nino Wael wrote: >type="submit" value="Generer rapport" wicket:id="wordbutton" > onclick="showContent('uglyfix');showContent('uniquename');" /> > How can you run this example with wicket?? It escapes qoutes in a strange wa so you should have the following code in the result html: And this script wouldn't work in IE and Firefox at least! BTW I found a workaround for IDs problem using TextTemplateHeaderContributor: I place all IDs in variables and have javascript template file which uses these variables, so wicket replaces variables with actual IDs in runtime. > Small code snip on howto workaround the path generated by wicket: > Thanks for this one. It's not very clean solution but anyway it's better than placing all handlers in java components. -- Andrew Klochkov - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] javascript handlers in html - quotes escaping
Nino Wael wrote: >type="submit" value="Generer rapport" wicket:id="wordbutton" > onclick="showContent('uglyfix');showContent('uniquename');" /> > How can you run this example with wicket?? It escapes qoutes in a strange wa so you should have the following code in the result html: And this script wouldn't work in IE and Firefox at least! BTW I found a workaround for IDs problem using TextTemplateHeaderContributor: I place all IDs in variables and have javascript template file which uses these variables, so wicket replaces variables with actual IDs in runtime. > Small code snip on howto workaround the path generated by wicket: > Thanks for this one. It's not very clean solution but anyway it's better than placing all handlers in java components. -- Andrew Klochkov - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user
Re: [Wicket-user] javascript handlers in html - quotes escaping
No true:) Why cant you use ID's? IT is true that forexample dropdown options are created on a specific pattern but it's somewhat easy to create some javascript which adapts that pattern. We use a lot of onchange some which are added in the html at some which are added with the attribute appender (I have a nice litte progressbar component, which need some html appended and a small javascript appended on the onclick). Code snips: Hjælp Small code snip on howto workaround the path generated by wicket: function isAnySelected(formId, name) { var form = resolve(formId); var notfound = true; for (var i = 0; i < form.length; i++) { var ename = form.elements[i].name; var prefix = ename.substring(0, ename.indexOf(":")); if (prefix == name) { if (form.elements[i].selectedIndex != 0) { return true; } notfound = false; } } return notfound; } These are all wicket components, which works nicely...I have more If wanted.. Regards Nino -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Klochkov Sent: 8. december 2006 11:41 To: wicket-user@lists.sourceforge.net Subject: [Wicket-user] javascript handlers in html - quotes escaping After 2 months working with Wicket I'm still quite impressed by this smart framework, but IMHO the most weak part of it is client-side scripting. So when you want to place a lot of javascript in html, using handlers like onclick, onkeyup etc, without using server at all (no ajax, no server callbacks) - it is too difficult (almost impossible). There are 2 big problems: 1. You can't use id attributes in scripts because wicket generates them. There is no way to get ID in javascript runtime. 2. Wicket escapes qoutes in javascript handlers in incorrect way. For example, it transforms the following handler: onclick="test('test me')" to the form: onclick="test(\"test me\")" And browser (firefox, IE) doesn't understand it, giving "incorrect character" error. So now I have to have a lot of java code like the following. And it would be MUCH better to define it in html. colorBox.add(new AttributeAppender("onclick", new AbstractReadOnlyModel() { @Override public Object getObject(Component component) { return "document.getElementById('" + textField.getMarkupId() + "').value='" + color + "'; " + "document.getElementById('" + ColorPicker.this.getMarkupId() + "').style.display='none'; " + "document.getElementById('" + colorPreview.getMarkupId() + "').style.background='#" + color + "';"; } }, ";")); Is there any way to workaround this problems? Maybe something will be changed in wicket v2.0? -- Andrew Klochkov - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user