Search code examples
jsf-2xhtml

Title not appearing when hovering over the column of a datatable


For code similar to that below, the title does not appear when the cursor hovers over a column header. Any ideas?

        <h:column title="COLUMN 1">
            <f:facet name="header" >COL 1</f:facet>
            <h:outputText id="col1" value="#{oneEntry.col1}" styleClass="al"/>
        </h:column>

        <h:column title="COLUMN 2">
            <f:facet name="header" >COL 2</f:facet>
            <h:outputText id="col2" value="#{oneEntry.col2}" styleClass="al"/>
        </h:column>

Solution

  • The <h:column> tag has no HTML 4.0 pass-through attributes as JSF generates these as nothing but <td> elements. And in HTML, tables consist of <td> elements within rows and columns are implicitly defined within the rows.

    So it is liking specifying the title attribute for each particular <td> element of each and every row.

    <table border="1">
      <tr>
       <td title="first">Cell A1</td>
       <td>Cell B1</td>
      </tr>
      <tr>
       <td title="first">Cell A2</td>
       <td>Cell B2</td>
      </tr>
    </table>
    

    So there is nothing like specifying an overall title for the column in HTML, you can have a title for <table> tag which is nothing but <h:dataTable>.

    Or you can have title on individual data cells by adding title to your components inside that column like this:

    <h:column>
          <f:facet name="header" >COL 1</f:facet>
          <h:outputText id="col1" value="#{oneEntry.col1}" styleClass="al"  title="COLUMN 1"/>
    </h:column>
    
     <h:column>
          <f:facet name="header" >COL 2</f:facet>
          <h:outputText id="col2" value="#{oneEntry.col2}" styleClass="al" title="COLUMN 2"/>
    </h:column>
    

    which generates a <span> containing the value of the outputText with the title attribute.