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:

<select class="dualdropdown" id="smltype" wicket:id="smltype" 
onchange="javascript:smltype_changed()">

                        <a title="Vis hj&aelig;lp" 
href="javascript:showHelp(766)" wicket:id="top-help">Hj&aelig;lp</a>


                                <input id="wordbutton" disabled="disabled" 
type="submit" value="Generer rapport" wicket:id="wordbutton" 
onclick="showContent('uglyfix');showContent('uniquename');" />





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

Reply via email to