I'm trying to include the paginator on my datatable but it's not working, i have the table and the paginator shows but it's not working, always int page 1 !!
this is my code :
![datatable paginator not working ][1]
<h:form id="form">
<p:outputPanel id="users">
<p:dataTable id="usersTable" value="#{personBean.allPersons}" paginator="true" rows="4" var="person" >
<p:column>
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<p:commandLink action="#{personBean.editPerson}">
<h:outputText value="#{person.name}" />
<f:setPropertyActionListener target="#{personBean.person}"
value="#{person}" />
</p:commandLink>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Age" />
</f:facet>
<p:commandLink action="#{personBean.editPerson}">
<h:outputText value="#{person.age}" />
<f:setPropertyActionListener target="#{personBean.person}"
value="#{person}" />
</p:commandLink>
</p:column>
</p:dataTable>
</p:outputPanel>
<p:commandButton value="Create New User"
action="#{personBean.newPerson}" />
</h:form>
always i have the same table, i can't move to 2
Related
I have a primefaces datatable which displays a list of cars. One of the columns of the datatable has a command button which when clicked opens a dialog box which displays information about the selected car. Everything works as expected until I default filter the datatable and select the command button of a filtered row. The details of the car is null in this case. How can I get the value (car object) of the selected row after filtering?
<h:form id="carView">
<h:panelGrid id="carPanelGroup" style="width:100%" styleClass="tblNowrap100pct">
`<p:dataTable value="#{carBean.carList}" var="car" id="carTbl" stripedRows="true" rendered="#{not empty carBean.carList}" showGridlines="true" styleClass="tblNowrap100pct" filteredValue="#{carBean.filteredValues}" rowKey="#{car.carId}">
<p:column headerText="Car Name" sortBy="#{car.carName}" filterBy="#{car.carName}" filterMatchMode="contains" >
<f:facet name="header">
<h:outputText value="Car Name" />
</f:facet>
<h:outputText value="#{car.carName}" />
</p:column>
<p:column headerText="Make" sortBy="#{car.make}" filterBy="#{car.make}" filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="Make" />
</f:facet>
<h:outputText value="#{car.make}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Car Download" />
</f:facet>
<p:commandButton action="#{carBean.selectCar}" value="Download" styleClass="linkButton" process="#this" oncomplete="PF('carDownloadpanel').show();" update="#all">
<f:setPropertyActionListener value="#{car}" target="#{carBean.carDto}"/>
</p:commandButton>
</p:column>`
</p:dataTable>
</p:panelGrid>
</h:form>
<!-- ******** pop up -->
<p:outputPanel id = "downloadOutputPanel">
<p:dialog header="#{carBean.carDto.carName}" widgetVar="carDownloadpanel" width="500" height="400" id="dialogDetails" modal="true">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="#{carBean.carDto.carName}" />
</h:panelGroup>
</f:facet>
<h:form id="carDetailView">
<p:panel>
<p:panelGrid id="carDetails" columns="2" styleClass="summaryTable"
columnClasses="colLabel, colNormalInputArea" rendered="#{not empty firmBean.firmDto}">
<h:outputText value="Car Name:" />
<h:outputText value="#{carBean.carDto.carName}" />
<h:outputText value="Firm Id:" />
<h:outputText value="#{carBean.carDto.carId}" />
</p:panelGrid>
</p:panel>
</h:form>
<h:form id="iwaInfo">
<h:panelGrid id="carReportInput" columns="2" styleClass="summaryTable" columnClasses="colLabel, colNormalInputArea">
<p:commandLink value="Download" id="downloadBtn"
action="#{carBean.downloadCar}" onclick="PF('carDownloadpanel').hide();">
</p:commandLink>
<p:commandLink value="Cancel" id="cancelBtn"
oncomplete="PF('carDownloadpanel').hide();" update=":carView:carPanelGroup" process="#parent"/>
</h:panelGrid>
</h:form>
</p:dialog>
</p:outputPanel>
Java method :
public String selectCar(){
if (this.carDto != null) {
carId = this.carDto.getCarId();
instanceId = this.carDto.getInstanceId();
if (carId!=null&&instanceId!=null){
CarDto dto = new CarDto();
List<CarDto> sLst = carService.searchCar(Long.parseLong(carId), Long.parseLong(instanceId));
if (sLst!=null&&sLst.size()>0){
dto= sLst.get(0);
}
setCarDto(dto);
}
}
return "";
}
I am trying to use datatable selection in dialog widget. But I cannot get selected value in my bean. Datatable selection is working, if I delete dialog widget tag. I am using PrimeFaces 4.0. How can I fix this?
passengerform.xhtml
<p:hotkey bind="esc" handler="dialogWidget.hide();" />
<p:dialog id="dialog" widgetVar="dialogWidget"
header="Coupon List" modal="true" width="400" showEffect="fade"
hideEffect="fade" appendTo="#(body)">
<h:form id="formDialog">
<h:outputLabel value="Lütfen E-ticket Kuponunu Seçiniz." />
<p:dataTable id="singleDT" var="coupon"
value="#{passengerFormService.couponList}"
rowKey="#{coupon.id}" rowIndexVar="rowIndex"
selection="#{passengerFormService.selectedCoupon}"
selectionMode="single">
<p:ajax event="rowSelect"
listener="#{passengerFormService.selectCoupon}"
update=":tab1:tab1_1:eticketform:formDialog">
<f:setPropertyActionListener value="#{coupon}"
target="#{passengerFormService.coupon}" />
</p:ajax>
<f:facet name="header"></f:facet>
<h:inputHidden name="hidden1"
value="#{passengerFormService.passengerForm.id}" />
<p:column style="width:20px" width="20">
<f:facet name="header">
<h:outputText value="#" />
</f:facet>
<h:outputText value="#{rowIndex+1}" />
</p:column>
<p:column headerText="Id">
<h:outputText value="#{coupon.id}" />
</p:column>
<p:column headerText="Departure Location">
<h:outputText value="#{coupon.departureLocation}" />
</p:column>
<f:facet name="footer"></f:facet>
</p:dataTable>
<p:separator />
<h:panelGrid columns="2" cellspacing="5"
columnClasses="alignLeft,alignRight" style="width:100%">
<p:commandButton id="selectButton1" update=""
icon="ui-icon-close" value="İptal"
oncomplete="PF('dialogWidget').hide()" />
<p:commandButton id="cancelSelectedButton1"
update=":tab1:tab1_1:passengerInsertform"
icon="ui-icon-check"
value="Onayla" oncomplete="PF('dialogWidget').hide()" />
</h:panelGrid>
</h:form>
</p:dialog>
PassengerFormService.java
public void selectCoupon(SelectEvent event) {
Log.getLogger().debug("New2 coupon selected...");
Log.getLogger().debug("selected: " +getSelectedCoupon());
}
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>
I'm working with Primefaces.My functionality is to display the records in a datatable with primefaces inline editing .Here we have an "Add" button which displays a dialog to enter new record.After entering the values and click on "Save" button,the record is inserted and the datatable is updated with the record.
My problem is, when i click on "Add" button for the second time the dialog box is not opening.Here is my code.
<h:form id="myForm" prependId="false">
<p:dataTable var="client" id="clientTable" value="#{clientView.clientModelList}" paginatorPosition="top" paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,25" rowEditListener="#{clientView.rowEditListener}" onRowEditUpdate="growl" >
<p:column style="width:60px;">
<p:rowEditor/>
<h:commandButton style="padding-left:5px;" image="/resources/images/delete.jpeg" styleClass="spa" value="delete" immediate="true" actionListener="#{clientView.delete}" >
<f:attribute name="username" value="#{client}" />
</h:commandButton>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{myLoginBean.multilangMap['everis.client.idCliente']}" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.codCliente}" />
</f:facet>
<f:facet name="input">
<h:inputText required="true" requiredMessage="#{msg.idClienteEmpty}" maxlength="80" value="#{client.codCliente}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{myLoginBean.multilangMap['everis.client.desCliente']}" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.desCliente}" />
</f:facet>
<f:facet name="input">
<h:inputText required="true" requiredMessage="#{msg.desClienteEmpty}" maxlength="255" value="#{client.desCliente}" />
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
</div>
<div class="divButPosition">
<h:panelGroup id="buttonPanel">
<p:commandButton id="buttons" value="Add" actionListener="#{clientView.addEmptyClient}"
async="true" update="buttonPanel,dlgForm:table" rendered="#{!clientView.addNewRow}" oncomplete="alert('complete');clientDialog.show();" />
</h:panelGroup>
</div>
</h:form>
<p:growl id="growl" showDetail="false" />
<p:dialog id="clientDialog" header="Client Detail" widgetVar="clientDialog" resizable="false" width="500" showEffect="explode" hideEffect="explode" modal="false" closable="false">
<h:form id="dlgForm" >
<h:dataTable var="newclient" id="table" value="#{clientView.newClient}">
<h:column>
<f:facet name="header">
<h:outputText value="#{myLoginBean.multilangMap['everis.client.idCliente']}" />
</f:facet>
<h:inputText value="#{newclient.codCliente}" required="true" requiredMessage="#{msg.idClienteEmpty}" maxlength="80"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{myLoginBean.multilangMap['everis.client.desCliente']}" />
</f:facet>
<h:inputText value="#{newclient.desCliente}" required="true" requiredMessage="#{msg.desClienteEmpty}" maxlength="255"/>
</h:column>
</h:dataTable>
<p:commandButton value="everis.save" actionListener="#{clientView.saveClient}" async="true" update="growl,buttonPanel,clientTable" oncomplete="handleRequest(args ,document.getElementById('clientDialog'))" />
<p:commandButton value="#{myLoginBean.multilangMap['everis.cancel']}" immediate="true" update="buttonPanel,table" async="true" actionListener="#{clientView.cancelClient}" oncomplete="clientDialog.hide();" />
</h:form>
</p:dialog>
Thanks alot for every one.
Now correct me if i'm wrong, but if you click save on the dialog you never close it? I won't know if it will help but you can try atleast