You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Christopher Highway <ch...@gmail.com> on 2008/10/18 23:06:14 UTC

[clickclick] new BooleanSelect field

Hi all,

Added the BooleanSelect (core) and experimental StyledBooleanSelect
(examples) to the clickclick repository.

I had a bit of a struggle with Click, but I came out on top in the end
(I think...) :-)

There is a testpage: clickclick-core-examples/controls/booleanSelect.htm
I didn't put it in the menu or anything so you'll have to browse to it manually.

[BooleanSelect]
- there are get/setBoolean() methods in keeping with
Integer/Long/Date/etc Fields.
- added some default notations backed by the resource bundle (see sample page).
- the required option defaults to tristate, not required defaults to
twostate (read the class javadoc for more info).

As OptionNames are final, and if the tristate property is changed 2 or
3 Options may be needed. For this the creation of the Options is
deferred to onInit(), this means:
a) the Options are not available for tweaking in page.onInit() (but
Options don't have anything to tweak so that's only a minor issue)
b) changes made after page.onInit() won't be reflected in the final result.

[StyledBooleanSelect]
The StyledBooleanSelect is a bit of a mixed success, it has some issues:

java-side:
Option does not have style attribute or class properties so I made a
new StyledOption class to add them.
the values are also buffered in the Select class as the options are
only instantiated at control.onInit() so the same goes as for a) and
b).

html-side:
Limited support for styling option elements (background-color and font
are ok, but Images are only supported by Firefox)
- if you use images you need to enable javascript to make it work correcty.
- use of images regresses ok in IE but less in Opera.
- colors work correctly in Opera and IE, but only show in the
dropdownlist in Firefox (Opera and IE apply the style of the selected
option to the Select control, but Firefox doesn't, this is also why
the image has to be manually changed through javascript).


Anyways, please have a look.

Cheers
Christopher

PS: I put the two icons in assets/images folder.
I made them myself, so there shouldn't be any copyright issues (used:
Artweaver + Windows Webdings font)

Re: [clickclick] new BooleanSelect field

Posted by Christopher Highway <ch...@gmail.com>.
Hi, I'll answer your previous message in a minute... :-)

2008/10/19 Bob Schellink <sa...@gmail.com>:
> I've noticed you left a comment about Select accessing value directly
> instead of using setValue. Are you referring to Select#bindRequestValue?
>
> I think this should be changed to invoke setValue.
>

Yes, as a form.post can be faked, I thought it best to check the value
again on getting and not only on setting.

If the overridden setValue() method is used, the check on getValue()
would not be needed as no illegal value could be entered.

The only advantage of the way it is done now is that no exception is
thrown on illegal value through bindRequestValue, only logged as these
are not normally to be expected, and only will happen runtime.
Exceptions are only thrown on the setters which will mostly happen
during developtime because the developer passed an illegal value.
(well I think so)

Cheers
Christopher.

PS: the underlying (super) method does use setValue();

PPS: IntegerField does not override setValue / getValue, it only makes
certain get/setInteger are valid (and returns null on illegal value).
 -- Maybe I'm being too paranoid...
maybe I should also leave the set/get value alone. If you want
certainty about the content you can use get/setBoolean -
get/setInteger.

Re: [clickclick] new BooleanSelect field

Posted by Bob Schellink <sa...@gmail.com>.
I've noticed you left a comment about Select accessing value directly 
instead of using setValue. Are you referring to Select#bindRequestValue?

I think this should be changed to invoke setValue.

Re: [clickclick] new BooleanSelect field

Posted by Christopher Highway <ch...@gmail.com>.
Hello all

I have updated the BooleanSelect field and added the StyledOption (&
removed StyledBooleanSelect)

samplepages:
clickclick-core-examples/controls/styledOption.htm
clickclick-core-examples/controls/booleanSelect.htm

cheers
Christopher

Changes:

[StyledOption]
- extracted StyledOption to normal class
   - added id attribute (formName_selectName_optionName)
   - removed all other styles and attributes
      - you can format individual options with their id:
"option.optionId {...}" or,
      - you can use the last part of the id to uniformely format
