• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to add a button to the first row of a dataTable

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:outputText value="#{screen.lastName}" />
</f:facet>
<t:inputText value="#{tableRow.lastName}" />
</t:column>
<t:column>
<f:facet name="header">
<t:outputText value="#{screen.firstName}" />
</f:facet>
<t:inputText value="#{tableRow.firstName}" />
</t:column>
<t:column>
<f:facet name="header">
<t:outputText value="#{screen.phoneNumber}" />
</f:facet>
<t:inputText value="#{tableRow.phoneNumber}" />
</t:column>
<t:column>
<f:facet name="header">
<t:outputText 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.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to post JSF questions in the JSF forum. I have moved this one for you.
 
Saloon Keeper
Posts: 28319
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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. />
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HtmlDataTable.getRowIndex() returns the row number of the table. So do:

JSF

MyBean
 
soumya kalla
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Do you pee on your compost? Does this tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic