Ability to add attributes to drop-down-list (select) options
------------------------------------------------------------

                 Key: WICKET-1785
                 URL: https://issues.apache.org/jira/browse/WICKET-1785
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 1.4-M3
            Reporter: Martin Makundi
            Priority: Minor


Time-after-time, there is need to style your select options in a DropDownChoice 
component. For example, the different options need to have different background 
colour, or something.

This can be accomplished using Select/SelectOption, but here you are required 
to re-implement all the intelligence already built into the 
dropdownchoice/listchoice component (automatic notnull and localization, for 
example). 

How could we leverage the existing functionality of the DropDownChoice but 
enhance it with the ability to parametrize option attributes individually?

Our suggestion is that we refactor suitable hooks into the rendering phase of 
the xxChoice components, i.e., a method along the lines of  "String 
getOptionAttributes(T t)" to be called, during the render phase of a 
DropDownChoice (in order to add attributes for the option tag).

With this kind of impementation it would then be easier for anybody to 
'sugarcoat' their DropDownChoice without breaking the existing inplementations. 
For example, one way to use it would be to just add a getDispayStyle method 
into your implementation of the IChoiceRenderer, and implement a respective 
check in your overriding "getOptionAttributes" -method:

MyDropDownChoice extends DropDownChoice() { 
  @Override
  protected String getOptionAttributes(T t) {
    if (renderer instanceof MyChoiceRenderer) { 
      ... and sugarcoat my option ... 
    }
  }
}


More discussion can be found at: 
http://www.nabble.com/color-code-options-in-drop-down-choice-tp16964792p18909328.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to