Problems rendering dataTable column conditionally [SOLVED]

UI Components for JSF
Post Reply
iranmarcius
Posts: 6
Joined: 17 Jul 2014, 21:50

24 Feb 2015, 17:56

I have the following code:

Code: Select all

			<p:dataTable id="myTable" value="#{list}" var="v">
				<p:column headerText="Column1">
					<h:outputText value="#{v.value}"/>
				</p:column>
				<p:column headerText="Column2" rendered="#{v.something == 'some string'}">
					<h:outputText value="#{v.something}"/>
				</p:column>
			</p:dataTable>
There's a selectOneMenu component that updates the dataTable when the selection is changed. Works fine.

The problem is the rendering of columns inside my dataTable.

When my condition is TRUE the column shows but the title disappears. The width property isn't respected too. The problem occurs only in the column I use that "conditional rendering".

Is this a bug or am I doing something wrong? I think some kind of error is happening during the rendering process but I have no log to investigate.

Any ideas?

iranmarcius
Posts: 6
Joined: 17 Jul 2014, 21:50

24 Feb 2015, 22:10

I figured out. The problem is that my condition was making a comparison using a property belongs the the element being rendered.

For my purpose I can make the comparison using a value returned by the ManagedBean.

Something like:

Code: Select all

  <p:dataTable id="myTable" value="#{myBean.list}" var="v">
       <p:column headerText="Column1">
           <h:outputText value="#{v.value}"/>
       </p:column>
       <p:column headerText="Column2" rendered="#{myBean.someBooleanValue}">
           <h:outputText value="#{v.something}"/>
       </p:column>
   </p:dataTable>
I don't know exactly why I cannot set the rendered property from an expression using a property from my list item, but this way the thing worked!

Thanks!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 34 guests