How can I export a p:chart type "line" to image as png or jpg file? - primefaces

I am sorry for my english level but I have a problem that has been going on for more than 3 days without finding any answer. My question is how I can export as image(png o jpg file) a p:chart type "line", I'm using JSF 2.1 and primefaces 5.3.
I leave my code here ...
<ui:composition 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"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:pe="http://primefaces.org/ui/extensions"
template="/plantillas/templateHistComp.xhtml">
<ui:define name="content">
<f:metadata>
<f:viewParam name="dmy" />
<f:event listener="#{InfoHistMB.init}" type="preRenderView" />
</f:metadata>
<h:head>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
</f:facet>
<title>::INFOAIRE::</title>
<h:outputScript name="js/layout.js" />
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAnKoDxm56hN4vhtkWuJdnSfejjJNc60Es"></script>
<!-- <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>-->
<h:outputText value="<!--[if gte IE 9]>" escape="false" />
<style type="text/css">
/* styles for IE 9 */
</style>
<h:outputText value="<![endif]-->" escape="false" />
<ui:insert name="head" />
<h:outputStylesheet name="grid/grid.css" library="primefaces" />
</h:head>
<h:body id="bodyInfHist">
<h:outputScript library="jqplot-plugin" name="jqplot.canvasOverlay.min.js" target="head" />
<!-- <h:outputScript library="js" name="extra_config.js" target="head" /> -->
<f:view>
<h:form id="formInfoHist">
<p:breadCrumb style="margin:0 auto;">
<p:menuitem value="Inicio" url="#" />
<p:menuitem value="Info Aire" outcome="/InformacionHistorica.xhtml"/>
<p:menuitem value="Historica-Comparativa" outcome="/InfoHistComparativa.xhtml"/>
<p:menuitem value="Historica-Detalle" outcome="/InfoHistDetalle.xhtml"/>
</p:breadCrumb>
<div class="ui-fluid">
<!-- <p:messages id="messages" showDetail="true" autoUpdate="false" closable="true" /> -->
<p:panelGrid columns="6" columnClasses="ui-grid-col-2,ui-grid-col-2,ui-grid-col-2,ui-grid-col-2,ui-grid-col-2,ui-grid-col-2" layout="grid" styleClass="ui-panelgrid-blank">
<p:outputLabel value="Departamento:"/>
<p:selectOneMenu id="departamentoBusqueda" value="#{InfoHistMB.departamento}" required="true" requiredMessage="Departamento es requerido!">
<p:ajax event="change" listener="#{InfoHistMB.onDepartamentChange}"
update="provinciaBusqueda,distritoBusqueda,estacionBusqueda"></p:ajax>
<f:selectItem itemLabel="Seleccione" itemValue="#{null}"/>
<f:selectItems value="#{InfoHistMB.listaDepartamento}" var="ld" id="listaDepartamentos"
itemLabel="#{ld.vDescripcion}" itemValue="#{ld.vCodigoDepa}"/>
</p:selectOneMenu>
<p:outputLabel value="Provincia:"/>
<p:selectOneMenu id="provinciaBusqueda" value="#{InfoHistMB.provincia}">
<p:ajax event="change" listener="#{InfoHistMB.onProvinciaChange}"
inmediate="true" process="#form" update="distritoBusqueda,estacionBusqueda"></p:ajax>
<f:selectItem itemLabel="Seleccionar" itemValue="00" />
<f:selectItems value="#{InfoHistMB.listaProvincia}" var="ld" id="listaProvincias"
itemLabel="#{ld.vDescripcion}" itemValue="#{ld.vCodigoProv}"/>
</p:selectOneMenu>
<p:outputLabel value="Distrito:"/>
<p:selectOneMenu id="distritoBusqueda" value="#{InfoHistMB.district}">
<p:ajax event="change" listener="#{InfoHistMB.onDistritoChange}"
inmediate="true" process="#form" update="estacionBusqueda"></p:ajax>
<f:selectItem itemLabel="Seleccionar" itemValue="00"/>
<f:selectItems value="#{InfoHistMB.listaDistrito}" var="ld" id="listaDistritos"
itemLabel="#{ld.vDescripcion}" itemValue="#{ld.vCodigoDist}"/>
</p:selectOneMenu>
<p:outputLabel value="Estación:"/>
<p:selectOneMenu id="estacionBusqueda" value="#{InfoHistMB.estacion}">
<f:selectItem itemLabel="Seleccione" itemValue="0" />
<f:selectItems value="#{InfoHistMB.listaEstacion}" var="ld" id="listaEstaciones"
itemLabel="#{ld.vNombreEstacion}" itemValue="#{ld.idEstacion}"/>
</p:selectOneMenu>
<p:outputLabel value="Periodo de medición:"/>
<p:selectOneMenu id="periodoMedicion" value="#{InfoHistMB.idPeriodoMed}">
<p:ajax event="change" listener="#{InfoHistMB.onPeriodoMedChange}"
inmediate="true" process="#form" update="parametro,finit"></p:ajax>
<f:selectItems value="#{InfoHistMB.listaPeriodoMed}" var="ld" id="listaPeriodoMed"
itemLabel="#{ld.vDescripcion}" itemValue="#{ld.idElemento}"/>
</p:selectOneMenu>
<p:outputLabel value="Fuente:"/>
<p:selectOneMenu id="fuente" value="#{InfoHistMB.idEntidadFuente}">
<f:selectItem itemLabel="Seleccione" itemValue="0" />
<f:selectItems value="#{InfoHistMB.listaFuente}" var="ld" id="listaFuente"
itemLabel="#{ld.vDescripcion}" itemValue="#{ld.idEntidad}"/>
</p:selectOneMenu>
<p:outputLabel value="Parametro:"/>
<p:selectOneMenu id="parametro" value="#{InfoHistMB.idParametro}">
<f:selectItem itemLabel="Seleccione" itemValue="0" />
<f:selectItems value="#{InfoHistMB.listaParametro}" var="ld" id="listaParametro"
itemLabel="#{ld.vNombreParametro}" itemValue="#{ld.idParametro}"/>
</p:selectOneMenu>
<p:outputLabel value="Fecha inicio:"/>
<p:calendar value="#{InfoHistMB.ffinit}" id="finit" disabled="#{InfoHistMB.enableFecha}" effect="fold" pattern="yyyy-MM-dd" requiredMessage="Fecha es requerida!"></p:calendar>
<p:outputLabel value="Fecha fin:"/>
<p:calendar value="#{InfoHistMB.ffin}" id="fend" effect="fold" pattern="yyyy-MM-dd" requiredMessage="Fecha es requerida!" ></p:calendar>
</p:panelGrid>
<div id="buscar" align="right" style="width:100%;">
<p:commandButton value="Buscar" id="buscar" actionListener="#{InfoHistMB.updateTable}" process="#form" inmediate="true" update="tablaResultados,EstacionMarker" icon="ui-icon-search" style="margin: 15px 10px; width:100px;">
</p:commandButton>
</div>
</div>
<div class="ui-grid ui-grid-responsive" style="border: 2px solid #E7E5E0;border-radius: 5px;">
<div class="ui-grid-row">
<div class="ui-grid-col-6" style="padding:10px 10px 0px 5px;">
<f:view contentType="text/html">
<p:gmap id="EstacionMarker" center="-12.046374, -77.042793" zoom="10" type="HYBRID" model="#{InfoHistMB.simpleModel}" style="width:100%;height:450px" />
</f:view>
</div>
<div class="ui-grid-col-6" style="padding: 0px 5px;">
<h3 style="color:#9B9995; padding:5px 5px;font-size: 1.5em;" >
Resultados Obtenidos</h3>
<p:dataTable id="tablaResultados" var="resultado" value="#{InfoHistMB.listaElementosTabla}" reflow="true" rows="5" paginator="true" tableStyle="width:auto" >
<p:column headerText="Ubigeo">
<h:outputText value="#{resultado.departamento}" />
</p:column>
<p:column headerText="Estaciones">
<h:outputText value="#{resultado.estaciones}"/>
</p:column>
<p:column headerText="Parámetros">
<h:outputText value="#{resultado.parametros}" />
</p:column>
<p:column headerText="Fecha inicio">
<h:outputText value="#{resultado.fechaInit}" />
</p:column>
<p:column headerText="Fecha fin">
<h:outputText value="#{resultado.fechaFin}" />
</p:column>
<p:column id="columnVer" headerText="Ver ">
<p:commandButton id="ver" value="Ver" actionListener="#{InfoHistMB.updateGraficolinear(resultado)}" process="#form" inmediate="true" update="formInfoHist:graficoLineal,formInfoHist:exEca,formInfoHist:exNoEca" icon="ui-icon-extlink" />
</p:column>
</p:dataTable>
</div>
</div>
</div>
<div class="ui-grid ui-grid-responsive" style="border: 2px solid #E7E5E0;border-radius: 5px;">
<div class="ui-grid-row">
<div class="ui-grid-col-12">
<h2 style="padding:15px 0px; text-transform: capitalize; text-align: center; font-family: Arial, Helvetica, sans-serif;">
Comparativo entre el resultado de la búsqueda y el estandar de calidad ambiental</h2>
</div>
</div>
</div>
<div class="ui-grid ui-grid-responsive" style="border: 2px solid #E7E5E0;border-radius: 5px;">
<div class="ui-grid-row">
<div class="ui-grid-col-9">
<p:chart id ="graficoLineal" type="line" model="#{InfoHistMB.lineModel2}" widgetVar="chartLineal" style="width:100%;height:350px;margin:20px 0" responsive="true"/>
</div>
<div class="ui-grid-col-3">
<div class="ui-grid ui-grid-responsive">
<div class="ui-grid-row">
<div class="ui-grid-col-12">
<hr style="height: 1px;background-color: #4278D5;"/>
</div>
</div>
<div class="ui-grid-row">
<div class="ui-grid-col-12">
<p:panelGrid columns="2" columnClasses="ui-grid-col-10,ui-grid-col-2" layout="grid" styleClass="ui-panelgrid-blank">
<h:outputText value="Nº de veces que se excedió el estandar de calidad ambiental " />
<h:outputText id="exEca" value="#{InfoHistMB.excedeEca}" ></h:outputText>
</p:panelGrid>
</div>
</div>
<div class="ui-grid-row">
<div class="ui-grid-col-12">
<hr style="height: 2px;background-color: #4278D5;"/>
</div>
</div>
<div class="ui-grid-row">
<div class="ui-grid-col-12">
<p:panelGrid columns="2" columnClasses="ui-grid-col-10,ui-grid-col-2" layout="grid" styleClass="ui-panelgrid-blank">
<h:outputText value="Nº de veces que no se excedió el estandar de calidad ambiental " />
<h:outputText id="exNoEca" value="#{InfoHistMB.noExcedeEca}" ></h:outputText>
</p:panelGrid>
</div>
</div>
<div class="ui-grid-row">
<div class="ui-grid-col-12">
<hr style="height: 1px;background-color: #4278D5;"/>
</div>
</div>
<div class="ui-grid-row">
<div class="ui-grid-col-12" align="center">
</div>
</div>
</div>
</div>
</div>
</div>
</h:form>
<script type="text/javascript">
function chartExtender() {
this.cfg.seriesDefaults.rendererOptions.varyBarColor = true;
}
</script>
</f:view>
</h:body>
</ui:define>
</ui:composition>
Exactly this is section of p:chart ...
<div class="ui-grid-col-9">
<p:chart id ="graficoLineal" type="line" model="#{InfoHistMB.lineModel2}" widgetVar="chartLineal" style="width:100%;height:350px;margin:20px 0" responsive="true"/>
</div>
I generate the graph dynamically from a database but I have not had a problem with it. I have used the example of the primefaces page but without any result.

