Centering a gmap - jsf

I am developing a solution to map the locations of a person in the field when submitting data via a mobile application.
All data submitted from the mobile application is send to a remote database from where I display all the data in tabular veiw using primefaces datatable object.
On row selection, a record of interest is selected, with accompanying triangulation coordianates submitted togetther with that particular record.
My challenge lies in changing the the focus of the map once I move from one record to the other, it is forcing me to refresh the entire xhtml page for the new coordinates selected to be located on the map and also with a marker attached.
Here is the code for the problem I got:
<ui:define name="main_content">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<h:form id="hsc">
<p:ajax event="rowSelect" update=":ewreg:display" oncomplete="helpDialog.show()" />
<p:dataTable id="tbl" value="#{merchadiseBeanList.merchadiseData}" var="merchadiseitem" scrollable="true" scrollHeight="400" resizableColumns="false" paginator="true" rows="20"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,50,100" selection="#{merchadiseBeanList.selectedmerchadise}" selectionMode="single">
<f:facet name="header">
Merchandise Report.
</f:facet>
<p:column sortBy="#{merchadiseitem.repMobile}" filterBy="#{merchadiseitem.repMobile}" headerText="Rep Mobile" style="width: 110px" >
<f:facet name="header">
<h:outputText value="Rep Mobile" />
</f:facet>
<h:outputText value="#{merchadiseitem.repMobile}" />
</p:column>
<p:column sortBy="#{merchadiseitem.dealerNo}" filterBy="#{merchadiseitem.dealerNo}" headerText="Dealer No" style="width: 100px" >
<f:facet name="header">
<h:outputText value="Dealer No" />
</f:facet>
<h:outputText value="#{merchadiseitem.dealerNo}" />
</p:column>
<p:column sortBy="#{merchadiseitem.weekNo}" filterBy="#{merchadiseitem.weekNo}" headerText="Week No" style="width: 110px" >
<f:facet name="header">
<h:outputText value="Week No" />
</f:facet>
<h:outputText value="#{merchadiseitem.weekNo}" />
</p:column>
<p:column sortBy="#{merchadiseitem.brandId}" filterBy="#{merchadiseitem.brandId}" headerText="Brand Id" style="width: 110px" >
<f:facet name="header">
<h:outputText value="Brand Id" />
</f:facet>
<h:outputText value="#{merchadiseitem.brandId}" />
</p:column>
<p:column sortBy="#{merchadiseitem.percentage}" filterBy="#{merchadiseitem.percentage}" headerText="Percentage" style="width: 110px" >
<f:facet name="header">
<h:outputText value="Percentage" />
</f:facet>
<h:outputText value="#{merchadiseitem.percentage}" />
</p:column>
<p:column sortBy="#{merchadiseitem.total}" filterBy="#{merchadiseitem.total}" headerText="Total" style="width: 110px" >
<f:facet name="header">
<h:outputText value="Total" />
</f:facet>
<h:outputText value="#{merchadiseitem.total}" />
</p:column>
<p:column sortBy="#{merchadiseitem.merchandisingDone}" filterBy="#{merchadiseitem.merchandisingDone}" headerText="MerchandisingDone" style="width: 110px" >
<f:facet name="header">
<h:outputText value="MerchandisingDone" />
</f:facet>
<h:outputText value="#{merchadiseitem.merchandisingDone}" />
</p:column>
<p:column sortBy="#{merchadiseitem.comments}" filterBy="#{merchadiseitem.comments}" headerText="Comments" style="width: 110px" >
<f:facet name="header">
<h:outputText value="Comments" />
</f:facet>
<h:outputText value="#{merchadiseitem.comments}" />
</p:column>
<p:column sortBy="#{merchadiseitem.regDate}" filterBy="#{merchadiseitem.regDate}" headerText="Reg Date" style="width: 110px" >
<f:facet name="header">
<h:outputText value="Reg Date" />
</f:facet>
<h:outputText value="#{merchadiseitem.regDate}" />
</p:column>
<f:facet name="footer">
<h:commandLink title="Export entire table Data to an Excel document." style="float: left">
<h:graphicImage library="images" name="excelAll.png" />
<p:spacer width="10" />
<p:dataExporter type="xls" target="tbl" fileName="Merchandising_Report_Full"
postProcessor="#{exporter.postProcessXLS}"/>
</h:commandLink>
<h:commandLink title="Export Filtered Page Data: Filter and Sort the
data and ensure that all the data is in one page by changing the number of records per page" style="float: left">
<h:graphicImage library="images" name="excel2.png" />
<p:dataExporter type="xls" target="tbl" fileName="Merchandising_Report_Filtered"
pageOnly="true" postProcessor="#{exporter.postProcessXLS}"/>
</h:commandLink>
<p:commandButton value="View" image="ui-icon ui-icon-document-b"
update="hsc:display" oncomplete="hscDialog.show()" />
<p:commandButton type="button" image="ui-icon ui-icon-pin-s" update="hsc:dlg"
value="Show Map" onclick="dlg.show()" oncomplete="dlg.show()"/>
</f:facet>
</p:dataTable>
<p:dialog widgetVar="dlg" width="625" height="400" modal="true"
onShow="mymap.checkResize()" dynamic="true">
<p:gmap center="#{merchadiseBeanList.selectedmerchadise.latitude},
#{merchadiseBeanList.selectedmerchadise.longitude}"
zoom="13" type="ROADMAP" draggable="true"
style="width:600px;height:400px" widgetVar="mymap"
model="#{merchadiseBeanList.simpleModel}" />
</p:dialog>
<p:dialog widgetVar="dllg" width="625" height="400" modal="true"
onShow="imap.checkResize()">
<p:gmap center="-1.29079655, 36.80600445" zoom="15" type="ROADMAP" draggable="true"
style="width:600px;height:400px" widgetVar="imap" />
</p:dialog>
<p:dialog header="Sales Record Detail" widgetVar="hscDialog" resizable="true"
width="240" showEffect="clip" hideEffect="fold" modal="true" >
<h:panelGrid id="display" columns="2" cellpadding="3" cellspacing="3" >
<f:facet name="header">
<h:graphicImage library="images" name="logo.png" />
</f:facet>
<h:outputText value="Id" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.ID}" />
<h:outputText value="Rep Mobile Number" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.repMobile}" />
<h:outputText value="Week Number" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.weekNo}" />
<h:outputText value="Dealer No" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.dealerNo}" />
<h:outputText value="Brand Id" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.brandId}" />
<h:outputText value="Percentage" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.percentage}" />
<h:outputText value="MerchandisingDone" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.merchandisingDone}" />
<h:outputText value="Comments" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.comments}" />
<h:outputText value="Reg Date" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.regDate}" />
<h:outputText value="MerchandisingDone" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.merchandisingDone}" />
<h:outputText value="Latitude" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.latitude}" />
<h:outputText value="Longititude" />
<h:outputText value="#{merchadiseBeanList.selectedmerchadise.longitude}" />
</h:panelGrid>
<p:commandButton type="button" image="ui-icon ui-icon-pin-s" update="hsc:dlg"
value="Show Map" onclick="dlg.show()" oncomplete="dlg.show()"/>
</p:dialog>
</h:form>
</ui:define>
here is the code which does the plotting of a marker to the respective latitude and longitude:
private MapModel simpleModel = new DefaultMapModel();
LatLng coord1;
double lati;
double longi;
public LatLng mapparams() {
try {
System.out.println("i am in smapparams method1");
try {
System.out.println("am checking fisrt");
lati = this.selectedmerchadise.Latitude;
longi = this.selectedmerchadise.Longitude;
System.out.println("am checking fisrt3");
} catch (NullPointerException np) {
System.out.println("NP is catched " + np);
} catch (Exception ex) {
System.out.println("this is bean ex" + ex);
System.out.println("coords at exception" + lati + " " + longi);
}
if (longi != 0 && lati != 0) {
System.out.println("i am in smapparams method3");
coord1 = new LatLng(lati, longi);
System.out.println("coords3: " + lati + " " + longi);
} else {
System.out.println("coords r null");
coord1 = new LatLng(0, 0);
}
} catch (Exception ex) {
System.out.println("this is the exceptions" + ex);
}
System.out.println("final cordianates" + coord1);
return coord1;
}
public MapModel getSimpleModel() {
this.mapparams();
System.out.println("i am in simple marker method");
simpleModel.addOverlay(new Marker(coord1, "Sales Rep Here"));
return simpleModel;
}

