I read many answers abot this issue, they say I should add an item to the list that feed the datatable and then refresh the form, but this does not work in my progect. this is my datatable:
<p:dataTable var="rowItem"
scrollable="true"
scrollHeight="100%"
id="flussiGuestSummary"
emptyMessage="nessun flusso guest selezionato"
value="#{fileMatchMB.selectedGuests}"
rowKey="#{rowItem.row}">
style="width:10px;text-align:center" />
<p:column headerText="Date Valuta"
width="30">
<h:outputText value="#{rowItem.data}">
<f:converter
converterId="filematch.interfaccia.CalendarConverter" />
</h:outputText>
</p:column>
<p:column headerText="Importo"
style="text-align: center; width:30px;">
<h:outputText value="#{rowItem.amount}">
<o:converter converterId="javax.faces.Number"
currencySymbol="#{rowItem.getCurrencySymbol()}"
type="currency" />
</h:outputText>
</p:column>
<p:column headerText="Descrizione"
styleClass="scrollableCell"
style="text-align: center; width:80px;">
<h:outputText value=" #{rowItem.descrizione}">
<f:converter converterId="filematch.interfaccia.StringShortner" />
<f:attribute name="shortnerActive"
value="#{fileMatchMB.shortnerActive}" />
</h:outputText>
</p:column>
<p:column headerText="Causale"
styleClass="scrollableCell"
style="text-align: center; width:30px;">
<h:outputText value=" #{rowItem.causale}"
width="100">
<f:converter converterId="filematch.interfaccia.StringShortner" />
<f:attribute name="shortnerActive"
value="#{fileMatchMB.shortnerActive}" />
</h:outputText>
</p:column>
<p:column headerText="match"
styleClass="scrollableCell"
style="text-align: center; width:10px;">
<h:outputText value=" #{rowItem.match}">
<f:converter converterId="filematch.interfaccia.StringShortner" />
<f:attribute name="shortnerActive"
value="#{fileMatchMB.shortnerActive}" />
</h:outputText>
</p:column>
<f:facet name="footer">
"#{fileMatchMB.countGuest} / #{fileMatchMB.guestList.size()} #{msg.msg_records}"
</f:facet>
</p:dataTable>
the code in the backing bean:
this.selectedGuests = selected_list;
I am sure selected_list is nort empty, but my datatable remains empty, what am I doing wrong?
Related
JSF2.2 project deployed on the Wildfly 8.2.1, I am using the primefaces 6.2. When following code is diplayed on the browser it does not show any result even not the header.
diplayResult.xthml
<h:form id="form">
<div style="border: 1">
<h:messages globalOnly="true" errorClass="err" warnClass="warn"
infoClass="info"></h:messages>
<h:messages globalOnly="false" errorClass="err" warnClass="warn"
infoClass="info"></h:messages>
</div>
<h:panelGrid>
<h:outputLabel id="quantity1"> Line:</h:outputLabel>
<h:message for="quantity1"></h:message>
<h:inputText id="quantity"
value="#{dActivityRelatedController.quantity}"></h:inputText>
<h:message for="quantity" errorClass="err" warnClass="warn"
infoClass="info"></h:message>
<h:commandButton
action="#{dActivityRelatedController.getDndActivitySetupList()}"
value="list"></h:commandButton>
</h:panelGrid>
</h:form>
<h:form id="form2">
<p:dataTable var="activitySetup" value="#{dActivityRelatedController.activitySetupList}">
<f:facet name="header">
Activity Setup List
</f:facet>
<p:columnGroup type="header">
<p:row>
<p:column />
<p:column />
<p:column colspan="2" headerText="------Import Dem------" />
<p:column colspan="2" headerText="------Import Det------" />
<p:column colspan="2" headerText="------Export Dem------" />
<p:column colspan="2" headerText="------Export Det------" />
<p:column headerText="status" />
</p:row>
<p:row>
<p:column headerText="Last Year" />
<p:column headerText="This Year" />
<p:column headerText="From Activity Grp" />
<p:column headerText="To Activity Grp" />
<p:column headerText="From Activity Grp" />
<p:column headerText="To Activity Grp" />
<p:column headerText="From Activity Grp" />
<p:column headerText="To Activity Grp" />
<p:column headerText="From Activity Grp" />
<p:column headerText="To Activity Grp" />
<p:column headerText="" />
</p:row>
</p:columnGroup>
<p:column>
</p:column>
<p:column>
</p:column>
<p:column>
<h:outputText value="#{activitySetup.IMP_ACT_GROUP}" />
</p:column>
<p:column>
<h:outputText value="#{activitySetup.IMP_ACT_GROUP}" />
</p:column>
<p:column>
<h:outputText value="#{activitySetup.IMP_ACT_GROUP}" />
</p:column>
<p:column>
<h:outputText value="#{activitySetup.IMP_ACT_GROUP}" />
</p:column>
<p:column>
<h:outputText value="#{activitySetup.IMP_ACT_GROUP}" />
</p:column>
<p:column>
<h:outputText value="#{activitySetup.IMP_ACT_GROUP}" />
</p:column>
<p:column>
<h:outputText value="#{activitySetup.IMP_ACT_GROUP}" />
</p:column>
<p:column>
<h:outputText value="#{activitySetup.IMP_ACT_GROUP}" />
</p:column>
<p:column>
<h:outputText value="#{activitySetup.IMP_ACT_GROUP}" />
</p:column>
</p:dataTable>
</h:form>
JSF basic tags are working, as below code.
<h:form id="datatableform">
<h:dataTable
value="#{dActivityRelatedController.activitySetupList}"
var="activitySetup">
<h:column>
<f:facet name="header">From Activity Grp</f:facet>
#{activitySetup.IMP_ACT_GROUP}
</h:dataTable>
</h:form>
When I check the diplayed page using firebug, then the complete primefaces code is displayed on the browser that is written on the diplayResult.xthml. That should be converted into equivalent html tags
I have a simple Primefaces Datatable with a SummaryRow. The values of this SummaryRow are calculated in the ManagedBean and available in simple BigDecimal variables. The DataTable is ordered by a String field.
Somehow, the DataTable is being displayed with the summaryRow in every row, and not in the last row.
I've searched for this but didn't find anything about.
I'm using Primefaces 5.3 with JSF 2.2.
The table:
(https://drive.google.com/file/d/0Bw9aJmydXWmvdU8yTUkyYnp0Ums/view)
The XHTML:
<p:dataTable
id="rgmStoricoContrattiSogettoCapogruppoDataTable"
value="#{storicoSoggettoProdottoBean.sogegettoProdottoList}"
var="soggetto"
rendered="#{storicoSoggettoProdottoBean.isNdgMemberOfGroup()}"
styleClass="common_datagrid"
emptyMessage="Nessun valore presente"
sortBy="#{soggetto.denominazione}" >
<p:column headerText="Soggetto">
<p:commandLink
value="#{soggetto.denominazione} #{soggetto.ndg} - #{soggetto.ndgCapogruppo}"
actionListener="#{storicoSoggettoProdottoBean.redirectSoggetoProdotto(request.contextPath, soggetto)}"
immediate="true"
process="#this"
style="font-size: 11px !important;" />
</p:column>
<p:column headerText="Rating And./Cerved" width="67" style="text-align: center">
<h:outputText value="#{soggetto.rating} / #{soggetto.ratingCerved}" />
</p:column>
<p:column headerText="Perfez. storico" width="60" style="text-align: right">
<h:outputText value="#{soggetto.perfezionato}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column headerText="Accord." width="60" style="text-align: right">
<h:outputText value="#{soggetto.accordato}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column headerText="Utilizz." width="60" style="text-align: right">
<h:outputText value="#{soggetto.utilizzato}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column headerText="Sconfino" width="60" style="text-align: right">
<h:outputText value="#{soggetto.sconfino}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column headerText="In proposta" width="60" style="text-align: right">
<h:outputText value="#{soggetto.inProposta}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column headerText="Garanzie bancarie" width="60" style="text-align: right">
<h:outputText value="#{soggetto.garanzieBancarie}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column headerText="Rischio indiretto vs gruppo" width="87" style="text-align: center;">
<h:outputText rendered="#{soggetto.rischioIndirettoVsGruppo == true}" value="SÍ" style="color: green; font-weight: bold;" />
</p:column>
<p:column headerText="Rischio indiretto vs terzi" width="60" style="text-align: right">
<h:outputText value="#{soggetto.rischioIndirettoVsTerzi}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column headerText="Rischio pond." width="60" style="text-align: right">
<h:outputText value="#{soggetto.rischioPonderato}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column width="25">
<p:commandButton
action="#{storicoSoggettoProdottoBean.redirectToStoricoPlafond(request.contextPath, soggetto)}"
immediate="true"
process="#this"
icon="fa fa-file-text-o"
styleClass="imageButton"
style="height: 12px;" />
</p:column>
<p:summaryRow>
<p:column styleClass="totaleRowColor" style="text-align: right;">
<h:outputText value="Totale:" style="font-weight: bold; text-transform: uppercase;" />
</p:column>
<p:column styleClass="totaleRowColor" width="67" />
<p:column styleClass="totaleRowColor" style="text-align: right;" width="60">
<h:outputText value="#{storicoSoggettoProdottoBean.perfezionatoSoggettoSum}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column styleClass="totaleRowColor" style="text-align: right;" width="60">
<h:outputText value="#{storicoSoggettoProdottoBean.accordatoSoggettoSum}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column styleClass="totaleRowColor" style="text-align: right;" width="60">
<h:outputText value="#{storicoSoggettoProdottoBean.utilizzatoSoggettoSum}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column styleClass="totaleRowColor" style="text-align: right;" width="60">
<h:outputText value="#{storicoSoggettoProdottoBean.sconfinoSoggettoSum}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column styleClass="totaleRowColor" style="text-align: right;" width="60">
<h:outputText value="#{storicoSoggettoProdottoBean.inPropostaSoggettoSum}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column styleClass="totaleRowColor" style="text-align: right;" width="60">
<h:outputText value="#{storicoSoggettoProdottoBean.garanzieBancarieSoggettoSum}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column styleClass="totaleRowColor" width="87" />
<p:column styleClass="totaleRowColor" style="text-align: right;" width="60">
<h:outputText value="#{storicoSoggettoProdottoBean.rischioIndirettoVsTerziSoggettoSum}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column styleClass="totaleRowColor" style="text-align: right;" width="60">
<h:outputText value="#{storicoSoggettoProdottoBean.rischioPonderatoSoggettoSum}">
<f:convertNumber type="currency" currencySymbol="€"/>
</h:outputText>
</p:column>
<p:column styleClass="totaleRowColor" width="25" />
</p:summaryRow>
As noted in this question, you have to provide the sortBy attribute on the p:dataTable tag for the summary row to work (as you did in your code snippet). Primefaces uses the expression in the sortBy tag to group the table entries and then provide a summary row for each group.
To get only one group, I tried this:
<p:dataTable sortBy="#{1}" ...>
Works fine for me, I get just one summary row with my grand total now.
Not sure if colspan attribute on column is required for expected result...?
Check the showcase of Primefaces for a sample if you didn't know: http://www.primefaces.org/showcase/ui/data/datatable/summaryRow.xhtml
The summary row uses the sortBy expression, So if you use a sortBy that is say a unique ID, then Primefaces is always going to provide a summary row for every row in the table. Using a constant for sortBy like Ginkobonsai suggests sortBy="#{1}" is a good idea, You could alternatively use a constant field in the POJO.
You can use a sortby value of some data that is shared by all of the rows.
Eg if you are using var soggetto
then you can have a field on that class that is equal across all objects.
Eg soggetto.dummysortby
in the class getDummySortBy returns 1.
I am sorry for my English. I have a JBoss Seam Project and using primefaces in user interface.We have a dialog and inside a datatable. When i select a row im getting following error
ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-localhost-127.0.0.1-8080-1) javax.resource.ResourceException: IJ000460: Error checking for a transaction
PersistenceException org.hibernate.exception.GenericJDBCException: Could not open connection
I thought maybe this error about hibernate but When i tired a lot of way about this problem i couldnt done it But when i moved dialog to new xhtml page it was done.I want to use dialog for my project instead of new page.Where is my mistake following code?
<h:form id="vehicleForm">
<p:commandButton id="selectClientButton" value="Musteri Sec" actionListener="#{clientFacade.clientSearchClear()}" />
</h:form>
<h:form id="selectClientForm">
<p:dialog widgetVar="selectClientDialog" resizable="true" draggable="true" modal="true" header="Arac Satis">
<h:panelGrid columns="4">
<h:outputText value="Adi" />
<h:outputText value="Soy Adı" />
<h:outputText value="TC/Vergi No." />
<h:outputText value="" />
<p:inputText value="#{clientFacade.client.name}" />
<p:inputText value="#{clientFacade.client.lastName}" />
<p:inputText value="#{clientFacade.client.taxNo}" />
<p:commandButton value="ARA" update=":selectClientForm:clientListDT" />
</h:panelGrid>
<p:dataTable id="clientListDT" rows="10" value="#{clientFacade.clientList}" var="client" >
<p:column style="width:3%" >
<p:commandLink id="test" actionListener="#{vehicleStockFacade.selectClient(client.clientId)}" ajax="false" >
<h:graphicImage value="#{icon.icon_select_mine_small}" rendered="#{client.isMyClient}" title="#{msg.choose}" width="15" height="15"/>
<h:graphicImage value="#{icon.icon_select_not_mine_small}" rendered="#{!client.isMyClient}" width="15" height="15" />
</p:commandLink>
</p:column>
<p:column>
<f:facet name="header" >
<h:outputText value="#{msg.client_name}" />
</f:facet>
<h:outputText value="#{client.name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.client_lastname}" />
</f:facet>
<h:outputText value="#{client.lastName}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.tax_no}" />
</f:facet>
<h:outputText value="#{client.taxNo}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.cell_phone}" />
</f:facet>
<h:outputText value="#{clientFacade.useMaskForPhone(client.mobilePhone)}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.town}" />
</f:facet>
<h:outputText value="#{client.town}" />
</p:column>
<p:column>
<f:facet name="header" id="headerId" >
<h:outputText value="#{msg.address}" />
</f:facet>
<h:outputText value="#{client.addressLine1}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.post_code}" />
</f:facet>
<h:outputText value="#{client.postCode}" />
</p:column>
</p:dataTable>
<f:facet name="footer">
<p:commandButton value="Secimi Kaldir" action="#{vehicleStockFacade.removeClientFromVehicleStock()}" style="float:right;margin-bottom:5px" ajax="false" />
</f:facet>
</p:dialog>
</h:form>
I am using PrimeFaces but I have problem with display <p:messages> for converterMessage.
When I use JSF tag <h:message>, it works correctly or even when I insert it into columns, but when I change to <p:message> it does not show. Can anybody helps me? My page is:
<h:form id="form2" prependId="false" style="direction:rtl;width: 600;top: 300px ;position: absolute" >
<p:messages for="count"/>
<p:outputLabel value="sum credit :#{shoppingBean.sumcredit}"/><br/>
<p:outputLabel value="shopping list :"/>
<p:dataTable id="dataTbl2" var="selectedProduct" value="#{shoppingBean.selectedProduct}" emptyMessage="no data"
paginatorAlwaysVisible="true" selection="#{shoppingBean.selection2}"
rowKey="#{selectedProduct.id}" disabledSelection="false" rows="5" paginator="true" pageLinks="5">
<p:column style="color: blue">
<f:facet name="header">
<h:outputText value="brand" />
</f:facet>
<h:outputText value="#{selectedProduct.tblShopProduct.brand}" />
</p:column>
<p:column style="color: blue">
<f:facet name="header">
<h:outputText value="price" />
</f:facet>
<h:outputText value="#{selectedProduct.tblShopProduct.price}" />
</p:column>
<p:column style="color: blue" >
<f:facet name="header">
<h:outputText value="date" />
</f:facet>
<h:outputText value="#{shoppingBean.tblShopOrder.created.toString().substring(0,11)}" />
<h:outputText value="#{shoppingBean.tblShopOrder.created.toString().substring(11,19)}" />
</p:column>
<p:column style="color: blue" >
<f:facet name="header">
<h:outputText value="number" />
</f:facet>
<h:outputText value="#{selectedProduct.number}" />
</p:column>
<p:column style="color: blue" >
<f:facet name="header">
<h:outputText value="amount" />
</f:facet>
<h:outputText value="#{selectedProduct.amount}" />
</p:column>
<p:column style="color: blue">
<f:facet name="header">
<h:outputText value="edit"/>**<h:inputText id="count" converterMessage="you allowed only for using number value="#{shoppingBean.count}"/>**
</f:facet>
<h:commandButton value="sum" rendered="#{selectedProduct.number==null}" action="#{shoppingBean.addProductCount(selectedProduct)}" />
<h:commandButton value="confirm" disabled="true" rendered="#{selectedProduct.number!=null}" />
</p:column>
<p:column style="color: blue" >
<f:facet name="header">
<h:outputText value="delete" />
</f:facet>
<h:commandButton value="delete" action="#{shoppingBean.deleteBuyed(selectedProduct)}" />
</p:column>
<f:facet name="footer">
<h:commandButton value="final shopping" action="#{shoppingBean.finalShop(selectedProduct)}" />
</f:facet>
</p:dataTable>
</h:form>
Tohid Makari.
<h:outputText value="edit"/>**<h:inputText id="count" converterMessage="you allowed only for using number value="#{shoppingBean.count}"/>**
This line could not work. Fix this first.
You do not update your messages tag.
Try something like this :
<p:messages for="count" autoUpdate="true" />
I am having trouble updating components in primefaces. Here is one example:
<h:form>
<p:panel style="width: 350px;" header="Partial Process">
<p:dataTable id="tablaPersonas" var="per" value="#{manejador.lista}">
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Nombre" />
</f:facet>
<h:outputText value="#{per.nombre}" />
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Apellido" />
</f:facet>
<h:outputText value="#{per.apellido}" />
</p:column>
<p:column headerText="Editar" style="text-align: center;">
<p:commandButton value="Editar"/>
</p:column>
</p:dataTable>
</p:panel>
<p:commandButton value="Abrir" onclick="widgetDlgAgregar.show();"/>
<p:dialog header="Agregar" widgetVar="widgetDlgAgregar" width="250" height="150" closable="true">
<h:panelGrid id="gridAdd" columns="2">
<h:outputLabel value="Nombre:"/>
<p:inputText value="#{manejador.auxiliarAgregar.nombre}"/>
<h:outputLabel value="Apellido:"/>
<p:inputText value="#{manejador.auxiliarAgregar.apellido}"/>
<p:commandButton oncomplete="widgetDlgAgregar.hide();" update="tablaPersonas,gridAdd" value="Agregar" actionListener="#{manejador.agregarPersona}"/>
</h:panelGrid>
</p:dialog>
</h:form>
As you see, I click on a CommandButton called "Abrir" and a Dialog opens with "Agregar" as title. I fill in the input boxes and when I click the CommandButton "Agregar", the DataTable isn't updated. Why is this happening?
Oh sorry i think you forgot this update
try this it should work
<h:form prependId="false">
<p:panel style="width: 350px;" header="Partial Process">
<p:dataTable id="tablaPersonas" var="per"
value="#{manejador.lista}">
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Nombre" />
</f:facet>
<h:outputText value="#{per.nombre}" />
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Apellido" />
</f:facet>
<h:outputText value="#{per.apellido}" />
</p:column>
<p:column headerText="Editar" style="text-align: center;">
<p:commandButton value="Editar" />
</p:column>
</p:dataTable>
</p:panel>
<p:commandButton value="Abrir" onclick="widgetDlgAgregar.show();" update="gridAdd" />
<p:dialog header="Agregar" widgetVar="widgetDlgAgregar" width="250"
height="150" closable="true">
<h:panelGrid id="gridAdd" columns="2">
<h:outputLabel value="Nombre:" />
<p:inputText value="#{manejador.auxiliarAgregar.nombre}" />
<h:outputLabel value="Apellido:" />
<p:inputText value="#{manejador.auxiliarAgregar.apellido}" />
<p:commandButton oncomplete="widgetDlgAgregar.hide();"
update="tablaPersonas,gridAdd" value="Agregar"
actionListener="#{manejador.agregarPersona}" />
</h:panelGrid>
</p:dialog>
</h:form>
try to put your
<p:dialog header="Agregar" widgetVar="widgetDlgAgregar" width="250" height="150" closable="true">
outside the form and add prependId="false" to your form <h:form prependId="false" >