You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Johan Compagner <jc...@gmail.com> on 2007/05/30 13:46:05 UTC

case insensitive check for attributes?

i have this html:


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org/
">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Insert title here</title>
  </head>
  <body>
    <span wicket:id="click" onClick="test();">click</span>
  </body>
</html>

then this page:

public class CaseSensitiveAttributePage extends WebPage
{
    public CaseSensitiveAttributePage()
    {
        add(new Label("click").add(new AttributeModifier("onclick",true,new
Model("test2();"))));
    }
}

what should the output then be?

or if i do: add(new Label("click").add(new
AttributeModifier("onclick",false,new Model("test();")))); // see the false

currently if we have a true (do append it) then we get:

 <span wicket:id="click" onclick="test2();" onClick="test();"></span>

which is wrong of course
with the false:

  <span wicket:id="click" onClick="test();"></span>

we don't add the attribute at all. (and it is mentioned in the html)

should we try to match case insenstive? Not it is just a ValueMap of
attributes so the problem is that
we then have to lowercase all the attributes keys

johan

Re: case insensitive check for attributes?

Posted by Maurice Marrink <ma...@gmail.com>.
Now that's a good idea Johan :)

Maurice

On 5/30/07, Johan Compagner <jc...@gmail.com> wrote:
> that would also be my fix.
> Just lower case everything once when loading and we are done.
> Then also lower case the AttributeModifiers and these problems are gone.
>
> does somebody disagree?
>
> johan
>
>
> On 5/30/07, Al Maw <wi...@almaw.com> wrote:
> >
> > Johan Compagner wrote:
> > > should we try to match case insenstive? Not it is just a ValueMap of
> > > attributes so the problem is that we then have to lowercase all the
> > > attributes keys
> >
> > Hmmmm. XHTML says all the attributes should be lowercased, so I see no
> > particular problem with lowercasing everything in the markup loader,
> > aside from the extra overhead. Someone will doubtless complain, though.
> >
> > Regards,
> >
> > Al
> >
> > --
> > Alastair Maw
> > Wicket-biased blog at http://herebebeasties.com
> >
>

Re: case insensitive check for attributes?

Posted by Johan Compagner <jc...@gmail.com>.
On 5/31/07, Al Maw <wi...@almaw.com> wrote:
>
> As far as I can see, the only reasons not to lower-case stuff
> automatically are that it's too magic and/or too expensive to check all
> the attribute modifiers.


it isn't about the attribute modifiers..
if you create one like this: new AttributeModifier("onClick",xxxx)
then we do internally always just toLowerCase() on it  (based on setting?)
that doesn't matter to much

The problem is the tag.getAttributes() map. so those comming from the markup
if we lower case the attribute modifier always and then we also lowercase
all the keys
that are in the attribute map of a tag that comes from the markup then the
problem is gone
And that lowercasing of all the tags attributes map is only done once
(loading the markup)
so that is not a problem.

ofcourse we could make this a setting:

boolan Settings.getLowerCaseAttributes() default = true

then we lower case all the attribute modifiers that are made and all the
markup attributes that we get from the markup.



> As a slight aside, but related to the magic, I've long been confused by
> AttributeModifier silently throwing things away if you omit the boolean
> constructor param. It seems to confuse fresh Wicket developers. Does
> anyone have a use-case for this? Why is it like that?


yeah that was something for way back.
thats why igor did make the SimpleAttributeModifier i think.
It is that markup can't be changed by the developer if the markup doesn't
specify it.
But i think this is just bogus. Developers want to do that a designer
doesn't have to
think about what a developer maybe want to do

So we can make that boolean by default true?

johan

Re: case insensitive check for attributes?

Posted by Al Maw <wi...@almaw.com>.
As far as I can see, the only reasons not to lower-case stuff 
automatically are that it's too magic and/or too expensive to check all 
the attribute modifiers.

I can also foresee someone wanting to use upper-case and then running an 
XSLT transform over it or something, and complaining that we've broken 
their use-case.

I'd be in favour of a runtime check in both DEVELOPMENT and DEPLOYMENT 
that AttributeModifiers are lowercase, perhaps with a 
setAllowUppercase(true) to cover the uncommon case if anyone needs it?

