I have a requirement to create a panel dynamically using jsf 2.0 custom components. The controls within the panel will be dynamically read from an xml and rendered on the selection of the corresponding object (Eg : If Person is selected, I should render a panel which will have controls related to person like : Person age field(inputtext), Person DOB(calendar) and so on).
I am trying to render it from the component class which extends UIComponentBase.
I have done this way. But I am getting a null pointer exception. How can the panel with the defined controls be rendered dynamically?
This is what I'm getting -
====Will Start Rendering====
inside the panel get method------
Sep 7, 2011 10:01:42 AM com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback visit
I've seen other people do similar things with JSF and I'm a little cynical on the matter, since there's already a system that can take XML definitions and render them like that, and it's called JSF. The only time I ever did anything that involved run-time construction of display components in all the years I've used JSF was in a generic database table editor app where the edit and display views were dynamically constructed from introspection of the database schema. For most apps, the internal arrangements are much more rigidly defined and it's much simpler to use Facelets components and other basic JSF building blocks without actually having to muck about in JSF's internal arrangements.
Creating a JSF custom control is a solution of last resort. The entire process and architecture is muddied and confused by the fact that it's a mish-mash of several earlier technologies, some of them overlapping, plus 2-3 generations of mutation within JSF itself. Just trying to find a decent set of design docs that are appropriate for the JSF release you're using can be a real challenge.
Excepting specialized cases such as generating unusual HTML tags, it's usually easier to construct custom components as facelets components or XML custom tags.
When static definitions are not sufficient, the next-best solution is to define a binding container on the static View and have a backing bean construct and add UIComponent objects as children to that bound container UIComponent. It's a lot less work that attempting to generate (and read back) brute-force HTML the way a custom tag class has to.
Customer surveys are for companies who didn't pay proper attention to begin with.