Primefaces GMap infoWindow for polygon, polyline - jsf

I'm use Primefaces and trying to create infoWindow with different content for different types of overlays.
Map.java
public void onMarkerSelect(OverlaySelectEvent event) {
if (event.getOverlay() instanceof Marker) {
selectedOverlay = "marker";
selMarkerSite = (Site) event.getOverlay().getData();
selMarkerSiteNetworkElements = new ArrayList<NetworkElement>();
List<NetworkElement> neList = selMarkerSite.getNetworkElements();
if (!neList.isEmpty()) {
for (NetworkElement ne : neList) {
if (!(ne.getNeFunc().getName().equals("CELL2G") || ne.getNeFunc().getName().equals("CELL3G") || (ne.getNeStatus() != null && ne.getNeStatus().getId().equals(new BigDecimal(26))))
&& filter.getRadioType().contains(ne.getNeFunc().getGeneration())) {
selMarkerSiteNetworkElements.add(ne);
}
}
}
balloonText = HtmlFormatter.siteBalloonInfoFormater(selMarkerSite);
}
if (event.getOverlay() instanceof Polygon) {
selectedOverlay = "polygon";
// my code
}
}
jsf
<p:gmap center="#{map.center}"
zoom="#{map.zoom}" fitBounds="false" type="HYBRID" id="mainMapId"
style="width:100%; height:100%" widgetVar="mainMap"
model="#{map.mapModel}">
<p:ajax event="overlaySelect" listener="#{map.onMarkerSelect}" />
<p:ajax event="stateChange" listener="#{map.onStateChange}"
global="false"/>
/>
<p:gmapInfoWindow>
<p:panel rendered="#{map.selectedOverlay=='marker'}">
<h:panelGrid columns="2" width="580">
<p:column style="width:200px">
<p:outputPanel style="display:block; width:180px">
<h:outputText value="#{map.balloonText}" escape="false" />
<h:panelGrid columns="2" style="width:180px">
<p:commandLink id="getAlarmsForSite"
actionListener="#{map.getSiteAlarms}">
<h:outputText value="Alarms" />
</p:commandLink>
<p:commandLink id="editSiteOnMapBtn"
actionListener="#{map.editSite()}">
<f:setPropertyActionListener
target="#{createOrUpdateSiteDialogController.componentsToUpdateOnNetworkElementSelectListener}"
value=":updateOrCreateNetworkElementDialogId" />
<h:outputText value="Edit this Site" />
</p:commandLink>
</h:panelGrid>
</p:outputPanel>
</p:column>
<p:column style="width:380px">
<p:tabView id="tabView" var="NE"
value="#{map.selMarkerSiteNetworkElements}"
rendered="#{map.selMarkerSiteNetworkElements.size()>0}">
<p:tab id="neTab" title="#{NE.name}"
titleStyleClass="tabSev#{NE.minSeverity}">
<h:panelGrid columns="2" style="width: 420px;">
<h:panelGrid columns="2" style="width: 230px;">
<h:outputText value="MO: " style="font-weight: bold" />
<h:outputText value="#{NE.managingElement.name}" />
<h:outputText value="DN: " style="font-weight: bold" />
<h:outputText value="#{NE.dn}" />
<h:outputText value="TYPE: " style="font-weight: bold" />
<h:outputText value="#{NE.neFunc.name}" />
<h:outputText value="STATUS: " style="font-weight: bold" />
<h:outputText value="#{NE.neStatus.nameEng}" />
<h:outputText value="Customer " style="font-weight: bold" />
<p:graphicImage width="18" cache="true"
title="#{NE.nms.customer.nameEng}"
url="#{NE.nms.customer.labelSmall}"
style="padding-top: 2px;" />
<p:commandLink id="getAlarmsForNE"
actionListener="#{map.getBsAlarms(NE)}">
<h:outputText
value="Alarms (#{NE.sizeAlarmsWithChildrenNE})"
styleClass="sev#{NE.minSeverity}" />
</p:commandLink>
<p:commandLink id="editNeOnMapBtn"
actionListener="#{map.editNe(NE)}">
<h:outputText value="Edit this NE" />
<f:setPropertyActionListener
target="#{createOrupdateNetworkElementController.componentsToUpdateOnSiteViweActionListener}"
value=":updateOrCreateSiteDialogId" />
</p:commandLink>
</h:panelGrid>
<p:dataList value="#{NE.networkElements}" var="NEc"
rendered="#{NE.networkElements.size()>0}">
<h:outputText
value="name: #{NEc.name}; azimuth: #{NEc.azimuth!=null ? NEc.azimuth : '-' }" />
</p:dataList>
</h:panelGrid>
</p:tab>
</p:tabView>
</p:column>
</h:panelGrid>
</p:panel>
<p:panel rendered="#{map.selectedOverlay=='polygon'}">
//
</p:panel>
</p:gmapInfoWindow>
</p:gmap>
The troubleis that the infoWindow is not showed when i click on any overlay except marker.
I want use jsf code in infoWindow.
How i can show infoWindow for another overlays?

Related

Multiple JSF progressBar inside same component