You can go if (foo.toLowerCase() == foo) which is reasonably cheap (most 
attributes are less than ~10 chars, so it's just 10 or so comparison 
operations, no new String will be made if it's already correct.

As a slight aside, but related to the magic, I've long been confused by 
AttributeModifier silently throwing things away if you omit the boolean 
constructor param. It seems to confuse fresh Wicket developers. Does 
anyone have a use-case for this? Why is it like that?

Al

-- 
Alastair Maw
Wicket-biased blog at http://herebebeasties.com

Re: case insensitive check for attributes?

Posted by Maurice Marrink <ma...@gmail.com>.
The main problem is not the time it took to fix, but the fact that i
accidentally stumbled on a page not working anymore because a coworker
had changed the java code from new SimpleAttributeModifier("onClick",
...) to "onclick" innocently expecting his change would not have any
effect. You don't want accidents like this to go to a production
environment without at least wicket screaming bloody murder, but then
you still have to notice the warning, an fix it. It would be much
simpler if wicket fixed it automagically for you.

Maurice

On 5/31/07, Timo Rantalaiho <Ti...@ri.fi> wrote:
> On Wed, 30 May 2007, Johan Compagner wrote:
> > here we have a case that the design says one thing and the java code another
> > so its a mismatch
> > what should happen then?
> > Today maurice had such a case and that did cost him quite some time to track
> > down.
> > Maybe in development mode we test for it somehow and then throw an
> > exception?
>
> Or just throw an exception always -- is there any case in
> which you would want to have a differing case in markup than
> in code?
>
> - Timo
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>

Re: case insensitive check for attributes?

Posted by Johan Compagner <jc...@gmail.com>.
and when will html5 be a standard supported by all major browsers?
will i still be programming then :)

johan


On 5/31/07, Martijn Dashorst <ma...@gmail.com> wrote:
>
> On 5/31/07, Johan Compagner <jc...@gmail.com> wrote:
> > and it will make the output more xhtml
>
> Heh, the world is moving away from xhtml: html5 will be the next big
> thing. Even the w3c seems to think so. That said, lower casing
> attributes should not be a problem for html5 as well, iiuc.
>
> Martijn
>
> --
> Join the wicket community at irc.freenode.net: ##wicket
> Wicket 1.2.6 contains a very important fix. Download Wicket now!
> http://wicketframework.org
>

Re: case insensitive check for attributes?

Posted by Martijn Dashorst <ma...@gmail.com>.
On 5/31/07, Johan Compagner <jc...@gmail.com> wrote:
> and it will make the output more xhtml

Heh, the world is moving away from xhtml: html5 will be the next big
thing. Even the w3c seems to think so. That said, lower casing
attributes should not be a problem for html5 as well, iiuc.

Martijn

-- 
Join the wicket community at irc.freenode.net: ##wicket
Wicket 1.2.6 contains a very important fix. Download Wicket now!
http://wicketframework.org

Re: case insensitive check for attributes?

Posted by Johan Compagner <jc...@gmail.com>.
see the thread :)
that was my first idea (and also almaw) but the discussion was that we
wanted
to do this long before (wicket 0?) and then we concluded that we shouldn't
alter the markup??

But making it all lowercase is still my prefference. It won't hurt as far as
i know nobody
and it will make the output more xhtml

johan


On 5/31/07, Martijn Dashorst <ma...@gmail.com> wrote:
>
> On 5/31/07, Johan Compagner <jc...@gmail.com> wrote:
> > the problem that testing all these is not just very simple
> > Now it is just a hash lookup but then we need to iterate
> > over all the keys everytime and check for equals ignoring case.
>
> Can't we put them in there always using lower case?
>
> Martijn
>

Re: case insensitive check for attributes?

Posted by Martijn Dashorst <ma...@gmail.com>.
On 5/31/07, Johan Compagner <jc...@gmail.com> wrote:
> the problem that testing all these is not just very simple
> Now it is just a hash lookup but then we need to iterate
> over all the keys everytime and check for equals ignoring case.

