I have a rich:datatable, which renders rows based on a datatype. One column of the datatable depends on one property of that datatype (ControlType property). Depending on that field, I have to render a combobox, or a textbox, or a checkbox list, or a grid, in that column.

I think I need to create that controls programatically (create UIPanel, UIComboBox, UITextBox, etc). I Created a panel in my .xhtml and bind it to a UIPanel in the backing bean. There I can place personalized controls inside my panel, but the getter of that property in the backing bean fires just one time during page load and doesnt fire for each row.

I think you have to loop every row in the datatable, and for each row find out what type of control it needs to creat. if it only fires in one row, might be because it create the objet for that particular row, and doesn't create the subsequence objects in the other rows.

and if for example the some column was required to input/output data - calendar controls was added: because dataType for the object was initialized with something like "/includes/richtags/calendar.xhtml"(page which contained just rich:cakendar with value from param). For other control type - other control view id was returned.

I am almost there Ilya, but still having problems. I am getting the following error:

javax.el.ELException: Could not Resolve Variable [Overflow]: msj at com.sun.facelets.el.VariableMapperWrapper.resolveVariable(VariableMapperWrapper.java:64) at com.sun.facelets.el.VariableMapperWrapper.resolveVariable(VariableMapperWrapper.java:60) at com.sun.facelets.el.VariableMapperWrapper.resolveVariable(VariableMapperWrapper.java:60) at com.sun.facelets.el.VariableMapperWrapper.resolveVariable(VariableMapperWrapper.java:60) at com.sun.facelets.el.VariableMapperWrapper.resolveVariable(VariableMapperWrapper.java:60)

.

.

Caused by: java.lang.StackOverflowError at java.lang.String.<init>(Unknown Source) at java.lang.StringBuffer.toString(Unknown Source) at com.sun.facelets.el.VariableMapperWrapper.resolveVariable(VariableMapperWrapper.java:64) at com.sun.facelets.el.VariableMapperWrapper.resolveVariable(VariableMapperWrapper.java:60) at com.sun.facelets.el.VariableMapperWrapper.resolveVariable(VariableMapperWrapper.java:60)

.

.

My include code is the following:

<ui:include src="#{question.controlXhtml}" />

being "question" my var in the datatable. controlXhtml returns a String. i.e. it returns "/backend/TextBox.xhtml"

doh... missed that problem.. there are problem that iteration var can't be resolved when include processed. It's content added to view during build view phase and var of dataTable accessible only in iteration durin render responce. read more

In my case it worked because was done inside forEach and not inside UIData.

So in order that to start work with data table condition should be inside include and not in include src. I could propose to try something like:

ControlType is an enum with a getText() method. It is returning correctly the expected text, since I added a <h:outputText value="#{controlType.text}"/> for debugging purposes and it displayed the correct text for each question. But the rendered condition is not working because it is rendering both controls. Shoud I use String.equal? Can I use that in Expression Language? how?