Author
dataTable styling question
Dave Alvarado
Ranch Hand
Joined: Jul 02, 2008
Posts: 434
Hi, Does anyone know how to make a panelGrid's main header row different from the cell's header rows? For example, if you look at the screen shot http://screencast.com/t/T7sN6r3B I want the "Results 1-20" row to have a different class than the row with the column titles ("Client System", "Destination System", etc.). Here's the (unsuccessful) JSF I'm using ... <h:dataTable id="dt1" binding="#{SearchResultsPage.dataTable}" value="#{SearchBean.results}" var="item" border="10" cellpadding="5" cellspacing="3" dir="LTR" frame="hsides" rules="all" columnClasses="tableHeader" rowClasses="evenRow,oddRow" headerClass="tableHeader2"> <f:facet name="header"> <h utputText value="Results #{SearchBean.startResultRow}-#{SearchBean.lastResultRow} of #{SearchBean.numResults} (#{SearchBean.numPages} page(s))" /> </f:facet> <h:column> <f:facet name="header"> <h utputText value="Client System" /> </f:facet> <h utputText value="#{item.clientSys}"></h utputText> </h:column> "f:facet" doesn't support styleClass, so I pose this question to the group for inspiration. Thanks, - Dave
Darryl Nortje
Ranch Hand
Joined: Jun 11, 2002
Posts: 140
Hey Dave, facet might not support styleClass, but doesn't outputText support styleClass?? cheers Darryl
Dave Alvarado
Ranch Hand
Joined: Jul 02, 2008
Posts: 434
The problem is applying a styleClass to the outputText only applies it to the span and not the overall TD. This is what happens http://screencast.com/t/jl3oCGS3 when I do this ... <h:dataTable id="dt1" binding="#{SearchResultsPage.dataTable}" value="#{SearchBean.results}" var="item" border="10" cellpadding="5" cellspacing="3" dir="LTR" frame="hsides" rules="all" rowClasses="evenRow,oddRow" headerClass="tableHeader2"> <f:facet name="header"> <h utputText value="Results #{SearchBean.startResultRow}-#{SearchBean.lastResultRow} of #{SearchBean.numResults} (#{SearchBean.numPages} page(s))" /> </f:facet> <h:column> <f:facet name="header"> <h utputText styleClass="tableHeader" value="Client System" /> </f:facet> <h utputText value="#{item.clientSys}"></h utputText> </h:column> There's got to be a way to make the style apply to the table cell. How? Thanks, - Dave
Kavita Tipnis
Ranch Hand
Joined: Sep 21, 2008
Posts: 177
posted Nov 04, 2008 11:51:00
0
I implemented a simple datatable to do what you were aiming for. Here is the code: mystyle.css Hope it works for you
Dave Alvarado
Ranch Hand
Joined: Jul 02, 2008
Posts: 434
Thanks for your response but when I added the "headerClass" attribute to the h:column tag, I got this compilation error search_results.jsp:46:15: This attribute is not recognized. <h:column headerClass="tableHeader"> ^---------^ I'm using WebLogic 9.2.2 with MyFaces 1.1.5. - Dave
Kavita Tipnis
Ranch Hand
Joined: Sep 21, 2008
Posts: 177
posted Nov 05, 2008 06:46:00
0
I checked the differences in both Mojarra (Sun JSF RI ) and MyFaces RI and you are right, there is no attribute 'headerClass' in MyFaces RI (Links to check: http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/tlddocs/index.html http://myfaces.apache.org/core11/myfaces-impl/tlddoc/index.html ) However, I think in MyFaces you can create an tablecolumn component(programmatically) or use binding attribute and use the setHeaderClass()method on the column. I am not using MyFaces RI, if you check the API docs you will get more information.
subject: dataTable styling question