Related

Primefaces DataTable in Second tab not displaying data

I have a primefaces page containing 2 tabs. Both tabs has its own data Table. When finish querying data, dataTable in the first tab displays queried data fine but the second tab does not (please refer to the picture.)
here is my xhtml file code
<code>
<h:body>`enter code here`
<h:form id="myForm">
<p:menubar>
<p:menuitem value="Logout" icon="ui-icon-close" ajax="false" immediate="true" action="#{logoutManagedBean.logout}" />
</p:menubar>
<p:growl id="growlExtractTimesheet" sticky="false" showDetail="true" life="3000" />
<h:panelGrid style="margin-top:20px; border:none; border-style: none; border-width: 0px;" columns="7" >
<p:outputLabel for="fromDateCalendar" value=' From ' />
<p:calendar id='fromDateCalendar'
value="#{dataProcessingManagedBean.fromDate}"
binding="#{dataProcessingManagedBean.fromDateCalendar}"
pattern="dd-MMM-yyyy"
required="true"
requiredMessage="From Date Required"
valueChangeListener="#{dataProcessingManagedBean.determineExtractButtonDisability}" >
<p:ajax event="dateSelect" partialSubmit="fromDateCalendar" update="extractTimesheetButton" />
</p:calendar>
<p:outputLabel for="toDateCalendar" value='To ' />
<p:calendar id='toDateCalendar'
value="#{dataProcessingManagedBean.toDate}"
binding="#{dataProcessingManagedBean.toDateCalendar}"
pattern="dd-MMM-yyyy"
required="true"
requiredMessage="To Date Required"
valueChangeListener="#{dataProcessingManagedBean.determineExtractButtonDisability}" >
<p:ajax event="dateSelect" partialSubmit="toDateCalendar" update="extractTimesheetButton" />
</p:calendar>
<p:commandButton id='extractTimesheetButton'
actionListener ="#{dataProcessingManagedBean.extractTimesheetData}"
binding ="#{dataProcessingManagedBean.extractTimesheetCommandButton}"
update='myForm:tabview:detailDataTable myForm:tabview:summaryDataTable myForm:downloadExcelsButton'
ajax="true" icon="ui-icon-calculator" >
</p:commandButton>
<p:commandButton id="downloadExcelsButton" ajax="false" actionListener="#{dataProcessingManagedBean.downloadExcelFile}"
binding="#{dataProcessingManagedBean.downloadExcelsCommandButton}" icon="ui-icon-arrowthick-1-s" disabled="true"/>
</h:panelGrid>
<p:tabView id='tabview' cache="false">
<p:tab title="Detail Data" id='detailTab'>
<p:dataTable id='detailDataTable' var="detailData" paginatorPosition="top"
value="#{dataProcessingManagedBean.detailDatas}" paginator="true"
rows="100" rowsPerPageTemplate="100,200,500,1000, 2000, 5000, 10000, 20000, 50000" lazy='true'
currentPageReportTemplate="Showing {startRecord}-{endRecord} out of {totalRecords}"
paginatorTemplate="{CurrentPageReport} {RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "
scrollable="true" scrollHeight="350"
liveResize="true" draggableColumns="true" resizableColumns="true"
selectionMode="multiple" selection="#{dataProcessingManagedBean.selectedDetailDatas}" rowKey="#{detailData.id}" >
<p:column headerText="Employee ID" width="80">
<h:outputText value="#{detailData.employeeId}" />
</p:column>
<p:column headerText="Employee Name Lastname" width="200">
<h:outputText value="#{detailData.employeeName}" />
</p:column>
<p:column headerText="Cost Center" width="100">
<h:outputText value="#{detailData.costCenter}" />
</p:column>
<p:column headerText="WBS Code" width="100">
<h:outputText value="#{detailData.wbsCode}" />
</p:column>
<p:column headerText="WBS Name" width="300">
<h:outputText value="#{detailData.wbsName}" />
</p:column>
<p:column headerText="Project Code" width="100">
<h:outputText value="#{detailData.projectCode}" />
</p:column>
<p:column headerText="Project Name" width="300">
<h:outputText value="#{detailData.projectName}" />
</p:column>
<p:column headerText="Activity" width="300">
<h:outputText value="#{detailData.activity}" />
</p:column>
<p:column headerText="Task" width="300">
<h:outputText value="#{detailData.task}" />
</p:column>
<p:column headerText="Role" width="150">
<h:outputText value="#{detailData.role}" />
</p:column>
<p:column headerText="Timesheet Date" width="100">
<h:outputText value="#{detailData.timesheetDate}" />
</p:column>
<p:column headerText="Total Working Hours" width="150">
<h:outputText value="#{detailData.totalWorkingHours}" />
</p:column>
<p:column headerText="Utilized" width="50">
<h:outputText value="#{detailData.utilized}" />
</p:column>
<p:column headerText="Billable" width="50">
<h:outputText value="#{detailData.billable}" />
</p:column>
<p:column headerText="OT" width="50">
<h:outputText value="#{detailData.ot}" />
</p:column>
<p:column headerText="On Time" width="80">
<h:outputText value="#{detailData.onTime}" />
</p:column>
<p:column headerText="Status" width="80">
<h:outputText value="#{detailData.status}" />
</p:column>
<p:column headerText="Remark" width="500">
<h:outputText value="#{detailData.remark}" />
</p:column>
</p:dataTable>
</p:tab>
<p:tab title="Summary Data" id='summaryTab'>
<p:dataTable id='summaryDataTable' var="summaryData" paginatorPosition="top"
value="#{dataProcessingManagedBean.summaryDatas}" paginator="true"
rows="50" rowsPerPageTemplate="50, 100, 200" lazy='true'
currentPageReportTemplate="Showing {startRecord}-{endRecord} out of {totalRecords}"
paginatorTemplate="{CurrentPageReport} {RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "
scrollable="true" scrollHeight="350"
liveResize="true" draggableColumns="true" resizableColumns="true"
selectionMode="multiple" selection="#{dataProcessingManagedBean.selectedSummaryDatas}" rowKey="#{summaryData.id}" >
<p:column headerText="Employee ID" width="80">
<h:outputText value="#{summaryData.employeeId}" />
</p:column>
<p:column headerText="Employee Name Lastname" width="200">
<h:outputText value="#{summaryData.employeeName}" />
</p:column>
<p:column headerText="Normal Billable hour(s)" width="100">
<h:outputText value="#{summaryData.normalBillableHours}" />
</p:column>
<p:column headerText="Normal Non-Billable hour(s)" width="100">
<h:outputText value="#{summaryData.normalNonBillableHours}" />
</p:column>
<p:column headerText="Total Normal hours(s)" width="100">
<h:outputText value="#{summaryData.totalNormalHours}" />
</p:column>
<p:column headerText="OT Billable hour(s)" width="100">
<h:outputText value="#{summaryData.otBillableHours}" />
</p:column>
<p:column headerText="OT Non-Billable hour(s)" width="100">
<h:outputText value="#{summaryData.otNonBillableHours}" />
</p:column>
<p:column headerText="Total OT hour(s)" width="100">
<h:outputText value="#{summaryData.totalOTHours}" />
</p:column>
<p:column headerText="Total hour(s)" width="100">
<h:outputText value="#{summaryData.totalHours}" />
</p:column>
</p:dataTable>
</p:tab>
</p:tabView>
<p:ajaxStatus onstart="PF('statusDialog').show()" onsuccess="PF('statusDialog').hide()" onerror="PF('statusDialog').hide()"/>
<p:dialog id="waitDialog" widgetVar="statusDialog" modal="true" draggable="false" closable="false" resizable="false" showHeader="false">
<p:graphicImage value="/images/ajax_wait.gif" />
</p:dialog>
</h:form>
</h:body>
</html>
and this is the result.
if anyone has come across this problem and solved it. please help Thank you.
I think I have solved the problem by putting attribute dynamic='true' for tabView component.

