aspose file tools*
The moose likes JSF and the fly likes How to add a button to the first row of a dataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to add a button to the first row of a dataTable" Watch "How to add a button to the first row of a dataTable" New topic
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">
<tutputText value="#{screen.lastName}" />
</f:facet>
<t:inputText value="#{tableRow.lastName}" />
</t:column>
<t:column>
<f:facet name="header">
<tutputText value="#{screen.firstName}" />
</f:facet>
<t:inputText value="#{tableRow.firstName}" />
</t:column>
<t:column>
<f:facet name="header">
<tutputText value="#{screen.phoneNumber}" />
</f:facet>
<t:inputText value="#{tableRow.phoneNumber}" />
</t:column>
<t:column>
<f:facet name="header">
<tutputText 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: 60046
    
  65

Please be sure to post JSF questions in the JSF forum. I have moved this one for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15629
    
  15

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
HtmlDataTable.getRowIndex() returns the row number of the table. So do:

JSF

MyBean
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to add a button to the first row of a dataTable
 
Similar Threads
strachable columns in jsf
selectBooleanCheckbox
InputText in DataTable does not store value
Non-unique IDs generated by MyFaces Tomahawk t:columns tag
nested datatable not working