I´m trying to show the progress of several batch processes using a progressbar for each one of them. The problem is that only one progressbar is been sent to server side (the last one). Here is the code...
I made a RequestScoped Named bean for the progress beacause I read that for multiple progressBar it is needed a bean instance for each one of the progressbars, but that do not resolve my problem.
I'm using Primefaces 6.1 with JSF 2.2.
Any ideas? Thanks!
<h:form id="formExecutions">
<p:dataGrid id="jobs" value="#{jobExecutorController.jobExecutions}" var="job" rows="5" paginator="true" emptyMessage="#{MessageResources['text.noRecordsFound']}"
paginatorPosition="bottom" columns="1" layout="grid">
<f:facet name="header">
#{MessageResources['text.batchProcesses']}
</f:facet>
<p:outputPanel layout="block" >
<p:panelGrid cellpadding="5" styleClass="vf-panelGrid">
<p:row style="width:100%">
<p:column>
<p:outputLabel for="executionId" value="#{MessageResources['text.executionId']}:" style="font-weight:bold"/>
</p:column>
<p:column>
<h:outputText id="executionId" value="#{job.executionId}" />
</p:column>
<p:column>
<p:outputLabel for="name" value="#{MessageResources['text.name']}:" style="font-weight:bold"/>
</p:column>
<p:column style="width:10%">
<h:outputText id="name" value="#{job.name}"/>
</p:column>
<p:column style="width:50%" rowspan="2">
<p:progressBar id="progressBar" widgetVar="progressBar" ajax="true" value="#{progressController.progress(job)}" labelTemplate="{value}%" styleClass="animated" style="height: 20px; line-height: 20px;" global="false" interval="3000">
<p:ajax event="complete" listener="#{progressController.onCompleteJob(job)}" update="messageDisplay" process="#this"/>
<p:ajax update="jobInfo"/>
</p:progressBar>
</p:column>
<p:column style="width:4%" />
<p:column rowspan="2" style="text-align:right">
<p:commandButton id="restart" onclick="PF('confirmRestartJob').show()" styleClass="coloured-icons-batch restart-image-icon blink"
disabled="#{not job.enableRestartAbandon}" immediate="true" title="">
<f:setPropertyActionListener value="#{job.executionId}" target="#{jobExecutorController.executionIdSelected}" />
<f:setPropertyActionListener value="#{job.name}" target="#{jobExecutorController.executionNameSelected}" />
</p:commandButton>
<p:tooltip for="restart" value="#{MessageResources['text.restartJobExecution']}" position="top"></p:tooltip>
<p:spacer width="10" />
<p:commandButton id="stop" onclick="PF('confirmStopJob').show()" styleClass="coloured-icons-batch stop-image-icon blink"
disabled="#{not job.enableStop}" immediate="true" title="">
<f:setPropertyActionListener value="#{job.executionId}" target="#{jobExecutorController.executionIdSelected}" />
<f:setPropertyActionListener value="#{job.name}" target="#{jobExecutorController.executionNameSelected}" />
</p:commandButton>
<p:tooltip for="stop" value="#{MessageResources['text.stopJobExecution']}" position="top"></p:tooltip>
<p:spacer width="10" />
<p:commandButton id="abandon" onclick="PF('confirmAbandonJob').show()" styleClass="coloured-icons-batch abandon-image-icon blink"
disabled="#{not job.enableRestartAbandon}" immediate="true" title="">
<f:setPropertyActionListener value="#{job.executionId}" target="#{jobExecutorController.executionIdSelected}" />
<f:setPropertyActionListener value="#{job.name}" target="#{jobExecutorController.executionNameSelected}" />
</p:commandButton>
<p:tooltip for="abandon" value="#{MessageResources['text.abandonJobExecution']}" position="top"></p:tooltip>
</p:column>
</p:row>
</p:panelGrid>
<h:panelGroup id="jobInfo" >
<p:panelGrid columns="4" cellpadding="5" styleClass="vf-panelGrid">
<p:outputLabel for="creationDate" value="#{MessageResources['text.creationDate']}:" style="font-weight:bold"/>
<h:outputText id="creationDate" value="#{job.formattedDate(job.createdDate)}" />
<p:outputLabel for="startDate" value="#{MessageResources['text.dateStartProcess']}:" style="font-weight:bold"/>
<h:outputText id="startDate" value="#{job.formattedDate(job.startedDate)}" />
<p:outputLabel for="lastUpdate" value="#{MessageResources['text.lastUpdate']}:" style="font-weight:bold"/>
<h:outputText id="lastUpdate" value="#{job.formattedDate(job.lastUpdate)}" />
<p:outputLabel for="toProcess" value="#{MessageResources['text.itemsToProcess']}:" style="font-weight:bold"/>
<h:outputText id="toProcess" value="#{job.itemsToProcess}" />
<p:outputLabel for="endDate" value="#{MessageResources['text.ended']}:" style="font-weight:bold"/>
<h:outputText id="endDate" value="#{job.formattedDate(job.endedDate)}" />
<p:outputLabel for="processed" value="#{MessageResources['text.itemsProcessed']}:" style="font-weight:bold"/>
<h:outputText id="processed" value="#{job.itemsProcessed}" />
<p:outputLabel for="status" value="#{MessageResources['text.state']}:" style="font-weight:bold"/>
<h:outputText id="status" value="#{job.status}" />
</p:panelGrid>
</h:panelGroup>
</p:outputPanel>
<p:spacer width="5"/>
<p:separator />
<p:spacer width="5"/>
</p:dataGrid>
My RequestScope backing bean...
#Named("progressController")
#RequestScoped
public class ProgressController
{
#EJB
private EJBJobRepositoryLocal ejbJobRepository;
public Long progress(DMJob jobExecution) throws VfCmsSqlException
{
if (jobExecution.getStatus().equals(BatchStatus.STARTED.name())) {
jobExecution.setProgress(ejbJobRepository.getJobProgress(jobExecution.getExecutionId()));
}
PrimeUtil.get().update("formExecutions:jobInfo");
return jobExecution.getProgress();
}
public void onCompleteJob(DMJob jobExecution)
{
Object[] parameters = {jobExecution.getName(), jobExecution.getExecutionId()};
Messages.displayInfoMessage("text.jobComplete", parameters);
}
}
Ok. The problem is that the PrimeFaces().start() method is not been executed over all the components generated by JSF. So, what I did is a javascript function which is executed when the page is fully loaded. In my case the components that I needed to initialize are several progress bar. My components are inside a data scroller which is inside a form, that's why I concat those id's. The 'i' is the index of each of the rendered progress bar in the page.
<script type="text/javascript">
$(window).load(function() {
startProgress();
});
function startProgress(){
var pid = document.getElementsByClassName('ui-progressbar');
var pidLength = pid.length;
for (var i = 0; i < pidLength; i++) {
var id = "formExecutions:scroller:".concat(i).concat(":progressBar");
PrimeFaces.getWidgetById(id).start();
}
}
</script>
And that was all!