javax.faces.FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled or define rowKey attribute

I saw this problem here many times but it doesn't help me.
I have the first dataTable with id:servers and I can do right click over a row and a contextMenu appears. I can click in Show Process and I get a second dataTable with id:processes.
But here is the problem, instead of showing the new dataTable I get,
javax.faces.FacesException: DataModel must implement
org.primefaces.model.SelectableDataModel when selection is enabled or
you need to define rowKey attribute
But I have defined rowKey in both dataTable
I have this code:
<h:form id="form" onkeypress="return event.keyCode != 13">
<!-- <p:messages id="msgs" /> -->
<p:growl id="msgs" showDetail="true" sticky="true" autoUpdate="true" />
<!-- Context menu for servers table. -->
<p:contextMenu for="servers">
<p:menuitem value="Show processes" update="form" icon="ui-icon-search" actionListener="#{homeBean.findLSRunningProcesses}" styleClass="homeIE"/>
</p:contextMenu>
<!-- Context menu for processes table. -->
<p:contextMenu for="processes">
<p:menuitem styleClass="homeIE" update="#form" value="Stop Process" icon="ui-icon-stop" oncomplete="stopDialog.show()"/>
</p:contextMenu>
<!-- Servers table. -->
<p:dataTable id="servers" var="server" value="#{homeBean.serverList}" paginator="true" rows="10"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15" widgetVar="serversTable" rowKey="#{server.adminFQDN}"
selection="#{homeBean.selectedLogicalServer}" selectionMode="single" emptyMessage="No servers found with given criteria">
<f:facet name="header">
<h:outputText value="Servers" />
</f:facet>
<p:column filterBy="#{server.ASSETID}" filterMatchMode="contains" sortBy="#{server.ASSETID}" headerText="ASSETID">
<h:outputText value="#{server.ASSETID}" />
</p:column>
<p:column filterBy="#{server.adminFQDN}" filterStyle="width:240px;" filterMatchMode="contains" sortBy="#{server.adminFQDN}" headerText="FQDN">
<h:outputText value="#{server.adminFQDN}" />
</p:column>
<p:column filterBy="#{server.adminIP}" filterMatchMode="contains" sortBy="#{server.adminIP}" headerText="Admin IP">
<h:outputText value="#{server.adminIP}" />
</p:column>
<p:column filterBy="#{server.delivery}" filterMatchMode="exact" sortBy="#{server.delivery}" headerText="Delivery">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('serversTable').filter()">
<f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="false" />
<f:selectItems label="#{homeBean.deliveries}" value="#{homeBean.deliveries}" />
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{server.delivery}" />
</p:column>
<p:column filterBy="#{server.environment}" filterMatchMode="exact" sortBy="#{server.environment}" headerText="Environment">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('serversTable').filter()">
<f:selectItem itemLabel="Select One" noSelectionOption="true" itemValue="#{null}"/>
<f:selectItems value="#{homeBean.environments}" />
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{server.environment}" />
</p:column>
<p:column filterBy="#{server.function}" filterMatchMode="exact" sortBy="#{server.function}" headerText="Function">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('serversTable').filter()">
<f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{homeBean.functions}" />
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{server.function}" />
</p:column>
<p:column filterBy="#{server.osVersion}" filterMatchMode="contains" sortBy="#{server.osVersion}" headerText="OS VERSION">
<h:outputText value="#{server.osVersion}" />
</p:column>
<p:column filterBy="#{server.os}" filterMatchMode="contains" sortBy="#{server.os}" headerText="OS">
<h:outputText value="#{server.os}" />
</p:column>
</p:dataTable>
<!-- Panel containing processes tables. -->
<p:panelGrid id="serverProcesses" styleClass="group-user-selection-table" rendered="#{homeBean.showSelectionPanel}">
<f:facet name="header">
<p:row>
<p:column>
<h:outputText value="#{homeBean.selectedLogicalServer.adminFQDN}" />
</p:column>
</p:row>
</f:facet>
<p:row>
<!--Processes table. -->
<p:column>
<p:dataTable id="processes" var="process" value="#{homeBean.processesList}" filteredValue="#{homeBean.filteredProcesses}"
selection="#{homeBean.selectedProcesses}" paginator="true" rows="15" rowKey="#{process.owner}"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="15,20,25,30" selectionMode="single" emptyMessage="No processses found with given criteria">
<f:facet name="header">
<h:outputText value="Processes" />
</f:facet>
<p:column name="owner" filterBy="#{process.owner}" filterMatchMode="contains" sortBy="#{process.owner}" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'DESCRIPTION' : 'OWNER'}">
<h:outputText value="#{process.owner}" />
</p:column>
<p:column name="pid" filterBy="#{process.pid}" filterMatchMode="exact" sortBy="#{process.owner}" headerText="PID">
<h:outputText value="#{process.pid}" />
</p:column>
<p:column name="ppid" filterBy="#{process.ppid}" filterMatchMode="exact" sortBy="#{process.ppid}" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'TYPE' : 'PPID'}">
<h:outputText value="#{process.ppid}" />
</p:column>
<p:column name="c" filterBy="#{process.c}" filterMatchMode="exact" sortBy="#{process.c}" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'STATE' : 'C'}">
<h:outputText value="#{process.c}" />
</p:column>
<p:column name="stime" filterBy="#{process.stime}" filterMatchMode="contains" sortBy="#{process.stime}" headerText="STIME" rendered="#{!(homeBean.selectedLogicalServer.os eq 'Windows')}">
<h:outputText value="#{process.stime}" />
</p:column>
<p:column name="tty" filterBy="#{process.tty}" filterMatchMode="contains" sortBy="#{process.tty}" headerText="TTY" rendered="#{!(homeBean.selectedLogicalServer.os eq 'Windows')}">
<h:outputText value="#{process.tty}" />
</p:column>
<p:column name="time" filterBy="#{process.time}" filterMatchMode="contains" sortBy="#{process.time}" headerText="TIME" rendered="#{!(homeBean.selectedLogicalServer.os eq 'Windows')}">
<h:outputText value="#{process.time}" />
</p:column>
<p:column name="cmd" filterBy="#{process.cmd}" filterMatchMode="contains" sortBy="#{process.cmd}" headerText="#{homeBean.selectedLogicalServer.os eq 'Windows' ? 'NAME' : 'CMD'}">
<h:outputText value="#{process.cmd}" />
</p:column>
</p:dataTable>
</p:column>
</p:row>
</p:panelGrid>
<p:dialog header="Stop Process" widgetVar="stopDialog" minHeight="40" styleClass="dialogPosition">
<h:outputText value="You are going to stop the process "/>
<h:outputText value="#{homeBean.selectedProcesses.cmd}"/>
<h:outputText value="with PID"/>
<h:outputText value="#{homeBean.selectedProcesses.pid}"/>
<br /><br /><br /><br />
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" style="float:left" onclick="stopDialog2.show();stopDialog.hide();" actionListener="#{homeBean.attrListener}">
<f:attribute name="processPID" value="#{process.pid}" />
</p:commandButton>
<p:commandButton value="NO" onclick="stopDialog.hide()" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" style="float:right"/>
</p:dialog>
<p:dialog header="Stop Process" widgetVar="stopDialog2" minHeight="40" styleClass="dialogPosition">
<h:outputText value="You are going to send an email to:"/>
<br />
<h:outputText value="#{homeBean.email}"/>
<br /><br /><br />
<p:commandLink value="Yes" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" style="float:left" update="form" action="#{homeBean.stopProcess}" oncomplete="stopDialog2.hide();"/>
<p:commandButton value="NO" onclick="stopDialog2.hide()" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" style="float:right"/>
</p:dialog>
</h:form>
FacesException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled
this solution works to me.
Especially this answer https://stackoverflow.com/a/10527008/5250930
The table must implement the SelectableDataModel

Primefaces Datatable row selection inside dialog

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>

Issue in displaying p:messages for converterMessage

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" />

DataTable PrimeFaces

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.

Resources