0

We are in the need of populating UISelectOne- and UISelectMany-Components with SeletItems from a database. Instead of subclassing I decided to create a Child-Component element which is able to provide the SelectItems. This way we dont have to introduce new components for this behavior.

But I cant see whats the best way to do this. At first I thought I just need a TagHandler but it seems that idea was a dead end. I tried to create SelectItems within the apply-method but I dont know how to add the items to the component.

Is there another way. Do I have to create a component instead of a TagHandler?

I might be on the wrong path anyway: as mentioned above, I tried to add the items to the component, but shouldnt this be done by the component-tree automatically.

Any help is appreciated.

lostiniceland
  • 3,729
  • 6
  • 38
  • 50
  • Just wondering, how exactly is `` in combination with some application wide `#{data}` managed bean insufficient? – BalusC Aug 06 '12 at 11:59
  • because then we need to provide the code in each bean using some helpermethod. The idea is that we just provide a logical key from the database to the tag and this is then added automatically. – lostiniceland Aug 06 '12 at 12:25
  • I fail to see/understand why "in each bean" is necessary. The `` doesn't necessarily need to refer the same managed bean as where the `value` of the parent select component points to. – BalusC Aug 06 '12 at 12:27

1 Answers1

1

but I dont know how to add the items to the component

Just add it as child of the parent component which is already supplied as argument of apply().

parent.getChildren().add(selectItems);
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • doh! Right...I will just try that out. I think my mistake was that I was working with the class SelectItem, instead of UISelectItem. I still dont know what the difference really is. – lostiniceland Aug 06 '12 at 12:27
  • 1
    The `SelectItem` is the model object representing a single select item (with value and label and so on). The `UISelectItem` represents the option component autogenerated by `` (and the `UISelectItems` represents the option components autogenerated by ``). – BalusC Aug 06 '12 at 12:28