Author
How to add a button to the first row of a dataTable
soumya kalla
Greenhorn
Joined: Jun 05, 2006
Posts: 12
Hello, I am using myFaces for my dataTable. The first cloumn in my table has checkboxes and the other columns have data. In the first row I want to add a button instead of a checkbox. <t:dataTable id="fooPB" value="#{phoneBooksTableDataBeanDto.tableRows}" var="tableRow" rows="5" styleClass="dataTable" headerClass="tableHeader" first="0" columnClasses="checkbox, string , string, string, string" rowClasses="odd, even"> <t:column> <f:facet name="header"> </f:facet> <h:selectBooleanCheckbox value="#{tableRow.selected}" /> </t:column> <t:column> <f:facet name="header"> <t utputText value="#{screen.lastName}" /> </f:facet> <t:inputText value="#{tableRow.lastName}" /> </t:column> <t:column> <f:facet name="header"> <t utputText value="#{screen.firstName}" /> </f:facet> <t:inputText value="#{tableRow.firstName}" /> </t:column> <t:column> <f:facet name="header"> <t utputText value="#{screen.phoneNumber}" /> </f:facet> <t:inputText value="#{tableRow.phoneNumber}" /> </t:column> <t:column> <f:facet name="header"> <t utputText value="#{screen.notes}" /> </f:facet> <t:inputText value="#{tableRow.notes}" /> </t:column> </t:dataTable> </h:panelGrid> i tried adding another set of <f:facet></f:facet> in each column below the header, but the row itself did not show up. Could somebody please tell me how I can add a button to the first row. I hope my question is clear enough.
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
Please be sure to post JSF questions in the JSF forum. I have moved this one for you.
[Smart Questions ] [JSP FAQ ] [Books by Bear ] [Bear's FrontMan ] [About Bear ]
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14571
Easiest way is to put BOTH in the first column and activate the one you want. IIRC, using mythical controls because I've forgotten the exact myFaces ones and it's the idea that counts: <z:buttonControl visible="${firstRow}" etc. /> <z:checkBoxControl visible="${! firstRow}" etc. />
Customer surveys are for companies who didn't pay proper attention to begin with.
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted Oct 26, 2006 23:23:00
0
HtmlDataTable.getRowIndex() returns the row number of the table. So do: JSF MyBean
Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
soumya kalla
Greenhorn
Joined: Jun 05, 2006
Posts: 12
Bauke, Thankyou so much for the code. I tried it using the rowIndex just like you suggested and it worked. I also thank the others for their help. Soumya
subject: How to add a button to the first row of a dataTable