How to inject div in JSF datatable excluding header - jsf

I have added a custom scrollbar in my JSF datatable and it looks like that:
My code is this:
<div class="verticalScrollbar" style="max-height:330px;">
<h:dataTable var="entity" value="#{entityBean.entities}"
styleClass="datatable"
headerClass="datatable-header"
rowClasses="datatable-odd-row,datatable-even-row">
<h:column>
<f:facet name="header">
<h:outputText value="Field 1" />
</f:facet>
<h:outputText value="#{entity.field1}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Field 2" />
</f:facet>
<h:outputText value="#{entity.field2}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Field 3" />
</f:facet>
<h:outputText value="#{entity.field3}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Field 4" />
</f:facet>
<h:outputText value="#{entity.field4}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Field 5" />
</f:facet>
<h:outputText value="#{entity.field5}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Field 6" />
</f:facet>
<h:outputText value="#{entity.field6}" />
</h:column>
</h:dataTable>
</div>
<script>
(function($){
$(window).load(function(){
$(".verticalScrollbar").mCustomScrollbar({
scrollButtons:{ enable:false },
horizontalScroll:false,
advanced:{ updateOnBrowserResize:true, updateOnContentResize:true }
});
});
})(jQuery);
</script>
The verticalScrollbar div contains the whole datatable including the header, so when I scroll down the table, I cannot see the header, like that:
How can I apply my scrollbar only to the body of the table excluding the header, so that the header stays still, while only the body scrolls down?

Related

Using inputRowSelect in a dynamic dataTable

Inside the dataTable dynamically creates a dataTable with the records, how can I get the number of rows for each dataTable that was created?
My Table:
<h:dataTable value="#{bean.tableId}"
var="tableIdInfo" rows="10">
<h:column>
<f:facet name="header">
<h:outputText value="id_date"></h:outputText>
</f:facet>
<h:outputText value="#{tableIdInfo.id_date}"
styleClass="outputText">
<hx:convertDateTime pattern="dd.MM.yyyy" />
</h:outputText>
</h:column>
<h:column>
<h:dataTable value="#{bean.tableList}" var="tInfo">
<h:column>
<f:facet name="header">
</f:facet>
<hx:inputRowSelect value="#{bean.rows}">
</hx:inputRowSelect>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText styleClass="outputText"
value="Date create"></h:outputText>
</f:facet>
<h:outputText value="#{tInfo.cDate}">
<hx:convertDateTime pattern="dd.MM.yyyy" />
</h:outputText>
</h:column>
</h:dataTable>
</h:column>
</h:dataTable>
I assume tableId is a list of data.
then add a column for getting row numbers.
<h:column>
<!-- display currently selected row number -->
<f:facet name="header">No</f:facet>
#{bean.tableId.rowIndex + 1}
</h:column>

richfaces DataScroller not working

I am trying to implement datascroller in richfaces 3.1.4 with JSF 1.2 but the datascroller is not working properly though it is showing the no of pages.Here is the code :
<rich:dataTable width="150 px" id="listOfServiceId" rows="#{posManageOrderBean.count}" columnClasses="col"
value="#{posManageOrderBean.customerProjectServiceIds}" var="serviceIDs"
headerClass="dr-stglpnl-h" rowClasses="evenrow,oddrow">
<h:column>
<f:facet name="header">
<h:outputText value="Service Id" rendered="true" />
</f:facet>
<h:commandLink value="#{serviceIDs.serviceID}" action="#{posManageOrderBean.showAllServiceIdAttr}" >
<f:param name="serviceId" value="#{serviceIDs.serviceID}"> </f:param>
</h:commandLink>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Copf Id" rendered="true" />
</f:facet>
<h:outputText value="#{serviceIDs.copfID}" rendered="true" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Service Id" rendered="true" />
</f:facet>
<h:outputText value="#{serviceIDs.customerProjectName}" rendered="true" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Service Id" rendered="true" />
</f:facet>
<h:outputText value="#{serviceIDs.customerName}" rendered="true" />
</h:column>
<f:facet name="footer">
<h:panelGrid>
<rich:datascroller maxPages="20" id="sc1" for="listOfServiceId" reRender="listOfServiceId"></rich:datascroller>
</h:panelGrid>
</f:facet>
</rich:dataTable>

Conditional column rendering

I'm working with jsf 2.0. I have this datatable
<h:dataTable value="#{agreement.licenseProducts}"
var="licenseProduct"
styleClass="pnx-table pnx-table-bdr pnx-table-unstyled mp-license-info">
<h:column>
<f:facet name="header">
<h:outputText value="Product" />
</f:facet>
<h:outputText value="#{licenseProduct.description}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Serial Number" />
</f:facet>
<h:outputText value="#{licenseProduct.serialNumber}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{agreement.labelForConcurrency}" />
</f:facet>
<h:outputText value="#{licenseProduct.concurrent}" />
</h:column>
<ui:fragment rendered="#{agreement.managementTool != 'NONE'}">
<h:column>
<f:facet name="header">
<h:outputText value="#{agreement.labelForLicenseType}" />
<span class="pnx-icon-right pnx-icon-info pnx-tooltip">
<div class="pnx-tooltip-content">
<h:outputText value="Tooltip content" />
</div>
</span>
</f:facet>
<h:outputText value="#{licenseProduct.licenseBase}" />
</h:column>
</ui:fragment>
<h:column>
<f:facet name="header">
<h:outputText value="#{agreement.labelForSeatCount}" />
</f:facet>
<h:outputText value="#{licenseProduct.seats}" />
</h:column>
</h:dataTable>
The problem is that the ui:fragment part is not working. No matter what the attribute's value is, it will NEVER show the column.
Any ideas?
--EDIT--
Just in case, I have other ui:fragments that depend on that same attribute, and they do render correctly depending on the attribute's value. I'm sure it has to do with the dataTable and the columns.
The rendered's attribute of <h:column> tag performs simply the job :
<h:column rendered="#{agreement.managementTool != 'NONE'}">
...
</h:column>

