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" />
Related
I'm trying to export data from DataTable using DataExporter tag, but, DataExporter is exporting only first page data (page of the print), but I want to export data from all pages.
See below my button code and the screen.
Code:
<p:dataTable id="listaConsulta" rowStyleClass="#{empty rowIx or rowIx mod 2 ne 0 ? 'jsfcrud_odd_row' : 'jsfcrud_even_row'}" rowIndexVar="rowIx" value="#{funcionarioController.items}" var="item">
<p:column>
<f:facet name="header">
<h:outputText value="Código"/>
</f:facet>
<h:outputText value="#{item.codigo}"/>
</p:column>
<p:column width="25%">
<f:facet name="header">
<h:outputText value="Nome"/>
</f:facet>
<h:outputText value="#{item.nome}"/>
</p:column>
<p:column width="10%">
<f:facet name="header">
<h:outputText value="Cpf"/>
</f:facet>
<h:outputText value="#{item.cpf}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Nascimento"/>
</f:facet>
<h:outputText value="#{item.datanascimento}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column width="25%">
<f:facet name="header">
<h:outputText value="Cargo"/>
</f:facet>
<h:outputText value="#{item.cargo.descricao}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Telefone"/>
</f:facet>
<h:outputText value="#{item.fone}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Celular"/>
</f:facet>
<h:outputText value="#{item.celular}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Ativo"/>
</f:facet>
<h:outputText value="#{item.estaAtivo}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<h:commandLink title="Editar" action="Create?faces-redirect=true&includeViewParams=true">
<f:setPropertyActionListener value="#{item}" target="#{funcionarioController.selected}"/>
<h:graphicImage height="32" value="/image/file_edit.png" />
</h:commandLink>
<h:commandLink title="Ficha Registro" target="_blank" action="#{funcionarioController.gerarRelatorioJasper}">
<f:setPropertyActionListener value="#{item}" target="#{funcionarioController.selected}"/>
<p:graphicImage value="/image/pdf.png" />
</h:commandLink>
</p:column>
</p:dataTable>
</h:panelGroup>
<br />
<p:commandButton ajax="false" immediate="true" action="#{funcionarioController.prepareCreate()}" value="#{bundle.ListFuncionarioCreateLink}"/>
<p:spacer width="10px"/>
<p:commandButton value ="Gerar Excel" ajax="false">
<p:dataExporter type="xls" target="listaConsulta" fileName="dadosFuncionarios" encoding="utf-8" pageOnly="false"/>
</p:commandButton>
Screen:
How do I solve this?
EDIT: I change the code inserting datatable and dataexporter entire code.
I am new to primefaces. I have one datatable in my application. In that for 3 columns i need to merge some rows. That row count will be generated dynamically based on the data. If I tried to use rowspan in that particular column tag, it additionally created blank cells and the total datatable format is changed. How to do merge that datarows in primefaces. For reference, I am attaching the design and code.
Xhtml code:
<f:facet name="header">
<h:outputText value="Date"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_date}" />
</p:column>
<p:column style="font-size:12px;width:73px;" >
<f:facet name="header">
<h:outputText value="Slot"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_slot}" />
</p:column>
<p:column style="font-size:12px;width:73px;" >
<f:facet name="header">
<h:outputText value="Number of Resources Required"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_noresources}" />
</p:column>
<p:column headerText="Select" id="hSelect" style="font-size:12px;width:60px;">
<p:selectBooleanCheckbox id="Booleanchkbox" onclick="{dtstep2_tab1.select='true'}" >
<p:ajax listener="#{dtstep2_tab1.UpdateStatus}" update="panel1" />
</p:selectBooleanCheckbox>
</p:column>
<p:column style="font-size:12px;width:70px;">
<f:facet name="header">
<h:outputText value="Employee Name"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_empname}" />
</p:column>
<p:column style="font-size:12px;width:120px;">
<f:facet name="header">
<h:outputText value="Contact Details"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_contactdet}" />
</p:column>
<p:column style="font-size:12px;width:70px;">
<f:facet name="header">
<h:outputText value="Worked Hrs to Date"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_totworkhours}" />
</p:column>
<p:column style="font-size:12px;width:50px;">
<f:facet name="header">
<h:outputText value="Agency Recruited"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_recruitmode}" />
</p:column>
<p:column style="font-size:12px;width:70px;">
<f:facet name="header">
<h:outputText value="Priority"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_priority}"/>
</p:column>
<p:column style="font-size:12px;width:90px;">
<f:facet name="header">
<h:outputText value="Type of Skill"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_skilltype}" />
</p:column>
<p:column style="font-size:12px;width:120px;">
<f:facet name="header">
<h:outputText value="Restriction"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_restriction}" />
</p:column>
<p:column style="font-size:12px;width:150px;">
<f:facet name="header">
<h:outputText value="Rest. Details"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_restdet}" />
</p:column>
<p:column style="font-size:12px;width:70px;">
<f:facet name="header">
<h:outputText value="B2B Days"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_b2bdays}" />
</p:column>
<p:column style="font-size:12px;width:70px;">
<f:facet name="header">
<h:outputText value="B2B Hrs"></h:outputText>
</f:facet>
<h:outputText value="#{step2table.rs2_b2bhrs}" />
</p:column>
<p:column headerText="Status" id="hStatus" style="font-size:12px;width:100px;">
<h:selectOneMenu id="cbo" value="#{step2table.rs2_status}" >
<f:selectItem itemLabel="Confirmed" itemValue="Confirmed"></f:selectItem>
<f:selectItem itemLabel="Selected" itemValue="Selected"></f:selectItem>
<f:selectItem itemLabel="Rejected" itemValue="Rejected"></f:selectItem>
</h:selectOneMenu>
</p:column>
<p:column style="font-size:12px;width:150px;">
<f:facet name="header">
<h:outputText value="Comments"></h:outputText>
</f:facet>
<h:inputText value="#{step2table.rs2_comments}" rendered="#{dtstep2_tab1.editable}"/>
</p:column>
Need to merge first three columns "date, Slot, and No of Resources Required" based on the employee column data. Guide me on this. Thanks in advance.
You can use p:summaryRow tag in p:dataTable. Example:
<h:form>
<p:dataTable var="car" value="#{dtSummaryRowView.cars}" sortBy="#{car.brand}">
<p:column headerText="Id" sortBy="#{car.id}">
<h:outputText value="#{car.id}" />
</p:column>
<p:column headerText="Year" sortBy="#{car.year}">
<h:outputText value="#{car.year}" />
</p:column>
<p:column headerText="Brand" sortBy="#{car.brand}">
<h:outputText value="#{car.brand}" />
</p:column>
<p:column headerText="Color" sortBy="#{car.color}">
<h:outputText value="#{car.color}" />
</p:column>
<p:summaryRow>
<p:column colspan="3" style="text-align:right">
<h:outputText value="Total:" />
</p:column>
<p:column>
<h:outputText value="#{dtSummaryRowView.randomPrice}">
<f:convertNumber type="currency" currencySymbol="$" />
</h:outputText>
</p:column>
</p:summaryRow>
</p:dataTable>
</h:form>
For more information, see the primefaces showcase link: http://www.primefaces.org/showcase/ui/data/datatable/summaryRow.xhtml
This is simply not possible in the datatable.
<p:column width="440">
<p:panelGrid rendered="#{someCondition}">
<f:facet name="header">
<p:row>
<p:column width="80"><h:outputText value="#{msg.isin}" /></p:column>
<p:column width="80"><h:outputText value="#{msg.wkn}" /></p:column>
<p:column width="200"><h:outputText value="#{msg.name}" /></p:column>
<p:column width="80"><h:outputText value="#{msg.amount}" /></p:column>
</p:row>
</f:facet>
<p:row>
<p:column><h:outputText value="#{savingsPlanPosition.isin}" /></p:column>
<p:column><h:outputText value="#{savingsPlanPosition.wkn}" /></p:column>
<p:column><h:outputText value="#{savingsPlanPosition.name}" /></p:column>
<p:column><h:outputText value="#{savingsPlanPosition.amount}" /></p:column>
</p:row>
</p:panelGrid>
<p:panelGrid rendered="#{!someCondition}">
<h:link id="savingsPlanPositionDetails${rowIndex}"
title="#{msg.assign_etf}"
outcome="portfolioPositionDetail">
<f:param name="portfolioId"
value="#{savingsPlanController.portfolioId}"></f:param>
<f:param name="portfolioPositionId"
value="#{savingsPlanPosition.portfolioPositionId}"></f:param>
<f:param name="from"
value="savingsPlan"></f:param>
<h:outputText value="#{msg.assign_etf}"/>
</h:link>
</p:panelGrid>
</p:column>
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>
Below is code of xhtml page,
even i put dialog in a form or not i can see outputtexts below of the page.
I am running into such situation for the first time.
<h:form id="form">
<h:outputLabel value="Welcome #{loginBean.name}"></h:outputLabel>
<p:dataTable id="cars" var="book" value="#{indexView.mediumBooksModel}" paginator="true" rows="10"
selection="#{indexView.selectedBook}" rowKey="">
<f:facet name="header">
RadioButton Based Selection
</f:facet>
<p:column selectionMode="single" style="width:2%" />
<p:column headerText="Title" style="width:25%">
#{book.title}
</p:column>
<p:column headerText="ISBN" style="width:25%">
#{book.isbn}
</p:column>
<p:column headerText="Year" style="width:24%">
#{book.year}
</p:column>
<p:column headerText="Price" style="width:24%">
#{book.price}
</p:column>
<f:facet name="footer">
<p:commandButton id="viewButton" value="View" icon="ui-icon-search"
update=":displaySingle" oncomplete="singleBookDialog.show()"/>
</f:facet>
</p:dataTable>
</h:form>
<p:dialog id="dialog" header="Book Detail" widgetVar="singleBookDialog" resizable="false"
modal="true" >
<h:panelGrid id="displaySingle" columns="2" cellpadding="4">
<f:facet name="header">
<p:graphicImage value="/images/books/#{indexView.selectedBook.image}.jpg"/>
</f:facet>
<h:outputText value="Title:" />
<h:outputText value="#{indexView.selectedBook.title}" style="font-weight:bold"/>
<h:outputText value="Year:" />
<h:outputText value="#{indexView.selectedBook.year}" style="font-weight:bold"/>
<h:outputText value="ISBN:" />
<h:outputText value="#{indexView.selectedBook.isbn}" style="font-weight:bold"/>
<h:outputText value="Price:" />
<h:outputText value="#{indexView.selectedBook.price}" style="font-weight:bold"/>
</h:panelGrid>
</p:dialog>
why when i add a seconde DataTable in my page i lose the entire content of this page ? im using JSF PrimeFaces.
This is my first DataTable:
<p:tab title="Projet">
<!-- ======================== Contenu ======================== -->
<br/>
<h:form id="form">
<p:dataTable var="car" value="xxxxx" selection="xxxx" selectionMode="single">
<f:facet name="header">
Listes des projets Gpsi
</f:facet>
<p:column>
<f:facet name="header">
<h:outputText value="Code" />
</f:facet>
<h:outputText value="xxxx" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Intitulé" />
</f:facet>
<h:outputText value="xxxx" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Dernière Etat" />
</f:facet>
<h:outputText value="xxxx" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Domaine" />
</f:facet>
<h:outputText value="xxxx" />
</p:column>
<f:facet name="footer">
<p:commandButton value="Ouvrire" image="ui-icon ui-icon-search" update="form:display" oncomplete="carDialog.show()"/>
</f:facet>
</p:dataTable>
<p:dialog header="Car Detail" widgetVar="carDialog" resizable="false" width="200" showEffect="clip" hideEffect="fold">
<h:panelGrid id="display" columns="2" cellpadding="4">
<f:facet name="header">
<p:graphicImage value="/images/cars/xxxx.jpg"/>
</f:facet>
<h:outputText value="Model:" />
<h:outputText value="xxxx" />
<h:outputText value="Year:" />
<h:outputText value="xxxx" />
<h:outputText value="Manufacturer:" />
<h:outputText value="xxxx" />
<h:outputText value="Color:" />
<h:outputText value="xxxx" />
</h:panelGrid>
</p:dialog>
</h:form>
And this one in the seconde tab :
<p:tab title="Objets">
<h:form id="form">
<p:dataTable var="car" value="pppp"
selection="mmmm" selectionMode="single">
<f:facet name="header">
Liste des Objets
</f:facet>
<p:column>
<f:facet name="header">
<h:outputText value="Model" />
</f:facet>
<h:outputText value="Model" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Year" />
</f:facet>
<h:outputText value="Year" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Manufacturer" />
</f:facet>
<h:outputText value="Manufacturer" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Color" />
</f:facet>
<h:outputText value="Color" />
</p:column>
<f:facet name="footer">
<p:commandButton value="View" image="ui-icon ui-icon-search"
update="form:display" oncomplete="carDialog.show()"/>
</f:facet>
</p:dataTable>
<p:dialog header="Car Detail" widgetVar="carDialog" resizable="false"
width="200" showEffect="clip" hideEffect="fold">
<h:panelGrid id="display" columns="2" cellpadding="4">
<f:facet name="header">
<p:graphicImage value="sss"/>
</f:facet>
<h:outputText value="Model:" />
<h:outputText value="xxx" />
<h:outputText value="Year:" />
<h:outputText value="xxx" />
<h:outputText value="Manufacturer:" />
<h:outputText value="xxx" />
<h:outputText value="Color:" />
<h:outputText value="xxx" />
</h:panelGrid>
</p:dialog>
</h:form>
<!-- ======================== FIN Contenu ===================== -->
</p:tab>
You should try to enclose your tabView with a single h:form, then place your dataTables inside your tabs:
<h:form id="form">
<p:tabView id="myTabView">
<p:tab id="firstTab">
<p:dataTable ....>
....
</p:dataTable>
</p:tab>
<p:tab id="secondTab">
<p:dataTable ....>
....
</p:dataTable>
</p:tab>
</p:tabView>
</h:form>
Two forms with the same id="form" --> error. Rename one of the forms.