Can't we put them in there always using lower case?

Martijn

Re: case insensitive check for attributes?

Posted by Johan Compagner <jc...@gmail.com>.
the problem that testing all these is not just very simple
Now it is just a hash lookup but then we need to iterate
over all the keys everytime and check for equals ignoring case.

So doing that in deployment mode is a bit to much (at least what i think)

johan


On 5/31/07, Timo Rantalaiho <Ti...@ri.fi> wrote:
>
> On Wed, 30 May 2007, Johan Compagner wrote:
> > here we have a case that the design says one thing and the java code
> another
> > so its a mismatch
> > what should happen then?
> > Today maurice had such a case and that did cost him quite some time to
> track
> > down.
> > Maybe in development mode we test for it somehow and then throw an
> > exception?
>
> Or just throw an exception always -- is there any case in
> which you would want to have a differing case in markup than
> in code?
>
> - Timo
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>

Re: case insensitive check for attributes?

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Wed, 30 May 2007, Johan Compagner wrote:
> here we have a case that the design says one thing and the java code another
> so its a mismatch
> what should happen then?
> Today maurice had such a case and that did cost him quite some time to track
> down.
> Maybe in development mode we test for it somehow and then throw an
> exception?

Or just throw an exception always -- is there any case in 
which you would want to have a differing case in markup than 
in code?

- Timo

-- 
Timo Rantalaiho
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

Re: case insensitive check for attributes?