rich:extendedDataTable with dynamic columns

I want to fill a rich:extendedDataTable with a static columns and dynamic columns in RichFaces 4.2
I tried following code,but it's not working for me :
<rich:extendedDataTable id="listDipRec"
iterationStatusVar="itDipRec" rows="200"
value="#{declarationReglementaireModel.detailCurrentDecReg.decReg.listLigneDipRecsDTO}"
var="ligneDipRec" frozenColumns="1"
style="height:300px; width:800px;" selectionMode="none">
<rich:column width="35px">
<h:panelGrid columns="1" cellpadding="2">
<a4j:commandLink render="editGridDipRec" execute="#this"
oncomplete="#{rich:component('modifDipRec')}.show()">
<span class="icone icone-edit icone-align-center" />
<a4j:param value="#{itDipRec.index}"
assignTo="#{declarationReglementaireModel.currentLigneDipRecIndex}" />
<f:setPropertyActionListener
target="#{declarationReglementaireModel.currentLigneDipRec}"
value="#{ligneDipRec}" />
</a4j:commandLink>
</h:panelGrid>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Date ligne fichier Dip" />
</f:facet>
<h:outputText value="#{ligneDipRec.dtLigneDipRec}">
<f:convertDateTime pattern="dd/MM/yyyy" timeZone="Europe/Paris" />
</h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Référence titre" />
</f:facet>
<h:outputText value="#{ligneDipRec.rfTitre}">
</h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Origine titre" />
</f:facet>
<h:outputText value="#{ligneDipRec.lbOrigineLigne}">
</h:outputText>
</rich:column>
<c:forEach items="#{ligneDipRec.listDonneeDipRecDTO}" var="column"
varStatus="status">
<rich:column>
<f:facet name="header">
<h:outputText value="Valeur rubrique" />
</f:facet>
<h:outputText value="#{declarationReglementaireModel.getColumnData(ligneDipRec,column).lbValeurRubrique}" />
</rich:column>
</c:forEach>
</rich:extendedDataTable>
<c:forEach> doesn't have access to the table's variables (i.e. ligneDipRec), and unfortunately you can't do anything about it.
The good news is that whatever you put inside the forEach will have access to those variables. The only thing you need to do is to save the size of the list somewhere in the bean and then loop over it, rather than over the variable:
<c:forEach var="columnNumber" begin="0"
end="{declarationReglementaireModel.detailCurrentDecReg.decReg.listSize - 1}">

Where to keep h:messages in a h:datatable while validating two h:columns

I am using one h:selectbooleancheckbox in each row to make 2 columns editable.
Have a look at my JSF page
<h:dataTable id="editTable" styleClass = "listtable" value="#{bean.GroupList}" var="group" border="1" first="0" rows="8" width="75%" frame="hsides" rules="all" cellpadding="5" headerClass="tableheading" rowClasses="firstrow, secondrow">
<f:facet name="header">
<h:outputText value="Groups"></h:outputText>
</f:facet>
<h:column>
<f:facet name="header">
<h:outputText value="GroupId"></h:outputText>
</f:facet>
<h:outputText value="#{group.Id}" rendered="#{not bean.checked[group.Id]}"></h:outputText>
<h:inputText value="#{group.Id}" rendered="#{bean.checked[group.Id]}" required="true"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="GroupName"></h:outputText>
</f:facet>
<h:outputText value="#{group.Name}" rendered="#{not bean.checked[group.Id]}"></h:outputText>
<h:inputText value="#{group.Name}" rendered="#{bean.checked[group.Id]}" required="true"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Check to Enable/Disable"></h:outputText>
</f:facet>
<h:selectBooleanCheckbox value="#{bean.checked[group.Id]}" />
</h:column>
</h:dataTable>
I have required="true" for GroupId and GroupName columns.
I am not getting where to keep h:messages for each column to display requiredmessage
Please help.
You need to use <h:message> instead to display errors specific to an input element. The <h:messages> will display all messages which are not covered by any <h:message>.
<h:column>
<f:facet name="header">
<h:outputText value="GroupId"></h:outputText>
</f:facet>
<h:outputText value="#{group.Id}" rendered="#{not bean.checked[group.Id]}"></h:outputText>
<h:inputText id="groupId" value="#{group.Id}" rendered="#{bean.checked[group.Id]}" required="true"/>
<h:message for="groupId" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="GroupName"></h:outputText>
</f:facet>
<h:outputText value="#{group.Name}" rendered="#{not bean.checked[group.Id]}"></h:outputText>
<h:inputText id="groupName" value="#{group.Name}" rendered="#{bean.checked[group.Id]}" required="true"/>
<h:message for="groupName" />
</h:column>

Resources