Primefaces provide client side method to convert chart to an image that can be downloaded
The following is an example from primefaces reference guide
<p:chart type="line" model="#{bean.model}" style="width:500px;
height:300px" widgetVar="chart"/>
<p:commandButton type="button" value="Export" icon="ui-icon-extlink"
onclick="exportChart()"/>
<p:dialog widgetVar="dlg" showEffect="fade" modal="true"
header="Chart as an Image">
<p:outputPanel id="output" layout="block" style="width:500px;height:300px"/>
</p:dialog>
function exportChart() {
//export image
$('#output').empty().append(PF('chart').exportAsImage());
//show the dialog
PF('dlg').show();
}

Related

p:dataScroller works only for the last element

I am trying to use dataScroller to show elements of a database table. It shows all the elements correctly but when I try to use some actions it only works for the last element like:
<p:commandButton value="vote"
action="#{avisBean.updateAvis(in,email)}">
and
<p:commandButton value="commenter" icon="ui-icon-check"
action="#{avisBean.addAvis(in,email)}">`
and for the others nothings enters to the database just empty string. How can I correct this?
This is the code:
<h:form id="commandLink">
<p:dataScroller value="#{ideeBean.idees}" var="in" chunkSize="10"
mode="inline" scrollHeight="500">
<f:facet name="header">
Les Idées
</f:facet>
<h:panelGrid columns="1" style="width:100%"
columnClasses="logo,detail">
<!-- <p:graphicImage name="demo/images/car/#{car.brand}-big.gif" /> -->
<p:outputPanel>
<h:panelGrid columns="2" cellpadding="5">
<h:outputText value="#{msg['idee.titre']}" />
<h:outputText value="#{in.titre}" style="font-weight: bold" />
<h:outputText value="#{msg['idee.description']}" />
<h:outputText value="#{in.description}"
style="font-weight: bold" />
<h:outputText value="#{msg['idee.theme']}" />
<h:outputText value="#{in.theme}" style="font-weight: bold" />
<h:outputText value="#{msg['idee.type']}" />
<h:outputText value="#{in.type}" style="font-weight: bold" />
<!-- *******************Rating**************** -->
</h:panelGrid>
</p:outputPanel>
<h:panelGrid columns="4" cellpadding="5">
<p:commandButton value="details"
action="details?faces-redirect=true"
actionListener="#{ideeBean.attrListener}">
<f:attribute name="idee" value="#{in}" />
</p:commandButton>
<!--************************************** -->
<p:selectOneMenu id="console" value="#{avisBean.avis.score}"
style="width:125px" converter="javax.faces.Integer">
<f:convertNumber integerOnly="true" />
<f:selectItem itemLabel="Choisir" itemValue="" />
<f:selectItem itemLabel="Horrible" itemValue="1" />
<f:selectItem itemLabel="médiocre" itemValue="2" />
<f:selectItem itemLabel="Bon" itemValue="3" />
<f:selectItem itemLabel="Trés Bon" itemValue="4" />
<f:selectItem itemLabel="Excellent" itemValue="5" />
</p:selectOneMenu>
<p:commandButton value="vote"
action="#{avisBean.updateAvis(in,email)}">
</p:commandButton>
</h:panelGrid>
<!-- ***************************comments******************** -->
<p:dataScroller id="growl"
value="#{ideeBean.getAllAvisList(in.id)}" var="a" chunkSize="2">
<f:facet name="header">
commentaires
</f:facet>
<f:facet name="loader">
<p:commandButton type="button" value="Plus"
icon="ui-icon-circle-triangle-s" />
</f:facet>
<h:panelGrid columns="1">
<!-- <p:graphicImage name="demo/images/car/#{car.brand}-big.gif" /> -->
<p:outputPanel>
<h:panelGrid columns="4" cellpadding="5">
<h:outputText value="#{a.user_avis.nom}" />
<p:inplace id="ajax" editor="true">
<p:ajax event="save" listener="#{avisBean.updateAvis(a)}" />
<h:inputText value="#{a.commentaire}"
style="font-weight: bold" rendered="#{not empty a.commentaire}" />
</p:inplace>
<p:commandButton value="Supprimer"
action="#{ideeBean.deleteAvisById(in.id,a.id)}"
icon="ui-icon-arrowrefresh-1-w"
rendered="#{utilisateurBean.getAllAvis(a,userid)}">
<f:param name="userid" value="#{loginBean.id}"></f:param>
</p:commandButton>
</h:panelGrid>
</p:outputPanel>
</h:panelGrid>
</p:dataScroller>
<!-- ***************************************** -->
<h:panelGrid columns="1">
<p:inputTextarea rows="2" cols="50" id="comment"
value="#{avisBean.avis.commentaire}" />
<p:commandButton value="commenter" icon="ui-icon-check"
action="#{avisBean.addAvis(in,email)}">
<f:param name="email" value="#{loginBean.email}"></f:param>
</p:commandButton>
</h:panelGrid>
<h:panelGrid columns="1" style="width:100%">
<p:graphicImage value="resources/images/separateurr.png" />
</h:panelGrid>
</h:panelGrid>
</p:dataScroller>
</h:form>

unable to use OneMenu inside carousel

I wanted to use OneMenu inside a carousel to set a properties in managedBean, but its not working.
i test the OneMenu without Carousel and it work good , so i think that the problem is inside the carousel .
Any ideas as to what is going on here? plz help .
this is my xhtm page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
template="/template/template.xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:define name="pageContent">
<h:form id="form1">
<br />
<br />
<br />
<p:carousel value="#{homeBean.doInstances()}" headerText="Bootstrap VM " var="vm" itemStyle="text-align:center" responsive="true">
<p:panelGrid columns="2" columnClasses="label,value" layout="grid" style="margin: 0 auto;" styleClass="ui-panelgrid-blank">
<f:facet name="header"><p:graphicImage name="images/instance.jpg" /></f:facet>
<p:panelGrid columns="2" style="margin: 0 auto;">
<h:outputText value="name" />
<h:outputText value="#{vm.name}" />
<h:outputLabel value="ip" />
<h:outputLabel value="#{vm.url}" />
<p:outputLabel value="Configuration" />
<p:selectOneMenu id="recepie3" value="#{bootstrapBean.recipeSelected}">
<f:selectItem itemLabel="Select One Recipie " itemValue="" />
<f:selectItems value="#{bootstrapBean.selectItems}" />
</p:selectOneMenu>
<p:commandButton value="Bootstrap" ajax="false" validateClient="true" actionListener="#{bootstrapBean.bootstrapSelectedVm(vm.url)}" />
</p:panelGrid>
</p:panelGrid>
<f:facet name="footer" style="margin: 0 auto;">
<p:panelGrid columns="3" columnClasses="label,value" layout="grid" style="margin: 0 auto;" styleClass="ui-panelgrid-blank">
<h:outputLabel>Bootstrap All VMs :</h:outputLabel>
<p:selectOneMenu id="recepie2" value="#{bootstrapBean.recipeSelected}">
<f:selectItem itemLabel="Select One Recipie " itemValue="" />
<f:selectItems value="#{bootstrapBean.recipies}" />
</p:selectOneMenu>
<p:commandButton value="Bootstrap" ajax="false" validateClient="true" actionListener="#{bootstrapBean.bootstrapAllVMs()}" />
</p:panelGrid>
</f:facet>
</p:carousel>
</h:form>
</ui:define>
</ui:composition>
Tag library initialized incorrectly, please correct it and its work.

Ajax Update on PrimeFaces dialog disables datepicker, and textarea counters

I have a PrimeFaces dataTable with buttons at the footer for creating, editing and deleting records from the table.
A click on the Create and Edit button displays a modal dialog to carry out each task. During a create or Edit, the dialog is not dismissed but rather an Ajax update is done so that as many record as possible can be inserted or edit can be repeatedly done. But the issue now is, after any Ajax Update datepickers gets disabled and TextArea counters disappears. Code sample is available below:
<ui:define name="metadata">
<f:metadata>
<f:event listener="#{departmentController.retrieveDeptList}"
type="preRenderView"/>
</f:metadata>
</ui:define>
<ui:define name="title">
<h:outputText value="#{bundle.ListDepartmentTitle}" />
</ui:define>
<ui:define name="mainContent">
<!--main content start-->
<section id="main-content">
<section class="wrapper">
<h3><i class="fa fa-angle-right"></i> #{bundle.ListDepartmentMainTableTitle}</h3>
<div class="row">
<div class="col-md-12">
<div class="content-panel">
<h:form id="DepartmentListForm">
<h:panelGroup id="results" styleClass="table-responsive">
<p:spacer width="10"/>
<h:outputText id="informationMessage"
value="#{departmentController.infoMessage}"
rendered="#{departmentController.infoMessage ne null}"
styleClass="informationMessage"/>
<p:dataTable id="datalist"
value="#{departmentController.items}"
var="item"
tableStyleClass="table"
selectionMode="single"
selection="#{departmentController.newDept}"
paginator="true"
scrollable="true"
scrollHeight="250"
rowKey="#{item.deptId}"
rows="10"
rowsPerPageTemplate="10,20,30,40,50"
emptyMessage="No department results found" >
<p:ajax event="rowSelect"
listener="#{departmentController.onRowSelect}"
update="createButton editButton deleteButton viewMemButton"/>
<p:ajax event="rowUnselect"
listener="#{departmentController.onRowUnselect}"
update="createButton editButton deleteButton viewMemButton"/>
<p:column>
<f:facet name="header">
<h:outputText value="#{bundle['ListDepartmentTitle_deptName']}"/>
</f:facet>
<h:outputText value="#{item.deptName}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{bundle['ListDepartmentTitle_dateEstablished']}"/>
</f:facet>
<h:outputText value="#{item.dateEstablished}">
<f:convertDateTime pattern="dd.MMM.yyyy" />
</h:outputText>
</p:column>
<f:facet name="footer">
<p:commandButton id="createButton"
icon="ui-icon-plus"
value="#{bundle['Create']}"
actionListener="#{departmentController.prepareCreate}"
oncomplete="PF('DepartmentCreateDialog').show()"/>
<p:spacer width="10"/>
<p:commandButton id="editButton"
process="#form"
icon="ui-icon-pencil"
value="#{bundle.Edit}"
update=":DepartmentEditForm"
oncomplete="PF('DepartmentEditDialog').show()"
disabled="#{departmentController.selectedDept eq null}" />
<p:spacer width="10"/>
<p:commandButton id="deleteButton"
icon="ui-icon-trash"
process="#form"
value="#{bundle.Delete}"
action="#{parishOfficesController.destroy}"
update=":growl, :DepartmentListForm:results"
disabled="#{departmentController.selectedDept eq null}">
<p:confirm header="Confirmation"
message="Are you sure you want to delete?"
icon="ui-icon-alert" />
</p:commandButton>
<p:confirmDialog global="true"
showEffect="fade"
styleClass="text-center"
hideEffect="fade">
<p:commandButton value="Yes" type="button"
styleClass="ui-confirmdialog-yes"
icon="ui-icon-check" />
<p:commandButton value="No" type="button"
styleClass="ui-confirmdialog-no"
icon="ui-icon-close" />
</p:confirmDialog>
<p:spacer width="30"/>
<p:commandButton id="viewMemButton"
value="#{bundle.ViewMembers}"
icon="ui-icon-extlink"
actionListener="#{dfView.chooseDepartment}"
disabled="#{departmentController.selectedDept eq null}" >
<p:ajax event="dialogReturn"
listener="#{dfView.onDeptMemberChosen}"
update=":growl" />
</p:commandButton>
</f:facet>
</p:dataTable>
</h:panelGroup>
<h:messages id="messages" styleClass="errorMessage"/>
</h:form>
<ui:include src="addDept.xhtml"/>
<ui:include src="editDept.xhtml"/>
</div>
</div>
</div>
</section>
</section><!-- /MAIN CONTENT -->
</ui:define>
//---------------------------------------------------------------------------
<p:dialog id="DepartmentEditDlg"
widgetVar="DepartmentEditDialog"
modal="true"
resizable="false"
appendTo="#(body)"
closable="false"
width="400"
height="300"
header="#{bundle['EditDepartmentTitle']}">
<h:form id="DepartmentEditForm" prependId="false">
<h:panelGroup id="editDisplay">
<p:messages id="editMsg" globalOnly="true" closable="true">
<p:effect type="pulsate" event="load" delay="500" />
</p:messages>
<br/>
<div class="form-group">
<h:outputLabel styleClass="labelText"
value="#{bundle.EditDepartmentLabel_deptName}"
for="editDeptName" />
<h:inputText id="editDeptName"
value="#{departmentController.newDept.deptName}"
title="#{bundle.EditParishOfficesTitle_deptName}"
required="true"
styleClass="form-control"
requiredMessage="#{bundle.EditDepartmentRequiredMessage_deptName}"/>
<h:message id="DeptEditMsg"
styleClass="errorMessage"
for="editDeptName"
showDetail="true"/>
</div>
<div class="form-group">
<h:outputLabel styleClass="labelText"
value="#{bundle.EditDepartmentLabel_dateEstablished}"
for="editDateEstablished" />
<b:datepicker id="editDateEstablished"
showButtonPanel="true"
change-month="true"
placeholder="Select a Date"
change-year="true"
value="#{departmentController.newDept.dateEstablished}"/>
</div>
<!--
<div>
<h:outputLabel styleClass="labelText"
value="#{bundle.EditDepartmentLabel_dateEstablished}"
for="editDateEstablished" />
</div>
<div>
<p:calendar id="editDateEstablished"
readonlyInput="true"
navigator="true"
mode="popup"
showButtonPanel="true"
pattern="dd.MMM.yyyy"
value="#{departmentController.newDept.dateEstablished}"
title="#{bundle.EditDepartmentTitle_dateEstablished}"
showOn="button"/>
</div>
-->
<br/>
<div class="modal-footer">
<p:commandButton actionListener="#{departmentController.update}"
value="#{bundle.Save}"
update="editDisplay,
:growl, :DepartmentListForm:results,
:DepartmentListForm:messages" />
<p:spacer width="10"/>
<p:commandButton value="#{bundle.Cancel}"
process=":DepartmentListForm"
action="#{departmentController.cancel}"
ajax="false"
onclick="DepartmentEditDialog.hide()"
update=":DepartmentListForm:results"
immediate="true" />
</div>
</h:panelGroup>
</h:form>
</p:dialog>
//--------------------------------------------------------------------------
<p:dialog id="DepartmentCreateDlg"
widgetVar="DepartmentCreateDialog"
modal="true"
resizable="false"
appendTo="#(body)"
closable="false"
width="400"
height="300"
header="#{bundle['CreateDepartmentTitle']}">
<h:form id="DepartmentCreateForm" prependId="false">
<h:panelGroup id="display">
<p:messages id="createMsg" globalOnly="true" closable="true">
<p:effect type="pulsate" event="load" delay="500" />
</p:messages>
<br/>
<div class="form-group">
<h:outputLabel styleClass="labelText"
value="#{bundle['CreateDepartmentLabel_deptName']}"
for="deptName" />
<h:inputText id="deptName"
styleClass="form-control"
value="#{departmentController.newDept.deptName}"
title="#{bundle['CreateDepartmentTitle_deptName']}"
required="true"
requiredMessage="#{bundle['CreateDepartmentRequiredMessage_deptName']}"/>
<h:message id="deptNameMsg"
styleClass="errorMessage"
for="deptName"
showDetail="true"/>
</div>
<div class="form-group">
<h:outputLabel styleClass="labelText"
value="#{bundle['CreateDepartmentLabel_dateEstablished']}"
for="dateEstablished" />
<b:datepicker id="dateEstablished"
showButtonPanel="true"
change-month="true"
placeholder="Select a Date"
change-year="true"
value="#{departmentController.newDept.dateEstablished}"/>
</div>
<!--
<div>
<h:outputLabel styleClass="labelText"
value="#{bundle['CreateDepartmentLabel_dateEstablished']}"
for="dateEstablished" />
</div>
<div>
<p:calendar id="dateEstablished"
readonlyInput="true"
navigator="true"
mode="popup"
showButtonPanel="true"
showOn="button"
pattern="dd.MMM.yyyy"
value="#{departmentController.newDept.dateEstablished}"
title="#{bundle['CreateDepartmentTitle_dateEstablished']}" />
</div>
-->
<br/>
<div class="modal-footer">
<p:commandButton actionListener="#{departmentController.create}"
value="#{bundle.Save}"
update=":DepartmentListForm:results,
:growl,
display,
:DepartmentListForm:messages" />
<p:spacer width="10"/>
<p:commandButton value="#{bundle.Cancel}"
process=":DepartmentListForm"
action="#{departmentController.cancel}"
onclick="DepartmentCreateDialog.hide()"
ajax="false"
update=":DepartmentListForm:results"
immediate="true" />
</div>
</h:panelGroup>
</h:form>
</p:dialog>

Printing in Primefaces

so I am using the printer from Primefaces, but it can not find the id of the datatable im trying to print. Anyone know why? I have removed some code for clarity. I also got the printer working on a different site but its not working here
<p:outputPanel id="topPanel" style=" display:block; height: 24%; float: top">
<h:form>
<p:growl id="messages" showDetail="true" />
<p:toolbar style="width: 100%">
<f:facet name="right">
<div style="float: right">
<p:commandButton actionListener="#{s.save}" value="Bearbeiten">
<f:param name="Bearbeiten" value="10" />
</p:commandButton>
<p:commandButton value="Drucken" type="button" icon="ui-icon-print">
<p:printer target="datatable"/>
</p:commandButton>
</div>
</f:facet>
</p:toolbar>
</h:form>
</p:outputPanel>
<p:outputPanel id="datatable" style="height: 50%">
<ui:insert name="datatable" />
<p:dataTable var="item" value="" paginator="true" rows="10" selection="" id="Datatable">
<p:column style="width:16px;text-align:center"/>
<p:column headerText="ID">
<h:outputText value="" />
</p:column>
<p:column headerText="Nachname">
<h:outputText value="" />
</p:column>
<p:column headerText="Vorname">
<h:outputText value="" />
</p:column>
</p:dataTable>
</p:outputPanel>

Primefaces Chat outputPanel displays no scrollbar

I'm facing an issue with the Primefaces Chat demo from the Primefaces showcase. The outputPanel component does not display a scroll bar like in the showcase demo. Here is my code and screenshot below:
<h:head>
<script type="text/javascript">
function handleMessage(data) {
var chatContent = $(PrimeFaces.escapeClientId('form:public'));
chatContent.append(data + '<br />');
//keep scroll
chatContent.scrollTop(200); <----------- have tried "chatContent.height()"
}
</script>
</h:head>
<h:body>
<p:growl id="growl" showDetail="true" />
<h:form id="form">
<p:fieldset id="container" legend="UserChat" toggleable="true">
<h:panelGroup rendered="#{chatView.loggedIn}">
<h:panelGrid columns="2" columnClasses="publicColumn,usersColumn" style="width:100%">
<p:outputPanel id="public" layout="block" styleClass="ui-corner-all ui-widget-content chatlogs" />
<p:dataList id="users" var="user" value="#{chatView.users}" styleClass="usersList">
<f:facet name="header">
Users
</f:facet>
<p:commandButton title="Chat" icon="ui-icon-comment" oncomplete="pChat.show()" update=":form:privateChatContainer">
<f:setPropertyActionListener value="#{user}" target="#{chatView.privateUser}" />
</p:commandButton>
#{user}
</p:dataList>
</h:panelGrid>
<p:separator />
<p:inputText value="#{chatView.globalMessage}" styleClass="messageInput" />
<p:spacer width="5" />
<p:commandButton value="Send" actionListener="#{chatView.sendGlobal}" oncomplete="$('.messageInput').val('').focus()"/>
<p:spacer width="5" />
<p:commandButton value="Disconnect" actionListener="#{chatView.disconnect}" global="false" update="container" />
</h:panelGroup>
<h:panelGroup rendered="#{not chatView.loggedIn}" >
Username: <p:inputText value="#{chatView.username}" />
<p:spacer width="5" />
<p:commandButton value="Login" actionListener="#{chatView.login}" update="container"
icon="ui-icon-person" />
</h:panelGroup>
</p:fieldset>
<p:dialog widgetVar="pChat" header="Private Chat" modal="true" showEffect="fade" hideEffect="fade">
<h:panelGrid id="privateChatContainer" columns="2" columnClasses="vtop,vtop">
<p:outputLabel for="pChatInput" value="To: #{chatView.privateUser}" />
<p:inputTextarea id="pChatInput" value="#{chatView.privateMessage}" rows="5" cols="30" />
<p:spacer />
<p:commandButton value="Send" actionListener="#{chatView.sendPrivate}" oncomplete="pChat.hide()" />
</h:panelGrid>
</p:dialog>
</h:form>
<p:socket onMessage="handleMessage" channel="/chat" autoConnect="true" widgetVar="subscriber"/>
</h:body>
Any clues about what i'm doing wrong?
Thanks and best regards!
The issue may be you didn't specify chatlogs css class, you should add it as below:
<style type="text/css">
.chatlogs {
height: 210px !important;
max-height: 210px !important;
overflow-y: scroll !important;
overflow-x: hidden !important;
}
</style>
And if you would like to scroll to bottom, you can try:
chatContent.scrollTop(chatContent[0].scrollHeight);