Refresh dialog in primefaces

I am building an application where it is necessary to register a user, more precisely a picture for a user besides his name, username and some other information, when the registration window is show, a default user image is load, then when they select a new image the default image dissapear and the selected one is displayed on the window, and a new button is displayed as well, this button allows the user to remove the selected picture, so the default image must be display again, but I still can't display again the default picture in case de button is clicked to return to the default picture and remove the selected one
View where users are listed and the modal window is displayed
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="/sesionAdmin/_admintmp.xhtml">
<ui:define name="body">
<h:head>
<h:outputScript library="js" name ="Calendario.js"/>
</h:head>
<h:body>
<h:form>
<p:commandButton id="createButton" value="Registrar usuario"
onclick="PF('UsuarioCreateDialog').show()">
</p:commandButton>
</h:form>
<p:separator/>
<h:form id="UsuarioListForm">
<p:panelGrid columns="2" styleClass="panelgrid">
<p:outputLabel style="font-weight: bold;" value="Buscar usuario:" />
<p:inputText placeholder="Digite nombres, apellidos, nombre de usuario o email"
style="width: 350px;" value="#{usuarioController.datoBusqueda}" >
<p:ajax event="keyup" update="datalist" listener="#{usuarioController.buscarUsuario()}" />
</p:inputText>
</p:panelGrid>
<p:dataTable id="datalist" value="#{usuarioController.items}" var="item"
paginator="true" widgetVar="tablaUsuarios"
rows="10"
rowsPerPageTemplate="10,20"
>
<f:facet name="header">
</f:facet>
<p:column >
<f:facet name="header">
<h:outputText value="Nombres"/>
</f:facet>
<h:outputText value="#{item.usunombres}"/>
</p:column>
<p:column >
<f:facet name="header">
<h:outputText value="Apellidos"/>
</f:facet>
<h:outputText value="#{item.usuapellidos}"/>
</p:column>
<p:column >
<f:facet name="header">
<h:outputText value="Nombre de usuario"/>
</f:facet>
<h:outputText value="#{item.usunombreusuario}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Email"/>
</f:facet>
<h:outputText value="#{item.usuemail}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Cargo"/>
</f:facet>
<h:outputText value="#{item.carid.carnombre}"/>
</p:column>
<p:column width="70" style="text-align: center">
<f:facet name="header">
<h:outputText value="Foto" />
</f:facet>
<p:graphicImage id="imgUsuario" value="#{usuarioController.imagenFlujo}" width="50" height="50" >
<f:param name="id" value="#{item.usuid}" />
</p:graphicImage>
</p:column>
<p:column style="width: 90px">
<f:facet name="header">
<p:outputLabel value="Acciones"/>
</f:facet>
<p:commandButton id="viewButton" icon="ui-icon-search" action="#{usuarioController.seleccionarUsuarioVer(item)}" update=":UsuarioViewForm, :formfotoView" oncomplete="PF('UsuarioViewDialog').show()" />
<p:commandButton id="editButton" icon="ui-icon-pencil" action="#{usuarioController.seleccionarUsuarioEditar(item)}" update=":UsuarioEditForm, :formEditarfoto" oncomplete="PF('UsuarioEditDialog').show()" />
</p:column>
</p:dataTable>
</h:form>
<ui:include src="RegistrarUsuario.xhtml"/>
<ui:include src="EditarUsuario.xhtml"/>
<ui:include src="VerInfoUsuario.xhtml"/>
<p:dialog header="Información" modal="true" position="center" widgetVar="mensajeRegistroExitoso" closable="false">
<p:messages style="font-size: 15px;" showDetail="true" autoUpdate="true"/>
<h:form>
<p:commandButton value="Aceptar" style="font-weight: normal;"
onclick="PF('mensajeRegistroExitoso').hide()"/>
</h:form>
</p:dialog>
</h:body>
</ui:define>
</ui:composition>
</html>
User dialog window
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition>
<p:dialog id="UsuarioCreateDlg" widgetVar="UsuarioCreateDialog" modal="true" resizable="false"
appendTo="#(body)" header="Registrar usuario">
<h:outputStylesheet name="css/appearUploadFile.css" />
<p:ajax event="close" listener="#{usuarioController.cancelarRegistroUsuario()}"/>
<p:outputLabel style="float: right;" value="  Campos obligatorios" />
<p:outputLabel style="float: right; font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
<br/>
<!--h:form id="formfoto" enctype="multipart/form-data"-->
<center>
<p:outputLabel style="font-weight:bold;" value="Foto de perfil" />
</center>
<center>
<br/>
<p:graphicImage rendered="#{usuarioController.miImagen ==null}"
style="height:100px; width:100px;"
value="#{usuarioController.imagenDefecto}"/>
<p:graphicImage rendered="#{usuarioController.miImagen !=null}"
id="img"
style="height:100px; width:100px;"
value="#{usuarioController.miImagen}"
cache="false"/>
<p:fileUpload mode="advanced" auto="true" fileUploadListener="#{usuarioController.convertirImagenABytes}"
allowTypes="/(\.|\/)(jpe?g|png)$/" sizeLimit="10000000" invalidFileMessage="El archivo no está en el formato válido"
required="true"
update="#form" multiple="false" label="Subir imagen">
</p:fileUpload>
<h:commandLink rendered="#{usuarioController.miImagen !=null}"
value="Imagen por defecto"
actionListener="#{usuarioController.establecerFotoPorDefecto()}"
>
<f:ajax execute="#all" render="#form"/>
<p:ajax update="UsuarioCreateDlg"/>
</h:commandLink>
</center>
<br/>
<!--/h:form-->
<h:form id="UsuarioCreateForm">
<p:panelGrid styleClass="panelgrid" id="panel2">
<p:row>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Nombres:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:inputText id="usunombres" value="#{usuarioController.selected.usunombres}"
title="#{bundleAdmin.CreateUsuarioTitle_usunombres}" required="true"
requiredMessage="Campo obligatorio">
<f:validator validatorId="ValidarCampo75Caracteres"/>
<p:ajax event="keyup" update="msgCaracteresNombre"/>
</p:inputText>
</p:column>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Apellidos:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:inputText id="usuapellidos" value="#{usuarioController.selected.usuapellidos}"
title="#{bundleAdmin.CreateUsuarioTitle_usuapellidos}" required="true"
requiredMessage="Campo obligatorio">
<f:validator validatorId="ValidarCampo75Caracteres"/>
<p:ajax event="keyup" update="msgCaracteresApellido"/>
</p:inputText>
</p:column>
</p:row>
<p:row>
<p:column>
</p:column>
<p:column>
<p:message id="msgCaracteresNombre" for="usunombres"/>
</p:column>
<p:column>
</p:column>
<p:column>
<p:message id="msgCaracteresApellido" for="usuapellidos"/>
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Genero:" />
</p:column>
<p:column>
<p:selectOneRadio value="#{usuarioController.selected.usugenero}">
<f:selectItem itemLabel="Masculino" itemValue="M" />
<f:selectItem itemLabel="Femenino" itemValue="F" />
</p:selectOneRadio>
</p:column>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Fecha de nacimiento:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:calendar id="usufechanacimiento"
placeholder="dd/mm/aaaa" pattern="dd/MM/yyyy"
value="#{usuarioController.selected.usufechanacimiento}"
title="#{bundleAdmin.EditUsuarioTitle_usufechanacimiento}"
required="true"
readonlyInput="true"
requiredMessage="Campo obligatorio"
showOn="button"
navigator = "true"
locale="es"
maxdate="#{usuarioController.fechaHoy}">
<p:ajax event="keyup" update="msgUsuFechaNacimiento"/>
<p:ajax event="dateSelect" update="msgUsuFechaNacimiento"/> </p:calendar>
</p:column>
</p:row>
<p:row>
<p:column>
</p:column>
<p:column>
</p:column>
<p:column>
</p:column>
<p:column>
<p:message id="msgUsuFechaNacimiento" for="usufechanacimiento"/>
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Email:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:inputText id="usuemail" value="#{usuarioController.selected.usuemail}"
title="#{bundleAdmin.CreateUsuarioTitle_usuemail}"
required="true" requiredMessage="Campo obligatorio">
<f:validator validatorId="ValidarCampoCorreoElectronico"/>
<p:ajax event="keyup" update="msgCaracteresEMail"/>
</p:inputText>
</p:column>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Cargo:" />
</p:column>
<p:column>
<p:selectOneMenu id="carid" value="#{usuarioController.cargo}" >
<f:selectItems value="#{cargoController.itemsAvailableSelectOne}"
var="caridItem"
itemValue="#{caridItem}"
itemLabel="#{caridItem.carnombre}"
/>
<f:validator validatorId="ValidarCamposSeleccionar"/>
</p:selectOneMenu>
</p:column>
</p:row>
<p:row>
<p:column>
</p:column>
<p:column>
<p:message id="msgCaracteresEMail" for="usuemail"/>
</p:column>
<p:column>
</p:column>
<p:column>
<p:message for="carid"/>
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Tipo de usuario:" />
</p:column>
<p:column>
<p:selectOneMenu id="grupoId" value="#{usuarioController.grupo.gruid}" >
<p:ajax event="change" update="grupoId"/>
<f:selectItems value="#{grupoController.itemsAvailableSelectOne}"
var="grupo"
itemValue="#{grupo.gruid}"
itemLabel="#{grupo.grudescripcion}"
>
</f:selectItems>
<f:validator validatorId="ValidarCamposSeleccionar"/>
</p:selectOneMenu>
</p:column>
</p:row>
<p:row>
<p:column>
</p:column>
<p:column>
<p:message for="grupoId"/>
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Nombre de usuario:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:inputText id="usunombreusuario" value="#{usuarioController.selected.usunombreusuario}"
title="#{bundleAdmin.CreateUsuarioTitle_usunombreusuario}" required="true"
requiredMessage="Campo obligatorio">
<f:validator validatorId="ValidarCampoNombreUsuario"/>
<p:ajax event="keyup" update="msgCaracteresNombreUsuario"/>
</p:inputText>
</p:column>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Contraseña:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:password id="usucontrasena" value="#{usuarioController.selected.usucontrasena}"
title="#{bundleAdmin.CreateUsuarioTitle_usucontrasena}"
required="true" requiredMessage="Campo obligatorio"/>
</p:column>
</p:row>
<p:row>
<p:column>
</p:column>
<p:column>
<p:message id="msgCaracteresNombreUsuario" for="usunombreusuario"/>
</p:column>
<p:column>
</p:column>
<p:column>
<p:message for="usucontrasena"/>
</p:column>
</p:row>
</p:panelGrid>
<p:separator/>
<center>
<p:commandButton action="#{usuarioController.registrarUsuario()}"
value="Registrar" update=":UsuarioListForm:datalist, panel2"
/>
</center>
</h:form>
</p:dialog>
</ui:composition>
</html>
User controller
public class UsuarioController implements Serializable {
#EJB
private com.unicauca.coordinacionpis.sessionbean.UsuarioFacade ejbUsuario;
#EJB
private UsuariogrupoFacade ejbUsuarioGrupo;
private List<Usuario> items = null;
private Cargo cargo;
private Grupo grupo;
private List<Usuario> filtroBusqueda;
private boolean campoFoto;
private boolean campoContrasena;
private String contrasena;
private String datoBusqueda;
private Usuario usuario;
private UploadedFile file;
private SimpleDateFormat formatoFecha;
private byte[] imagen;
private DefaultStreamedContent miImagen;
private UploadedFile uploadedFile;
public StreamedContent getImagenDefecto(){
return Utilidades.getImagenPorDefecto("foto");
}
public StreamedContent getImagen(Usuario usuario) {
RequestContext requestContext = RequestContext.getCurrentInstance();
FacesContext context = FacesContext.getCurrentInstance();
String id = context.getExternalContext().getRequestParameterMap().get("idUsu");
if (usuario.getUsufoto() == null) {
return Utilidades.getImagenPorDefecto("foto");
} else {
return new DefaultStreamedContent(new ByteArrayInputStream(usuario.getUsufoto()));
}
}
public void establecerFotoPorDefecto()
{
System.out.println("Hallo");
this.miImagen = null;
RequestContext requestContext = RequestContext.getCurrentInstance();
//requestContext.execute("PF('UsuarioCreateDialog').hide()");
//requestContext.execute("PF('UsuarioCreateDialog').show()");
//this.imagenPorDefecto();
}
public DefaultStreamedContent getMiImagen() {
convertirBytesAImagen();
/*if(miImagen==null)
miImagen = Utilidades.getImagenPorDefecto("foto");*/
return miImagen;
}
public void convertirBytesAImagen()
{
if(imagen != null)
{
InputStream is = new ByteArrayInputStream((byte[]) imagen);
miImagen = new DefaultStreamedContent(is, "image/png");
}
}
}
The method I am calling to set the default picture is establecerFotoPorDefecto()

