title: Conditionally rendering a row in a <h:datatable>
body: <p>I'm trying to change an existing data table (written by a previous developer) so that you see the whole table if logged in as sysadmin but only see your own details if logged in as someone else.</p>
  
  <p>I've tried doing this by adding a <code>rendered</code> tag to each value in the table. This has let me see that my checks are working and get the basic test working. That part of the code is functioning as intended. However, there's an obvious flaw in that the extra rows still get generated whether they are filled up or not.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;h:dataTable value="#{userBean.users}" var="userAccount"
                  binding="#{userBean.userTable}"
                  styleClass="defaultTable"
                  headerClass="tableHeader"
                  rowClasses="evenRow,oddRow"
                  columnClasses="col512"&gt;
  
      &lt;h:column&gt;
          &lt;f:facet name="header"&gt;
              &lt;h:outputText value="Username"/&gt;
          &lt;/f:facet&gt;
          &lt;h:commandLink value="#{userAccount.userName}"
                         action="#{userBean.edit}"
                         rendered="#{(userAccount.userName == settings.user.userName) 
                                         || settings.user.systemAdministrator}"/&gt;
      &lt;/h:column&gt;
  
      &lt;h:column&gt;
          &lt;f:facet name="header"&gt;
              &lt;h:outputText value="User Group"/&gt;
          &lt;/f:facet&gt;
          &lt;h:outputText id="userGroup" value="#{userAccount.userGroup.userGroupName}"
                        rendered="#{(userAccount.userName == settings.user.userName)
                                         || settings.user.systemAdministrator}"/&gt;
      &lt;/h:column&gt;
  &lt;/h:dataTable&gt;
  </code></pre>
  
  <p>When not systemAdministrator it (predictably) outputs something like this:</p>
  
  <p><img src="https://i.stack.imgur.com/aY74L.png" alt="image"></p>
  
  <p>with all the rows generated but only filled in for the current user.</p>
  
  <p>I understand why it's doing this, but I'm not sure how to get it to do what I want it to do instead. It's like I want to <code>render</code>/not <code>render</code> the whole row but the data table is generated by column not row so I can't see how to add that. Even adding a <code>&lt;c:if&gt;</code>, I'd need to add it around the row, so I don't see how I can do that when it's generated by column.</p>
  
  <p>The other idea I had was that I could just check to see if the row is empty and if so hide it? But that feels a bit dirty to me. </p>
  
  <p>Which of these options would be best and how do I get around the checking/hiding row without <code>row</code> tags thing? Or do I need to restructure the whole table? (Might be above my ability.)</p>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>The showClass/hideClass <code>rowClasses</code> that @xild suggested looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/6AUvO.png" alt="enter image description here"></p>
  
  <p>i.e. the same but without the breaks between the rows.</p>