Search code examples
javajsficefaces

JSF/ICEFaces Custom Component Design Pattern & Read up


I need to create a custom component which consist of a drop down box, tree and a display panel for the details a selected item of a node.

This UI component will be a popup for users to select some items and add to the backing bean. (It can be use to select shirts, cars or anything that fit the level and tree data)

May I know is there any good read up best practice when it comes to creating custom component for multiple usage.

After brain storming I have identify the following problems.

1) How to pass back the selections to the backingbean? Possible solution: implement observer pattern for the custom component so when user click [OK] it will pass back the value to the backing bean before closing the custom component

2) The display of details of the selected node. (Different type of items can display differently) Possible solution: I might consider using UI:Include but I am thinking of a more elegant solution

Any other issues????

Any help?


Solution

  • I'll ignore the ICEfaces part in the question as I don't use it.

    1) How to pass back the selections to the backingbean?

    Provide a value attribute wherein you can just specify the bean property. Easiest is to let your custom component extend UIInput which provides this attribute already.


    2) The display of details of the selected node. (Different type of items can display differently) Possible solution: I might consider using UI:Include but I am thinking of a more elegant solution

    You could provide support for specific <f:facet>s. In the encodeChildren() of the component or its renderer you can get them by UIComponent#getFacet().