Primefaces pagination (lazydatamodel) load method

I´ve a couple issues with a page I´m working on.
I have two sections: frmConf and frmData.
The first one has some parameters I use for searching purposes.
The second one has a DataTable defined as lazy and algo I have it´s corresponding backing wich extends LazyDatamodel.
In the mentioned DataTable in section 2 I have a column with a commandLink which creates a PDF document for the selected row in the DataTable.
The problem I´m facing is it works just fine the first time I load the page:
It calls the load (#override) method from LazyDatamodel and presents the first 10 records of the query results from the DB.
Then, when I click on the commandLink column it shows the "save as" dialog for the corresponding PDF just fine and I can proceed to download the file.
But then, for some reason wich I don´t yet understand, if I click another row´s PDF commandLink it goes and calls the referred load method a requeries the DB assuming I´m trying to do some pagination and it doesn´t even generate the required PDF.
What I´m trying to achieve is just load the page for every pagination case and not for any unrelated event like clicking the PDF button for the selected row.
Why is it reloading and requerying (even though it shows the same results as the indexes for pagination haven´t change) the entire page content after the first (correct)PDF generation?
It´s my guess something happens after the first PDF generation (it leaves the page with some "reload required" state.
I´m leaving the markup from the page as well as the corresponding backing bean PDF generation method.
Please I´d really appreciate if someone could help me with this.
Thanks!
JSF markup:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="/templates/cimaTemplate.xhtml">
<ui:define name="tituloPagina">
<h:outputText value="Consulta Documentos" />
</ui:define>
<ui:define name="tituloFormulario">
<h:outputText value="Documentos" styleClass="titulo" />
</ui:define>
<ui:define name="contenido">
<style>
.style1 {
text-align: right;
}
.style3 {
text-align: left;
}
.style2 {
text-align: center;
background: blue;
color: white;
font-weight: bold;
}
.colEstadoStyle {
td:nth-child(1)
width: 20px;
}
.imageClass {
display: block;
background-image: url('/imagenes/pdf.png') no-repeat 100%;
}
</style>
<h:form id="frmConf" styleClass="form" >
<p:growl id="growl" showDetail="true" sticky="true" />
<p:panel id="datosEmisorPanel">
<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
<p:panelGrid style="margin: 0 auto;" id="panelG">
<p:row>
<p:column>
<p:panelGrid>
<p:row>
<p:column style="text-align: center;" colspan="2">
<strong><h:outputLabel styleClass="label" value="Seleccionar Archivo" /></strong>
<p:selectManyCheckbox style="text-align: center;"
value="#{cabDocumentoMB.selectedOptionsEmail}">
<f:selectItem itemValue="PDF" itemLabel="PDF" />
<f:selectItem itemValue="XML" itemLabel="XML" />
</p:selectManyCheckbox>
</p:column>
</p:row> <p:row>
<p:column colspan="2">
<strong><h:outputLabel styleClass="label"
value="E-Mails" /></strong>
<br></br>
<h:inputTextarea value="#{cabDocumentoMB.correos}"
cols="40" />
<br></br>
</p:column>
</p:row> <p:row>
<p:column colspan="2">
<strong><h:outputLabel styleClass="style1"
value="Formato: email1#email.com,email2#email.com" /></strong>
</p:column>
</p:row> <p:row>
<p:column rowspan="2">
<p:commandButton icon="ui-icon-mail-closed"
value=" Envio normal" id="bto_enviarEmail"
oncomplete="bloquearPagina.hide()"
onstart="bloquearPagina.show()"
action="#{cabDocumentoMB.EnviarCorreos('Normal')}"
update="growl">
</p:commandButton>
<p:blockUI block="frmConf" widgetVar="bloquearPagina">
Enviando correo...<br />
<p:graphicImage value="/imagenes/ajax-loader.gif" />
</p:blockUI>
<p:blockUI block="frmConf" widgetVar="bloquearReproceso">
Reprocesando...<br />
<p:graphicImage value="/imagenes/ajax-loader.gif" />
</p:blockUI>
</p:column>
<p:column rowspan="2">
<p:commandButton value=" Envio ZIP" icon="ui-icon-tag"
action="#{cabDocumentoMB.EnviarCorreos('ZIP')}"
oncomplete="bloquearPagina.hide()"
onstart="bloquearPagina.show()" update="growl">
</p:commandButton>
<br />
</p:column>
</p:row> </p:panelGrid>
</p:column>
<p:column colspan="0">
<p:panelGrid> <p:row>
<p:column colspan="1" styleClass="style1">
<strong><h:outputLabel styleClass="label" size="30"
value="Cédula/RUC/Pasaporte" /></strong>
</p:column>
<p:column colspan="1" styleClass="style3">
<h:inputText styleClass="text" style="font-weight: bold;"
value="#{cabDocumentoMB.ruc}" />
</p:column>
</p:row> <p:row>
<p:column colspan="1" styleClass="style1">
<strong><h:outputLabel styleClass="label" size="30"
value="Nombres:" /></strong>
</p:column>
<p:column colspan="1" styleClass="style3">
<h:inputText styleClass="text" style="font-weight: bold;"
value="#{cabDocumentoMB.razonSocial}" />
</p:column>
</p:row> <p:row>
<p:column styleClass="style1">
<strong><h:outputLabel styleClass="label"
value="Número del Documento:" /></strong>
</p:column>
<p:column styleClass="style3">
<h:inputText value="#{cabDocumentoMB.numDocumento}"
size="30" title="Número del Documento" placeHolder="TBD"/>
</p:column>
</p:row> <p:row>
<p:column styleClass="style1">
<strong><h:outputLabel styleClass="label"
value="Tipo de Documento:" /></strong>
</p:column>
<p:column styleClass="style3">
<p:selectOneMenu
value="#{cabDocumentoMB.seleccionTipo}">
<f:selectItems value="#{cabDocumentoMB.tipo}" />
</p:selectOneMenu>
</p:column>
</p:row> <p:row>
<p:column styleClass="style1">
<strong><h:outputLabel styleClass="label"
value="Estados:" /></strong>
</p:column>
<p:column styleClass="style3">
<p:selectOneMenu
value="#{cabDocumentoMB.seleccionTipoEstado}">
<f:selectItems value="#{cabDocumentoMB.tipoEstados}" />
</p:selectOneMenu>
</p:column>
</p:row> <p:row>
<p:column>
<strong><h:outputLabel styleClass="label"
value="Fecha Inicial:" /></strong>
<br></br>
<p:calendar id="txt_inicial"
value="#{cabDocumentoMB.fechaInicio}"
pattern="yyyy-MM-dd" mask="true" mode="popup" showOn="button"
readonlyInput="true">
<f:convertDateTime type="date" dateStyle="short"
pattern="yyyy-MM-dd" />
</p:calendar>
</p:column>
<p:column>
<strong><h:outputLabel styleClass="label"
value="Fecha Final:" /></strong>
<br></br>
<p:calendar id="txt_final"
value="#{cabDocumentoMB.fechaFinal}"
pattern="yyyy-MM-dd" mask="true" mode="popup" showOn="button"
readonlyInput="true">
<f:convertDateTime type="date" dateStyle="short"
pattern="yyyy-MM-dd" />
</p:calendar>
</p:column>
</p:row> <p:row>
<p:column style="text-align: center;">
<p:commandButton value=" Busqueda " icon="ui-icon-search"
title="Buscar Filtrado"
action="#{cabDocumentoMB.findDocumentos()}"
update=":frmData:listaDocumentos,:frmConf:datosEmisorPanel">
</p:commandButton>
</p:column>
<p:column>
<p:commandButton value="Reprocesar documentos "
icon="ui-icon-tag"
action="#{CabDocumentoMB.reprocesarDocumentos()}"
disabled="#{CabDocumentoMB.botonReprocesarActivo}"
update=":frmData:listaDocumentos,:frmConf:datosEmisorPanel">
</p:commandButton>
<br />
</p:column>
</p:row> </p:panelGrid>
</p:column>
</p:row>
</p:panelGrid>
</p:panel>
</h:form>
<h:form id="frmData" styleClass="form">
<p:panel id="datosDetalle22" >
<h:panelGroup id="listaDocumentos">
<p:dataTable id="lazyDataTable"
var="documento"
value="#{cabDocumentoMB.allDocumentos}"
paginator="true" rows="10" rowsPerPageTemplate="10,50,100"
selection="#{cabDocumentoMB.seleccionDocu}"
update=":frmData:listaDocumentos"
lazy="true">
<f:facet name="header">
Consulta de Documentos
</f:facet>
<p:column headerText="Identificación" style="width:10% ; font-size:11px" >
<h:outputText value="#{documento.identificacionComprador}" style="font-size:11px;" />
</p:column>
<p:column headerText="Razón Social" style="width:25% ; font-size:11px">
<h:outputText value="#{documento.razonSocialComprador}" style="font-size:11px;" />
</p:column>
<p:column headerText="Comprobante" style="width:10% ; font-size:11px">
<h:outputText value="#{documento.codigoDocumento}" style="font-size:11px;" />
</p:column>
<p:column headerText="Número" style="width:10% ; font-size:11px">
<h:outputText value="#{documento.id.serie}" style="font-size:11px;" />
</p:column>
<p:column headerText="Importe total" style="width:7% ; text-align:right ; font-size:11px">
<h:outputText value="#{documento.importeTotal}" style="font-size:11px;" />
</p:column>
<p:column headerText="Fecha Emisión" style="width:7% ; text-align:center ; font-size:11px">
<h:outputText value="#{documento.fechaEmision}" style="font-size:11px;" />
</p:column>
<p:column headerText="Ambiente"
style="width:10% ; text-align:center ; font-size:11px">
<h:outputText value="#{documento.id.ambiente}" style="font-size:11px;" />
</p:column>
<p:column headerText="Estado" style="width:20% ; font-size:11px">
<p:row>
<p:column>
<h:outputText value="#{documento.estadoTransaccion}" style="font-size:11px;" />
</p:column>
<p:column>
<p:commandButton update=":frmData:display" oncomplete="detalleEstadoDiag.show()" icon="ui-icon-search" style="float:right;">
<f:setPropertyActionListener
target="#{cabDocumentoMB.seleccionDocumentos}"
value="#{documento}"
/>
</p:commandButton>
</p:column>
</p:row>
</p:column>
<p:column headerText="PDF" style="font-size:11px" >
<p:commandLink action="#{cabDocumentoMB.pdf(documento,'')}"
ajax="false"
disabled="#{CabDocumentoMB.desactivaBotonPDF}"
update=":frmData:datosDetalle22">
<p:graphicImage value="/imagenes/pdf.png" ></p:graphicImage>
<f:setPropertyActionListener
target="#{cabDocumentoMB.documentos}"
value="#{documentos}" >
</f:setPropertyActionListener>
</p:commandLink>
</p:column>
<p:column headerText="XML" style="font-size:11px" >
<p:commandLink
action="#{cabDocumentoMB.xml(documento)}"
ajax="false"
update=":frmData:datosDetalle22"
disabled="#{CabDocumentoMB.desactivaBotonXML}">
<p:graphicImage value="/imagenes/xml.png"></p:graphicImage>
<f:setPropertyActionListener
target="#{cabDocumentoMB.documentos}"
value="#{documentos}">
</f:setPropertyActionListener>
</p:commandLink>
</p:column>
<p:column selectionMode="multiple"/>
</p:dataTable>
<p:dialog header="Detalle de estado" widgetVar="detalleEstadoDiag" resizable="false" width="400" showEffect="explode" hideEffect="explode" style="font-size:11px" >
<h:panelGrid id="display" columns="2" cellpadding="4">
<div align="left" style="font-size:11px;"><h:outputText value="Descripción: " style="font-weight:bold" /></div>
<h:outputText value="#{cabDocumentoMB.seleccionDocumentos.msjError}" />
</h:panelGrid>
</p:dialog>
</h:panelGroup>
</p:panel>
<p:panel id="datosExcel" style="align=center">
<h:commandLink>
<p:graphicImage value="/imagenes/excel.png" />
<p:dataExporter type="xls"
postProcessor="#{manager.postProcessXLS}" target="myData"
fileName="myexcel" />
</h:commandLink>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
</html>
Backing: (PDF Method)
...
JRBeanCollectionDataSource beanCollectionDataSource = new JRBeanCollectionDataSource(detallesAdiciones);
String reportPath = pathReports.get(doc.getId().getCodigoDocumento());
JasperPrint jasperPrint = null;
try {
jasperPrint = JasperFillManager.fillReport(reportPath, obtenerMapaParametrosReportes(obtenerParametrosInfoTriobutaria(doc), obtenerInfoFactura(lstFactDetAdictDocumento,doc)), beanCollectionDataSource);
} catch (JRException e) {
e.printStackTrace();
}
HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
httpServletResponse.addHeader("Content-disposition", "attachment; filename="+name);
ServletOutputStream servletOutputStream = null;
try {
servletOutputStream = httpServletResponse.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream);
} catch (JRException e) {
e.printStackTrace();
}
FacesContext.getCurrentInstance().responseComplete();

actionListener of p:commandButton in h:dataTable is not invoked

I have a <h:dataTable> adds contents of an input text to a list in a nested <h:dataTable>. A hidden command button is linked to the input text
Problem is only the first input text's action method work, hence only list attached to the first thread of the parent message is updated not the consecutive once.
<p:tabView id="tabView">
<p:tab id="tab1" title="Conversation">
<h:form id="pol">
<p:dataTable var="message"
value="#{channelBean.getBean('channel').messageList}"
id="messageListTable">
<p:column>
<f:facet name="header">Photo</f:facet>
<h:outputText value="Photo" />
</p:column>
<p:column>
<f:facet name="header">Message</f:facet>
<p:panelGrid columns="1">
<p:panelGrid columns="3">
<h:outputText value="#{message.sender}" />
<h:outputText rendered="#{message.channel!=null}"
value="#{message.channel.name}" />
<h:outputText value="#{message.message}" escape="false" />
</p:panelGrid>
<p:panelGrid columns="8">
<h:outputText value="#{message.postedString}" />
<h:form>
<p:commandLink id="likeLink" value="UnLike"
rendered="#{message.liked}" update="#parent" ajax="false">
<f:actionListener binding="#{channelBean.like(message)}" />
</p:commandLink>
<p:commandLink id="unLikeLink" value="Like"
rendered="#{!message.liked}" update="#parent" ajax="false">
<f:actionListener binding="#{channelBean.unLike(message)}" />
</p:commandLink>
<h:outputText value="." />
<h:outputText value="Reply" />
<h:outputText value="." />
<h:outputText value="Share" />
<h:outputText value="." />
<p:commandLink id="moreLink" value="More" />
<p:menu overlay="true" trigger="moreLink" my="left top"
at="left bottom">
<p:menuitem value="Save" icon="ui-icon-disk" />
<p:menuitem value="Update" icon="ui-icon-arrowrefresh-1-w" />
</p:menu>
</h:form>
</p:panelGrid>
</p:panelGrid>
</p:column>
</p:dataTable>
</h:form>
</p:tab>
<p:tab id="tab2" title="Info">
<h:form id="channelViewForm">
<l:inputTextarea
cid="com_fourforbusiness_esm_shared_domain_ffbesm_Channel_description"
label="#{msg.description}:"
value="#{channelBean.getBean('channel').description}" />
<p:commandLink value="#{msg.save}"
update=":sideBarForm:subscribedChannels,#parent">
<f:actionListener
binding="#{channelBean.saveChannel('channel')}" />
</p:commandLink>
</h:form>
</p:tab>
<p:tab id="tab3" title="File"></p:tab>
<p:tab id="tab4" title="Notes"></p:tab>
</p:tabView>
</p:panel>
<p:panel id="inbox" visible="#{mainViewBean.currentView=='IN_BOX'}"
autoUpdate="true">
<h:form id="pol">
<p:dataTable var="message"
value="#{channelBean.subscribedChannelsMessages}"
id="messageListTable"
>
<p:column>
<f:facet name="header">Photo</f:facet>
<h:outputText value="Photo" />
</p:column>
<p:column>
<f:facet name="header">Message</f:facet>
<p:panelGrid columns="1">
<p:panelGrid columns="3">
<h:outputText value="#{message.sender}" />
<h:outputText rendered="#{message.channel!=null}"
value="#{message.channel.name}" />
<h:outputText value="#{message.message}" escape="false" />
</p:panelGrid>
<p:panelGrid columns="8" id="panelx">
<h:outputText value="#{message.postedString}" />
<h:form>
<p:commandLink id="likeLink" value="UnLike"
rendered="#{message.liked}" update="#parent" ajax="false">
<f:actionListener binding="#{channelBean.like(message)}" />
</p:commandLink>
<p:commandLink id="unLikeLink" value="Like"
rendered="#{!message.liked}" update="#parent" ajax="false">
<f:actionListener binding="#{channelBean.unLike(message)}" />
</p:commandLink>
<h:outputText value="." />
<p:commandLink id="replyLink" value="Reply" action="#{channelBean.enabletextbox}" process="#this" ajax="true" update=":pol">
</p:commandLink>
<h:outputText value="." />
<h:outputText value="Share" />
<h:outputText value="." />
<p:commandLink id="moreLink" value="More" />
<p:menu overlay="true" trigger="moreLink" my="left top"
at="left bottom">
<p:menuitem value="Save" icon="ui-icon-disk" />
<p:menuitem value="Update" icon="ui-icon-arrowrefresh-1-w" />
</p:menu>
<BR></BR>
<p:inputText value="#{channelBean.repli}" rendered="#{channelBean.replyClicked}" id="replyTxt" ></p:inputText>
<p:commandButton value="repSave" ajax="true" actionListener="#{channelBean.addMessage(message)}" rendered="#{channelBean.replyClicked}" update=":pol" style="visibility: hidden;" oncomplete="alert('#{message.message}');"> </p:commandButton>
<p:dataTable var="rep" id="replyListTable" value="#{message.replyList}">
<p:column headerText="Replies">
<h:outputText value="#{rep.reply}" />
</p:column>
</p:dataTable>
</h:form>
</p:panelGrid>
</p:panelGrid>
</p:column>
</p:dataTable>
</h:form>
</p:panel>
Backing bean:
public void addMessage (Message msg)
{
List<Message> subList=this.getSubscribedChannelsMessages();
for(Message mess:subList)
{
if(mess.getMessage().equalsIgnoreCase(msg.getMessage()))
{
msg.getReplyList().add(new Reply (repli));
repli = "";
replyClicked = false;
}
}
}
public void enabletextbox()
{
if (replyClicked==false)
replyClicked =true;
else
replyClicked = false;
}
I don't understand why the <p:commandButton> of the nested <h:dataTable> doesn't invoke its actionListener. How is this caused and how can I solve it?

Centering a gmap

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;
}

Resources