Posted by Johan Compagner <jc...@gmail.com>.
hmm but that is not the right argument here  i think (we shouldn't change
because we shouldn't)
here we have a case that the design says one thing and the java code another
so its a mismatch
what should happen then?
Today maurice had such a case and that did cost him quite some time to track
down.
Maybe in development mode we test for it somehow and then throw an
exception?

johan



On 5/30/07, Gwyn Evans <gw...@gmail.com> wrote:
>
> On Wednesday, May 30, 2007, 3:55:51 PM, Eelco <ee...@gmail.com>
> wrote:
>
> It's not on Nabble (too early) but it was "Attributes need to perserve
> case" from 06-Sep-2005 on wicket-develop@lists.sourceforge.net.
> Let me know if you want a copy, but the summary was that Juergen
> suggested it wasn't really Wicket's place to modify them as it could
> be confusing, and no one disagreed.
>
> The 'issue' was 1286616 on SF -
>
> https://sourceforge.net/tracker/?func=detail&atid=684975&aid=1286616&group_id=119783
>
> /Gwyn
>
> > I vaguely remember having a to-lowercase conversion build in around
> > Wicket 1.0. If it was removed again, we probably had a reason for it.
> > Did you search the mail archives?
>
> > Eelco
>
> > On 5/30/07, Johan Compagner <jc...@gmail.com> wrote:
> >> that would also be my fix.
> >> Just lower case everything once when loading and we are done.
> >> Then also lower case the AttributeModifiers and these problems are
> gone.
> >>
> >> does somebody disagree?
> >>
> >> johan
> >>
> >>
> >> On 5/30/07, Al Maw <wi...@almaw.com> wrote:
> >> >
> >> > Johan Compagner wrote:
> >> > > should we try to match case insenstive? Not it is just a ValueMap
> of
> >> > > attributes so the problem is that we then have to lowercase all the
> >> > > attributes keys
> >> >
> >> > Hmmmm. XHTML says all the attributes should be lowercased, so I see
> no
> >> > particular problem with lowercasing everything in the markup loader,
> >> > aside from the extra overhead. Someone will doubtless complain,
> though.
> >> >
> >> > Regards,
> >> >
> >> > Al
> >> >
> >> > --
> >> > Alastair Maw
> >> > Wicket-biased blog at http://herebebeasties.com
> >> >
> >>
>
>
>
> /Gwyn
>
>

Re: case insensitive check for attributes?

Posted by Gwyn Evans <gw...@gmail.com>.
On Wednesday, May 30, 2007, 3:55:51 PM, Eelco <ee...@gmail.com> wrote:

It's not on Nabble (too early) but it was "Attributes need to perserve
case" from 06-Sep-2005 on wicket-develop@lists.sourceforge.net.
Let me know if you want a copy, but the summary was that Juergen
suggested it wasn't really Wicket's place to modify them as it could
be confusing, and no one disagreed.

The 'issue' was 1286616 on SF -
https://sourceforge.net/tracker/?func=detail&atid=684975&aid=1286616&group_id=119783

/Gwyn

> I vaguely remember having a to-lowercase conversion build in around
> Wicket 1.0. If it was removed again, we probably had a reason for it.
> Did you search the mail archives?

> Eelco

> On 5/30/07, Johan Compagner <jc...@gmail.com> wrote:
>> that would also be my fix.
>> Just lower case everything once when loading and we are done.
>> Then also lower case the AttributeModifiers and these problems are gone.
>>
>> does somebody disagree?
>>
>> johan
>>
>>
>> On 5/30/07, Al Maw <wi...@almaw.com> wrote:
>> >
>> > Johan Compagner wrote:
>> > > should we try to match case insenstive? Not it is just a ValueMap of
>> > > attributes so the problem is that we then have to lowercase all the
>> > > attributes keys
>> >
>> > Hmmmm. XHTML says all the attributes should be lowercased, so I see no
>> > particular problem with lowercasing everything in the markup loader,
>> > aside from the extra overhead. Someone will doubtless complain, though.
>> >
>> > Regards,
>> >
>> > Al
>> >
>> > --
>> > Alastair Maw
>> > Wicket-biased blog at http://herebebeasties.com
>> >
>>



/Gwyn


Re: case insensitive check for attributes?

Posted by Eelco Hillenius <ee...@gmail.com>.
I vaguely remember having a to-lowercase conversion build in around
Wicket 1.0. If it was removed again, we probably had a reason for it.
Did you search the mail archives?

Eelco

On 5/30/07, Johan Compagner <jc...@gmail.com> wrote:
> that would also be my fix.
> Just lower case everything once when loading and we are done.
> Then also lower case the AttributeModifiers and these problems are gone.
>
> does somebody disagree?
>
> johan
>
>
> On 5/30/07, Al Maw <wi...@almaw.com> wrote:
> >
> > Johan Compagner wrote:
> > > should we try to match case insenstive? Not it is just a ValueMap of
> > > attributes so the problem is that we then have to lowercase all the
> > > attributes keys
> >
> > Hmmmm. XHTML says all the attributes should be lowercased, so I see no
> > particular problem with lowercasing everything in the markup loader,
> > aside from the extra overhead. Someone will doubtless complain, though.
> >
> > Regards,
> >
> > Al
> >
> > --
> > Alastair Maw
> > Wicket-biased blog at http://herebebeasties.com
> >
>

Re: case insensitive check for attributes?

Posted by Johan Compagner <jc...@gmail.com>.
that would also be my fix.
Just lower case everything once when loading and we are done.
Then also lower case the AttributeModifiers and these problems are gone.

does somebody disagree?

johan


On 5/30/07, Al Maw <wi...@almaw.com> wrote:
>
> Johan Compagner wrote:
> > should we try to match case insenstive? Not it is just a ValueMap of
> > attributes so the problem is that we then have to lowercase all the
> > attributes keys
>
> Hmmmm. XHTML says all the attributes should be lowercased, so I see no
> particular problem with lowercasing everything in the markup loader,
> aside from the extra overhead. Someone will doubtless complain, though.
>
> Regards,
>
> Al
>
> --
> Alastair Maw
> Wicket-biased blog at http://herebebeasties.com
>

Re: case insensitive check for attributes?

Posted by Al Maw <wi...@almaw.com>.
Johan Compagner wrote:
> should we try to match case insenstive? Not it is just a ValueMap of 
> attributes so the problem is that we then have to lowercase all the
> attributes keys

Hmmmm. XHTML says all the attributes should be lowercased, so I see no 
particular problem with lowercasing everything in the markup loader, 
aside from the extra overhead. Someone will doubtless complain, though.

Regards,

Al

-- 
Alastair Maw
Wicket-biased blog at http://herebebeasties.com