individual options of multiple Selects:
        "option[id$=optionId] {...}". (see examplepage for what's possible)
      - or you can set the id property to a custom id for easier css formatting.

[BooleanSelect]
- removed the customised set/getValue() set/getObjectValue() methods
to better reflect the way IntegerField and LongField work.
  If you want typesafety use get/setBoolean().
- semantics of getBoolean are slightly changed in that null and "" are
null, "true" == True (ignoreCase) and everything else is False
(before, 'everything else' was null)
  these semantics better follow how Boolean.valueOf converts String
values (except that valueOf never returns null, but we need this for
our Tristate)
- always uses StyledOption with names 'unset', 'true' & 'false', this
means the ids are 'formName_selectName_[unset/true/false]'
  you can use (in css) option[id$=...] to enlarge the number of
options to which your style will be applied.
  We could also just give them ids of just the name, then you would
need nesting to apply styles to a specific instance.
  ex. setting all true values to green: 'option[id$=true] {color:
green;}' vs. 'option.true {color: green;}'
      the first is easier to set individual instances, the second is
easier to set all instances.

[Other]
- removed StyledBooleanSelect
- I have not made a StyledOptionGroup class. You can already style
them at Selectlevel using elementname and nesting, it could be added
if the need were to arise though.
- split examplepages into one for BooleanSelect and one for
StyledOption, I may have gone a bit overboard with this last one...
:-)
- The Javascript is not as robust as before. By using Ids in Options
makes changing the styles with javascript a lot harder, as you have to
copy styles from the rules and not just from the element itself. This
makes getting the script right a lot harder (especially if there are
some inherited styles).
  therefore I'm seeing the Javascript as an unsupported feature, which
you can copy from the samplepage if you like, but nothing more. It's
only for Firefox anyway.

Re: [clickclick] new BooleanSelect field

Posted by Bob Schellink <sa...@gmail.com>.
Christopher Highway wrote:
> I'm not going to put it in if it's not really needed, If a good reason
> arises it can still be done.
>   

Agree.

> We could also consider to make the StyledOption a topclass and not an
> innerclass then you could use it for a a regular Select as well, and
> you could create Selects like on the Jira searchpage
> (http://www.avoka.com/jira/secure/IssueNavigator.jspa).
> Setting an Id might be preferable to a class attribute then though, as
> there might be more options.
>   

Yes StyledOption as a topclass could be useful. By default the ID could 
be rendered as
formName_selectName_optionName. Otherwise it can set explicitly.

kind regards

bob

Re: [clickclick] new BooleanSelect field

Posted by Christopher Highway <ch...@gmail.com>.
Hi Bob,
Thanks for the answers

2008/10/19 Bob Schellink <sa...@gmail.com>:
> I also don't think tweaking the control after onInit will be common. However
> if you want to support this a custom Option with mutable Label could do the
> trick.

I'm not going to put it in if it's not really needed, If a good reason
arises it can still be done.

> One thing you might want to consider for the StyledBooleanSelect is to
>  "hardcode" the option CSS classes with no option of changing it. This way
> you can document the available CSS classes and force users to use external
> CSS to style it if they want. (its a shame browser support are so flaky with
> Option styling)

I think this is a good middle way.
One can still tweak individual control styles if needed by using the
id of the select and an inner option.
(#form_select-ttt trueOption {color...})

We could also consider to make the StyledOption a topclass and not an
innerclass then you could use it for a a regular Select as well, and
you could create Selects like on the Jira searchpage
(http://www.avoka.com/jira/secure/IssueNavigator.jspa).
Setting an Id might be preferable to a class attribute then though, as
there might be more options.
Hmm... might be a bit overkill though, or maybe when more browsers
support the backgroundimage style?

>
> If you do consider this you might want to merge BooleanSelect and
> StyledBooleanSelect into one control where BooleanSelect has a StyledOption
> which appends the CSS classes.
>
> Lastly you could probably remove the isMultiple logic in StyledOption#render
> as BooleanSelect does not allow multiple selection.

I'll look into it.

> kind regards
>
> bob
>

Cheers
Christopher

Re: [clickclick] new BooleanSelect field

Posted by Bob Schellink <sa...@gmail.com>.
Hi Christopher,

BooleanSelect looks good.

I also don't think tweaking the control after onInit will be common. 
However if you want to support this a custom Option with mutable Label 
could do the trick.

One thing you might want to consider for the StyledBooleanSelect is to 
   "hardcode" the option CSS classes with no option of changing it. 
This way you can document the available CSS classes and force users to 
use external CSS to style it if they want. (its a shame browser 
support are so flaky with Option styling)

If you do consider this you might want to merge BooleanSelect and 
StyledBooleanSelect into one control where BooleanSelect has a 
StyledOption which appends the CSS classes.

Lastly you could probably remove the isMultiple logic in 
StyledOption#render as BooleanSelect does not allow multiple selection.


kind regards

bob


Christopher Highway wrote:
> Hi all,
> 
> Added the BooleanSelect (core) and experimental StyledBooleanSelect
> (examples) to the clickclick repository.
> 
> I had a bit of a struggle with Click, but I came out on top in the end
> (I think...) :-)
> 
> There is a testpage: clickclick-core-examples/controls/booleanSelect.htm
> I didn't put it in the menu or anything so you'll have to browse to it manually.
> 
> [BooleanSelect]
> - there are get/setBoolean() methods in keeping with
> Integer/Long/Date/etc Fields.
> - added some default notations backed by the resource bundle (see sample page).
> - the required option defaults to tristate, not required defaults to
> twostate (read the class javadoc for more info).
> 
> As OptionNames are final, and if the tristate property is changed 2 or
> 3 Options may be needed. For this the creation of the Options is
> deferred to onInit(), this means:
> a) the Options are not available for tweaking in page.onInit() (but
> Options don't have anything to tweak so that's only a minor issue)
> b) changes made after page.onInit() won't be reflected in the final result.
> 
> [StyledBooleanSelect]
> The StyledBooleanSelect is a bit of a mixed success, it has some issues:
> 
> java-side:
> Option does not have style attribute or class properties so I made a
> new StyledOption class to add them.
> the values are also buffered in the Select class as the options are
> only instantiated at control.onInit() so the same goes as for a) and
> b).
> 
> html-side:
> Limited support for styling option elements (background-color and font
> are ok, but Images are only supported by Firefox)
> - if you use images you need to enable javascript to make it work correcty.
> - use of images regresses ok in IE but less in Opera.
> - colors work correctly in Opera and IE, but only show in the
> dropdownlist in Firefox (Opera and IE apply the style of the selected
> option to the Select control, but Firefox doesn't, this is also why
> the image has to be manually changed through javascript).
> 
> 
> Anyways, please have a look.
> 
> Cheers
> Christopher
> 
> PS: I put the two icons in assets/images folder.
> I made them myself, so there shouldn't be any copyright issues (used:
> Artweaver + Windows Webdings font)
> 


Re: [clickclick] new BooleanSelect field

Posted by Bob Schellink <sa...@gmail.com>.
Thanks Christopher, I'll definitely check it out.

bob


Christopher Highway wrote:
> Hi all,
> 
> Added the BooleanSelect (core) and experimental StyledBooleanSelect
> (examples) to the clickclick repository.
> 
> I had a bit of a struggle with Click, but I came out on top in the end
> (I think...) :-)
> 
> There is a testpage: clickclick-core-examples/controls/booleanSelect.htm
> I didn't put it in the menu or anything so you'll have to browse to it manually.
> 
> [BooleanSelect]
> - there are get/setBoolean() methods in keeping with
> Integer/Long/Date/etc Fields.
> - added some default notations backed by the resource bundle (see sample page).
> - the required option defaults to tristate, not required defaults to
> twostate (read the class javadoc for more info).
> 
> As OptionNames are final, and if the tristate property is changed 2 or
> 3 Options may be needed. For this the creation of the Options is
> deferred to onInit(), this means:
> a) the Options are not available for tweaking in page.onInit() (but
> Options don't have anything to tweak so that's only a minor issue)
> b) changes made after page.onInit() won't be reflected in the final result.
> 
> [StyledBooleanSelect]
> The StyledBooleanSelect is a bit of a mixed success, it has some issues:
> 
> java-side:
> Option does not have style attribute or class properties so I made a
> new StyledOption class to add them.
> the values are also buffered in the Select class as the options are
> only instantiated at control.onInit() so the same goes as for a) and
> b).
> 
> html-side:
> Limited support for styling option elements (background-color and font
> are ok, but Images are only supported by Firefox)
> - if you use images you need to enable javascript to make it work correcty.
> - use of images regresses ok in IE but less in Opera.
> - colors work correctly in Opera and IE, but only show in the
> dropdownlist in Firefox (Opera and IE apply the style of the selected
> option to the Select control, but Firefox doesn't, this is also why
> the image has to be manually changed through javascript).
> 
> 
> Anyways, please have a look.
> 
> Cheers
> Christopher
> 
> PS: I put the two icons in assets/images folder.
> I made them myself, so there shouldn't be any copyright issues (used:
> Artweaver + Windows Webdings font)
>