Primefaces h:panelgrid inside a p:tabView or p:outputpanel - jsf-2

I am working with a h:panelgrid in a p:tabView, but the components in the panelgrid are more smaller than components(inputtext, buttons, the font size) that are outside of him.
The code is :
<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">
<p:panel header="Datos Generales de Proyecto" />
<h:panelGrid id="idPgProyecto" columns="4" width="100%" border="0" columnClasses="colC1-T,colC2-T,colC3">
<p:outputLabel for="idEmpresa" value="Empresa:" style="margin-right:2px;" />
<p:inputText id="idEmpresa" style="width:350px;" value="#{proyectoBean.prVista.strEmpresa}"
readonly="true"/>
<h:outputText value="   " />
<h:outputText value="   " />
<p:outputLabel for="idCodProyecto" value="Codigo: " style="margin-right:2px;"/>
<p:inputText id="idCodProyecto" value="#{proyectoBean.prVista.codigo}" style="width:350px;" />
<p:message for="idCodProyecto" display="text" />
<h:outputText value="   " />
</h:panelGrid>
<h:panelGrid id="idPgPr1" columns="5" width="100%" border="0" columnClasses="colC1-T,colC2-T,colC3,colC1-T">
<p:outputLabel for="idNombre" value="Nombre: " style="margin-right:2px;"/>
<p:inputText id="idNombre" value="#{proyectoBean.prVista.nombre}" style="width:350px;"
required="true" requiredMessage="Ingrese Nombre"/>
<p:message for="idNombre" display="icon" />
<p:outputLabel for="idFechaInicio" value="Fecha Inicio: " style="margin-right:10px;"/>
<p:calendar id="idFechaInicio" value="#{proyectoBean.prVista.fechaInicio}" showOn="button" pattern="dd-MM-yyyy"
navigator="true">
</p:calendar>
</h:panelGrid>
<p:outputPanel rendered="#{proyectoBean.prVista.id != null and proyectoBean.prVista.strEstadoProyecto == 'INC'}">
<h:panelGrid id="idPgProyecto5" columns="3" width="100%" border="0" columnClasses="colC1-T,colC2-T">
<h:outputText value="   " />
<p:commandButton value="Cerrar Proyecto" style="width: 360px; color: blue;" actionListener="#{proyectoBean.cerrarProyecto}" update="idFormProyecto">
<p:confirm header="Confirmacion de Cierre de Proyecto" message="¿Esta seguro de cerrar Proyecto?" icon="ui-icon-alert" />
</p:commandButton>
<h:outputText value="   " />
</h:panelGrid>
</p:outputPanel>
<p:tabView >
<p:tab title="Maquinas Perforacion" >
<h:outputText value="Este es un texto de prueba"/>
<h:panelGrid id="idPgMaquina" columns="5" width="100%" border="0" columnClasses="colC1-T,colC2-T,colC3,colC1-T">
<p:outputLabel for="idSlcMaquina" value="Asignar Maquina:" style="margin-right:2px;font-size: 12px;"/>
<p:selectOneMenu id="idSlcMaquina" style="width:358px;" effect="none" value="#{proyectoBean.pu.idMaquina}"
disabled="#{proyectoBean.prVista.id == null}">
<f:selectItem itemLabel=" ---- Seleccione Maquina ---- " itemValue="#{null}" noSelectionOption="true"/>
<f:selectItems value="#{proyectoBean.pu.lstMaquinas}" var="m" itemValue="#{m.id}" itemLabel="#{m.nombre}"/>
</p:selectOneMenu>
<p:commandButton id="idBtnASignar" actionListener="#{proyectoBean.asignarMaquinaProyecto}"
update="idPgMaquina,idDTMaquinasProyecto" title="Agregar Maquina a lista" icon="ui-icon-plus"/>
<h:outputText value="   " />
<h:outputText value="   " />
</h:panelGrid>
</p:tab>
<p:tab title="Empleados" >
<h:panelGrid columns="3" width="100%" columnClasses="colC1-T,colC2-T" border="0">
<p:outputLabel value="Empleado:" for="idAutoCompleteEmpleado" style="margin-right:2px;"/>
<p:autoComplete id="idAutoCompleteEmpleado" value="#{proyectoBean.pu.empleado}" completeMethod="#{proyectoBean.completarEmpleado}"
var="empleado" itemLabel="#{empleado.nombreCompleto}" itemValue="#{empleado}" converter="empleadoPRConverter"
minQueryLength="2" onclick="this.select();" forceSelection="true" size="65" disabled="#{proyectoBean.prVista.id == null}">
<p:ajax event="itemSelect" listener="#{proyectoBean.seleccionarEmpleado}" update="idDTEmpleadoProyecto"/>
</p:autoComplete>
<p:message for="idAutoCompleteEmpleado" display="text"/>
</h:panelGrid>
</p:tab>
</p:tabView>
</ui:composition>
The panelgrid inside a outputpanel or tabview has the components more smaller that the others panelgrid that are outside. I'm working with PF 4.0 and JSF 2.2
Thanks for all

Seems like this is because it scales based on width. In tabview width of panelgrid is much smaller, than outside.
In this case, I would suggest to create css styles for each component and apply them, rather then making them stretch automatically

Related

preRenderView-Event triggered before an action

I am in a little bit of trouble with my preRenderView-Event. My page also uses a commandbutton to submit data but unfortunately the preRenderView-Event is always called before the buttons action is invoked.
<h:body style="width:600px; ">
<ui:composition template="/common/master-layout.xhtml">
<ui:define name="title">#{message['app.page.main.title']}</ui:define>
<ui:debug
rendered="#{initParam['javax.faces.PROJECT_STAGE'] eq 'Development'}"
hotkey="x" />
<ui:define name="metadata">
<f:metadata>
<f:viewParam name="id" value="#{saisieDevisController.idDemande}" />
<f:event type="preRenderView"
listener="#{saisieDevisController.init}" />
</f:metadata>
</ui:define>
<ui:define name="content">
<p:fieldset legend="Programme" style="margin-top: 20px;">
<h:form id="etudeDemSaisieDevisForm">
<p:tabView id="etudeDemSaisieDevisTabView">
<p:tab id="programmeTab" title="Programme">
<h:panelGrid columns="4" cellpadding="10">
<h:outputText id="programmeInput" value="Programme"
style="font-weight:bold" />
<h:outputText for="programmeInput"
value="#{saisieDevisController.selectedDemande.idProgramme.codeProgImmobilier}" />
<h:outputText id="lotInput" value="Lot" style="font-weight:bold" />
<h:outputText for="lotInput"
value="#{saisieDevisController.selectedDemande.idBien.numLotCommercial}" />
<h:outputText id="nomAcqInput" value="Nom Acquereur"
style="font-weight:bold" />
<h:outputText for="nomAcqInput"
value="#{saisieDevisController.selectedDemande.idAcquereur.genreEtatCivil} #{saisieDevisController.selectedDemande.idAcquereur.prenomAcquereur} #{saisieDevisController.selectedDemande.idAcquereur.nomAcquereur}" />
</h:panelGrid>
</p:tab>
<p:tab id="datesFraisTab" title="Dates et frais">
<h:panelGrid columns="4" cellpadding="10">
<h:outputLabel value="Date de valité de devis"
style="font-weight:bold" />
<p:calendar
value="#{saisieDevisController.selectedDemande.lastDevis.datValidite}"
id="dateValiditeDevis" showOn="button" required="true">
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:calendar>
<h:outputLabel value="Date butoire de chantier"
style="font-weight:bold" />
<p:calendar
value="#{saisieDevisController.selectedDemande.lastDevis.dateButoire}"
id="dateButoireDevis" showOn="button" required="true">
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:calendar>
<h:outputText value="Frais de dossier" style="font-weight:bold" />
<p:selectOneMenu
value="#{saisieDevisController.selectedDemande.lastDevis.fraDossiers}"
style="width: 175px;">
<f:selectItem itemLabel="Choisir..." itemValue=""
noSelectionOption="true" />
<f:selectItem itemLabel="Aucun" itemValue="Aucun" />
<f:selectItem itemLabel="Déjà réglé" itemValue="Déjà réglé" />
<f:selectItem itemLabel="Charge Acquéreur"
itemValue="Charge Acquéreur" />
<f:selectItem itemLabel="Charge SNC" itemValue="Charge SNC" />
</p:selectOneMenu>
<h:outputLabel value="Date de plan de référence"
style="font-weight:bold" />
<p:calendar
value="#{saisieDevisController.selectedDemande.lastDevis.datPlanReference}"
id="datePlanRef" showOn="button" required="true">
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:calendar>
<h:outputText value="Frais de pilotage" style="font-weight:bold" />
<p:selectOneMenu
value="#{saisieDevisController.selectedDemande.lastDevis.fraPilotage}"
style="width: 175px;">
<f:selectItem itemLabel="Choisir..." itemValue=""
noSelectionOption="true" />
<f:selectItem itemLabel="Oui" itemValue="Oui" />
<f:selectItem itemLabel="Non" itemValue="Non" />
<f:selectItem itemLabel="Pour mémoire" itemValue="Pour mémoire" />
</p:selectOneMenu>
<h:outputText value="Frais de plan" style="font-weight:bold" />
<p:selectOneMenu
value="#{saisieDevisController.selectedDemande.lastDevis.fraPlan}"
style="width: 175px;">
<f:selectItem itemLabel="Choisir..." itemValue=""
noSelectionOption="true" />
<f:selectItem itemLabel="Aucun" itemValue="Aucun" />
<f:selectItem itemLabel="Charge Acquéreur"
itemValue="Charge Acquéreur" />
<f:selectItem itemLabel="Charge SNC" itemValue="Charge SNC" />
</p:selectOneMenu>
</h:panelGrid>
</p:tab>
<p:tab id="devisTab" title="Devis">
<h:panelGrid columns="2" cellpadding="10">
<h:panelGrid columns="4" cellpadding="10">
<h:outputText id="numDevis" value="Numéro de devis"
style="font-weight:bold" />
<h:inputText for="numDevis"
value="#{saisieDevisController.selectedDemande.lastDevis.numDevis}" />
<h:outputText id="dateRecepDemande"
value="Date de la réception de la demande"
style="font-weight:bold" />
<h:outputText for="dateRecepDemande"
value="#{saisieDevisController.selectedDemande.dateDemande}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
<h:outputText id="dateSaisieDevis"
value="Date de saisie de la demande" style="font-weight:bold" />
<h:outputText for="dateSaisieDevis"
value="#{saisieDevisController.selectedDemande.dateSaisie}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
<h:outputText id="ficheOptionDevis" value="Fiche d'oprion"
style="font-weight:bold" />
<h:outputText for="ficheOptionDevis"
value="#{saisieDevisController.selectedDemande.ficheOption}" />
</h:panelGrid>
</h:panelGrid>
</p:tab>
<p:tab id="previsualisationTab" title="Prévisualisation">
<h:panelGrid columns="2" cellpadding="10">
</h:panelGrid>
</p:tab>
</p:tabView>
<p:panel>
<ui:include src="ligneDataTable.xhtml" />
</p:panel>
<h:panelGrid columns="4" cellpadding="10"
style="text-align: center;margin-left: 25%;width: 50%; margin-right: 25%; margin-top: 30px; background-color:RGB(225,240,233)">
<h:outputText id="chargeSncHt" value="Charge SNC HT"
style="font-weight:bold" />
<h:outputText for="chargeSncHt"
value="#{saisieDevisController.selectedDemande.idDemande}" />
<h:outputText id="chargeAcqHt" value="Charge Acq HT"
style="font-weight:bold" />
<h:outputText for="chargeAcqHt" value="200" />
<h:outputText id="chargeSncTtc" value="Charge SNC TTC"
style="font-weight:bold" />
<h:outputText for="chargeSncTtc" value="0" />
<h:outputText id="chargeAcqTtc" value="Charge ACQ TTC"
style="font-weight:bold" />
<h:outputText for="chargeAcqTtc" value="0" />
</h:panelGrid>
<h:panelGrid columns="3" cellpadding="10" style="margin: 0 auto;">
<p:commandButton value="Valider" id="saveDemande"
styleClass="ui-priority-primary"
action="#{saisieDevisController.updateValidate}"
style="margin-left:10px;margin-top:10px;margin-bottom:10px;height:125%;width:90px">
</p:commandButton>
<p:commandButton value="Annuler" id="cancelDemande"
styleClass="ui-priority-primary"
action="#{saisieDevisController.updateCancel}"
style="margin-left:10px;margin-top:10px;margin-bottom:10px;height:125%;width:90px"
immediate="true" />
<p:commandButton value="Suspendre" id="suspendDemande"
styleClass="ui-priority-primary"
action="#{saisieDevisController.updateSuspend}"
style="margin-left:10px;margin-top:10px;margin-bottom:10px;height:125%;width:90px">
</p:commandButton>
</h:panelGrid>
</h:form>
</p:fieldset>
</ui:define>
</ui:composition>
Controller:
#Component
#Scope("view")
public class SaisieDevisController implements Serializable {
//...
#ManagedProperty("#{demandeController.selectedDemande}")
private DemandeDto selectedDemande;
private Long idDemande;
//...
public String init(){
if (!FacesContext.getCurrentInstance().isPostback()) {
selectedDemande = new DemandeDto();
selectedDemande.setIdBien(new BienDto());
listDescriptifs = new ArrayList<DescriptifDto>();
selectedDecriptif = new DescriptifDto();
actualize();
}
return null;
}
public String initLigne(){
ligneToSave = new LigneDto();
listLots = new ArrayList<LotDto>();
listLots = lotService.findAll();
listSituations = new ArrayList<SituationDto>();
listSituations = situationService.findAll();
listUnites = new ArrayList<UniteDto>();
listUnites = uniteService.findAll();
return "/views/demande/saisieDevis/addLigne?faces-redirect=true";
}
public void actualize(){
selectedDemande = saisieDevisService.findById(idDemande);
selectedDemande.setLastDevis(selectedDemande.getLastDevis());
}
With the JSF Lifecycle in mind, it is not really possible to have an preRenderView-Event being triggered before the "Invoke application" phase is finished. Please double-check the following:
Is the action invoked at all? In case of an converter/validation error the "invoke action" phase is skipped and the response is rendered instantly.
Are you calling the method from somewhere else? saisieDevisController.init sounds pretty generic. Maybe a trigger like #PostConstruct calls it earlier (nested).
Hope it helps...

update entity attribute through primefaces modal

Try to load and update attributes from a datatable to a form embedded in a primefaces modal box:
1) The datatable command to send user's data to the modal
<p:commandButton value="alterar"
action="#{usuarioMB.carregarAlteracao(u)}" update=":usuarioDesc"
process="#this" onclick="dlg.show();" />
2) It loads well the user's attributes in the modal box
<p:dialog id="modalDialog" header="Alterar Usuário" widgetVar="dlg"
modal="true" height="260" appendToBody="true" dynamic="true" >
<h:form id="usuarioDesc" styleClass="formTamanho">
<h:panelGrid id="#{msg.pnlIdProfile}" columns="2"
columnClasses="labelPanelGrid, contentPanelgrid">
<p:outputLabel value="Perfil:" />
<p:outputLabel value="#{usuarioMB.usuario.perfil.nome}" />
</h:panelGrid>
<h:panelGrid id="#{msg.pnlIdLogin}" columns="2"
columnClasses="labelPanelGrid, contentPanelgrid">
<p:outputLabel value="#{msg.lblLogin}" for="usuario_login" />
<p:inputText value="#{usuarioMB.usuario.login}" id="usuario_login"
required="true" requiredMessage="#{msg.msgReqLogin}" />
</h:panelGrid>
<h:panelGrid id="nomeUsuario" columns="2"
columnClasses="labelPanelGrid, contentPanelgrid">
<p:outputLabel value="Nome:" for="usuario_nome" />
<p:inputText value="#{usuarioMB.usuario.nome}" id="usuario_nome"
required="true" />
</h:panelGrid>
<h:panelGrid id="emailUsuario" columns="2"
columnClasses="labelPanelGrid, contentPanelgrid">
<p:outputLabel value="Email:" for="usuario_email" />
<p:inputText value="#{usuarioMB.usuario.email}" id="usuario_email"
required="false" />
</h:panelGrid>
<h:panelGrid id="#{msg.pnlIdCal}" columns="3"
columnClasses="labelPanelGrid, contentPanelgrid">
<p:outputLabel value="#{msg.lblBirth}" for="#{msg.calId}" />
<p:calendar value="#{usuarioMB.usuario.nascimento}"
id="#{msg.calId}" locale="#{msg.calLocale}" showButtonPanel="true"
navigator="true" />
<p:outputLabel value="(Ex: 16-04-1980)" />
</h:panelGrid>
<br />
<div id="btnForms" style="margin-left: 120px;">
<p:commandButton value="Alterar Usuário" id="alt_usuario"
action="#{usuarioMB.alterar()}" update=":usuarioDataTable:tableUsuarios"
process="#this" style="margin-left:5px;" oncomplete="dlg.hide();"/>
<p:commandButton value="Criar nova senha e mandar por email"
id="alt_senha"
action="#{usuarioMB.sendEmail(usuario.email)}"
process="#this"
style="margin-left:5px;" />
<p:commandButton value="Cancelar" onclick="dlg.hide();"
style="margin-left:5px;" />
</div>
</h:form>
</p:dialog>
3) When i modify the attribute through the fields in the modal, then use the command action "alterar" , then the managed bean still keeps the reference to the user's original datas, and no update happens.
public String alterar() {
try {
gerenciarUsuarioBean.alterar(usuario);
JSFMessageUtil.sendInfoMessageToUser("Usuário salvado com sucesso!");
} catch (DaoExcecao e) {
LOG.error(e);
JSFMessageUtil.sendErrorMessageToUser("Erro cadastrando usuário !");
}
usuario = new Usuario();
return "/views/gerencia/gerenciarUsuarios.xhtml";
}
In a nutshell, the user's attributes are auto merged in the database. Any help is welcome..
Ok, then there was a bit of confusion in the command buttons (process / update)
1) datatable cmd:
<p:commandButton value="alterar"
action="#{usuarioMB.carregarAlteracao(u)}" update=":usuarioDesc:usr"
process="#this" onclick="dlg.show();" />
2) Update button
<p:commandButton value="Alterar Usuário" id="alt_usuario"
action="#{usuarioMB.alterar()}"
update=":usuarioDataTable:tableUsuarios" process="#form"
style="margin-left:5px;" oncomplete="dlg.hide();" />
Hope it helps someone.

Clearing form fields after invalidation JSF

Ok i have the following problem: In my web app i have the CRUD all one page via dialogs controls of Primefaces. In the new dialog i have some validators. For example: when a user does not fill the necessary fields for form submission obviously the form doesn't submit. But when i close de New dialog and open it up again, the validation messages are still there! How can i get rid of this? I want a fresh new page (without accumulated validation errors) every time a dialogs open up! How that can be done?
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="./../../resources/templates/baseTemplate.xhtml">
<ui:define name="content">
<f:view id="vRoot">
<p:fieldset legend="Gerenciar público">
<h:form id="frmPublicos">
<!-- Exibição de mensagens gerais -->
<p:growl id="gMessages" sticky="false" globalOnly="true" />
<!-- Exibição da lista de públicos -->
<p:dataTable id="dtPublicos"
value="#{publicoBean.lstDataTablePublico}"
paginator="true" rows="5"
rowsPerPageTemplate="5,10"
paginatorPosition="bottom"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
var="atual">
<!-- Every time dialog opens validation messages should be cleaned -->
<f:facet name="header">
<p:commandButton id="cbViewNovo"
value="Novo" type="button"
styleClass="cbViewNovo"
onclick="dlgNovo.show();"
update=":dlgNovoPublico"
process="#this">
<p:resetInput target=":dlgNovoPublico"/>
</p:commandButton>
</f:facet>
<!-- Colunas de edição e exclusão -->
<p:column>
<f:facet name="header">
<h:outputLabel value="Editar"/>
</f:facet>
<p:commandButton id="cbViewEditar"
image="ui-icon-pencil"
title="Editar"
update=":frmEditar:pEditarPublico"
oncomplete="dlgEditar.show();">
<f:setPropertyActionListener value="#{atual}" target="#{publicoBean.publicoSelecionado}" />
</p:commandButton>
</p:column>
<p:column>
<f:facet name="header">
<h:outputLabel value="Excluir"/>
</f:facet>
<p:commandButton id="cbViewExcluir" onclick="dlgExcluir.show();"
icon="ui-icon-close" title="Excluir">
<f:setPropertyActionListener value="#{atual}" target="#{publicoBean.publicoSelecionado}" />
</p:commandButton>
</p:column>
<p:column>
<f:facet name="header">
Nome
</f:facet>
<h:outputLabel id="olViewNomePublico" value="#{atual.nmePublico}"/>
</p:column>
<p:column>
<f:facet name="header">
Tipo de público
</f:facet>
<h:outputLabel id="olViewTipoPublico" value="#{atual.tdTipoPublico}"/>
</p:column>
</p:dataTable>
</h:form>
<!-- Caixa de diálogo de inclusão -->
<p:dialog id="dlgNovoPublico"
widgetVar="dlgNovo"
modal="true"
header="Novo público"
resizable="false">
<h:form id="frmNovo">
<p:panel id="pNovoPublico">
<p:messages id="mNovoMessages" redisplay="false" />
<p:panelGrid columns="2">
<p:outputLabel id="olNovoNomePublico" value="Nome:" for="itNovoNomePublico"/>
<p:inputText id="itNovoNomePublico" value="#{publicoBean.nome}" required="true"
requiredMessage="Digite o nome do público."/>
<p:outputLabel id="olNovoTipoPublico" for="somNovoTipoPublico" value="Tipo de público:"/>
<p:selectOneMenu id="somNovoTipoPublico"
value="#{publicoBean.tipoPublicoSelecionado}"
effect="fade"
converter="#{publicoBean.conversor}"
required="true"
requiredMessage="Selecione um tipo de público."
>
<f:selectItem itemLabel="Selecione um item..." itemValue=""/>
<f:selectItems value="#{publicoBean.lstMenuTipoPublico}" var="atual" itemLabel="#{atual.label}" itemValue="#{atual}"></f:selectItems>
</p:selectOneMenu>
<p:commandButton value="Cancelar" immediate="true" onclick="dlgNovo.hide()"/>
<p:commandButton id="cbNovoSalvar" value="Salvar"
actionListener="#{publicoBean.cadastrarPublico}"
oncomplete="handleSalvo(xhr, status, args);"
update=":frmPublicos:dtPublicos :frmNovo :frmPublicos:gMessages"
ajax="true"/>
</p:panelGrid>
</p:panel>
</h:form>
</p:dialog>
<!-- Caixa de diálogo de exclusão -->
<p:confirmDialog id="dialogoExcluir" message="Deseja realmente excluir?"
header="Excluir público" severity="alert"
widgetVar="dlgExcluir">
<h:form id="frmExcluir">
<p:commandButton id="cbExcluirCancelar" value="Cancelar" onclick="dlgExcluir.hide()" type="button" />
<p:commandButton id="cbExcluirContinuar" value="Continuar"
update=":frmPublicos:dtPublicos :frmPublicos:gMessages"
oncomplete="dlgExcluir.hide()"
actionListener="#{publicoBean.excluirPublico}"/>
</h:form>
</p:confirmDialog>
<!-- Caixa de diálogo de edição -->
<p:dialog id="dialogoEditar" widgetVar="dlgEditar" header="Editar público"
resizable="false" modal="true">
<h:form id="frmEditar">
<p:panel id="pEditarPublico">
<p:messages id="mEditarMessages" redisplay="false" />
<p:panelGrid columns="2">
<p:outputLabel id="olEditarNomePublico" value="Nome:" for="itEditarNomePublico"/>
<p:inputText id="itEditarNomePublico" value="#{publicoBean.publicoSelecionado.nmePublico}" required="true"
requiredMessage="Digite o nome do público."/>
<p:outputLabel id="olEditarTipoPublico" for="somEditarTipoPublico" value="Tipo de público:"/>
<p:selectOneMenu id="somEditarTipoPublico"
value="#{publicoBean.publicoSelecionado.tdTipoPublico}"
effect="fade"
converter="#{publicoBean.conversor}"
required="true"
requiredMessage="Selecione um tipo de público."
>
<f:selectItem itemLabel="Selecione um item..." itemValue=""/>
<f:selectItems value="#{publicoBean.lstMenuTipoPublico}"
var="atual"
itemLabel="#{atual.label}"
itemValue="#{atual}"></f:selectItems>
</p:selectOneMenu>
<p:commandButton value="Cancelar" immediate="true" onclick="dlgEditar.hide()"/>
<p:commandButton id="cbEditarSalvar" value="Salvar"
actionListener="#{publicoBean.alterarPublico}"
oncomplete="dlgEditar.hide();"
update=":frmPublicos:dtPublicos :frmEditar :frmPublicos:gMessages"/>
</p:panelGrid>
</p:panel>
</h:form>
</p:dialog>
</p:fieldset>
</f:view>
<!-- Javascript responsável por fechar a caixa de diálogo ao cadastrar-->
<script type="text/javascript">
function handleSalvo(xhr, status, args){
if(args.salvo){
dlgNovo.hide();
}
}
function handleEditar(xhr, status, args){
if(args.salvo){
dlgEditar.hide();
}
}
</script>
</ui:define>
Try p:resetInput. http://www.primefaces.org/showcase-labs/ui/resetInput.jsf
Try with pe:resetInput from Primefaces Extensions: http://fractalsoft.net/primeext-showcase-mojarra/sections/resetInput/formElements.jsf
<p:commandButton id="cbViewNovo"
value="Novo" type="button"
styleClass="cbViewNovo"
onclick="dlgNovo.show();"
update=":dlgNovoPublico"
process="#this">
<pe:resetInput target=":dlgNovoPublico"/>
</p:commandButton>

Primefaces poll not updating panel

I can't figure out why my primefaces poll will not update any components.
<p:poll widgetVar="poll"
interval="#{messageBean.refreshInterval}"
listener="#{messageBean.refreshLiveData}"
update=":transactionLogForm:tabViewMain:liveViewPanel"/>
The refreshLiveData method gets called successfully but it refuses to update the outputText component (or any component for that matter).
<p:tab id="liveViewTab" title="Live View">
<h:panelGrid id="liveViewPanel" columns="6" cellpadding="5">
<h:outputText value="Live View Enabled: " />
<p:selectBooleanCheckbox value="#{messageBean.liveViewActive}">
</p:selectBooleanCheckbox>
<h:outputText value="Interval: " />
<p:spinner id="interval" value="#{transactionLogBean.refreshInterval}" />
<h:outputText value="Last Update:" />
<h:outputText id="lastUpdated" value="#{transactionLogBean.lastUpdated}" />
</h:panelGrid>
</p:tab>
Here is the full code from within the body tags:
<p:layout id="mainLayout" fullPage="true" style="height:100%" >
<h:form id="transactionLogForm">
<p:poll widgetVar="poll"
interval="#{messageBean.refreshInterval}"
listener="#{messageBean.refreshLiveData}"
update=":transactionLogForm:tabViewGrids:messageTable :transactionLogForm:tabViewGrids:timestatTable :transactionLogForm:tabViewMain:liveViewPanel"/>
<p:layoutUnit id="topHeader" position="north" size="178" >
<ui:include src="inc_menu.xhtml" />
</p:layoutUnit>
<p:layoutUnit id="center" position="center" >
<div>
<p style="font-size: 20px; font-weight: bold; padding: 0px 0px 0px 10px">Transaction Logs</p>
</div>
<p:tabView id="tabViewMain" orientation="top">
<p:tab title="Reference No">
<h:panelGrid columns="2" cellpadding="5">
<p:inputTextarea id="referenceNo" rows="1" cols="100" value="#{transactionBean.referenceNo}" style="width:300px"/>
<p:commandButton id="refreshBtnMain0" value="Search" action="#{transactionBean.searchTranLogDetails(true)}"
update=":transactionLogForm:transactionSearchTable" ajax="true"
oncomplete="txnDialog.show()"
style="vertical-align: baseline"/>
</h:panelGrid>
</p:tab>
<p:tab title="Log Id">
<h:panelGrid columns="2" cellpadding="5">
<p:inputText id="logID" value="#{transactionLogBean.logID}" style="width:300px"/>
<p:commandButton id="refreshBtnMain1" value="Refresh" action="#{transactionLogBean.refreshData}" update=":transactionLogForm:tabViewGrids:messageTable :transactionLogForm:tabViewGrids:timestatTable" ajax="true" />
</h:panelGrid>
</p:tab>
<p:tab title="Date Range">
<h:panelGrid columns="5" cellpadding="5">
<h:outputText value="Start Date:" />
<p:calendar id="StartDate" pattern="dd/MM/yyyy HH:mm:ss" navigator="true" value="#{transactionLogBean.startDate}" />
<h:outputText value="End Date:" />
<p:calendar id="EndDate" pattern="dd/MM/yyyy HH:mm:ss" navigator="true" value="#{transactionLogBean.endDate}" />
<p:commandButton id="refreshBtnMain2" value="Refresh" action="#{transactionLogBean.refreshData}" update=":transactionLogForm:tabViewGrids:messageTable :transactionLogForm:tabViewGrids:timestatTable" ajax="true" />
</h:panelGrid>
</p:tab>
<p:tab id="liveViewTab" title="Live View">
<h:panelGrid id="liveViewPanel" columns="6" cellpadding="5">
<h:outputText value="Live View Enabled: " />
<p:selectBooleanCheckbox value="#{messageBean.liveViewActive}">
</p:selectBooleanCheckbox>
<h:outputText value="Interval: " />
<p:spinner id="interval" value="#{transactionLogBean.refreshInterval}" />
<h:outputText value="Last Update:" />
<h:outputText id="lastUpdated" value="#{transactionLogBean.lastUpdated}" />
</h:panelGrid>
</p:tab>
</p:tabView>
<p:tabView id="tabViewGrids">
<p:tab title="Message Logs">
<ui:include src="inc_messagelogs.xhtml" />
</p:tab>
<p:tab title="Timestat Logs">
<ui:include src="inc_timestatlogs.xhtml" />
</p:tab>
</p:tabView>
<p:dialog header="Log Message" widgetVar="logDialog" id="logDlg" showEffect="fade">
<h:outputText id="msg" value="#{transactionLogBean.selectedLogMessage}"/>
</p:dialog>
<p:dialog header="Transaction Search Results" widgetVar="txnDialog" resizable="false" id="tranDlg"
showEffect="fade" modal="false" position="center">
<p:dataTable id="transactionSearchTable" value="#{transactionBean.tranlogList}"
var="t" widgetVar="tranSearchTable" rowKey="#{t.transactionId}"
selectionMode="single" selection="#{transactionBean.selectedTranlog}"
paginator="true" rows="10" style="font-size:14px"
rowStyleClass="#{t.rowColour}">
<p:ajax event="rowSelect" update=":transactionLogForm:tabViewGrids:messageTable :transactionLogForm:tabViewGrids:timestatTable"
listener="#{transactionLogBean.refreshData(transactionBean.selectedTranlog.logId)}"
oncomplete="txnDialog.hide()" global="false"/>
<p:column style="text-align: left">
<f:facet name="header">
Tran Id
</f:facet>
#{t.transactionId}
</p:column>
<p:column style="text-align: left" sortBy="#{t.dateCreated}">
<f:facet name="header">
Date/Time
</f:facet>
#{t.dateCreated}
</p:column>
<p:column style="text-align: left" sortBy="#{t.transactionType}">
<f:facet name="header">
Tran Type
</f:facet>
#{t.transactionType}
</p:column>
<p:column style="text-align: left">
<f:facet name="header">
Amount
</f:facet>
#{t.amount}
</p:column>
<p:column style="text-align: left">
<f:facet name="header">
Result
</f:facet>
#{t.externalMessageCode}
</p:column>
</p:dataTable>
</p:dialog>
</p:layoutUnit>
</h:form>
</p:layout>
I'm not getting any errors reported, so all the references must be ok - please help!!!
I'm using JSF 2.0, Primefaces 3.4.RC1
Extract from generated html:
<div id="transactionLogForm:tabViewMain:liveViewTab" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-helper-hidden" role="tabpanel" aria-hidden="true"><table id="transactionLogForm:tabViewMain:liveViewPanel" cellpadding="5">
<tbody>
<tr>
<td>Live View Enabled: </td>
<td><div id="transactionLogForm:tabViewMain:j_idt27" class="ui-chkbox ui-widget"><div class="ui-helper-hidden-accessible"><input id="transactionLogForm:tabViewMain:j_idt27_input" name="transactionLogForm:tabViewMain:j_idt27_input" type="checkbox" /></div><div class="ui-chkbox-box ui-widget ui-corner-all ui-state-default"><span class="ui-chkbox-icon"></span></div></div><script id="transactionLogForm:tabViewMain:j_idt27_s" type="text/javascript">PrimeFaces.cw('SelectBooleanCheckbox','widget_transactionLogForm_tabViewMain_j_idt27',{id:'transactionLogForm:tabViewMain:j_idt27'});</script></td>
<td>Interval: </td>
<td><span id="transactionLogForm:tabViewMain:interval" class="ui-spinner ui-widget ui-corner-all"><input id="transactionLogForm:tabViewMain:interval_input" name="transactionLogForm:tabViewMain:interval_input" type="text" class="ui-spinner-input ui-inputfield ui-state-default ui-corner-all" autocomplete="off" value="10" /><a class="ui-spinner-button ui-spinner-up ui-corner-tr ui-button ui-widget ui-state-default ui-button-text-only"><span class="ui-button-text"><span class="ui-icon ui-icon-triangle-1-n"></span></span></a><a class="ui-spinner-button ui-spinner-down ui-corner-br ui-button ui-widget ui-state-default ui-button-text-only"><span class="ui-button-text"><span class="ui-icon ui-icon-triangle-1-s"></span></span></a></span><script id="transactionLogForm:tabViewMain:interval_s" type="text/javascript">$(function(){PrimeFaces.cw('Spinner','widget_transactionLogForm_tabViewMain_interval',{id:'transactionLogForm:tabViewMain:interval',step:1.0});});</script></td>
<td>Last Update:</td>
<td><span id="transactionLogForm:tabViewMain:lastUpdated"></span></td>
</tr>
</tbody>
</table>
</div>
Problem solved - it was a backing bean issue after all and had nothing to do with the poll itself which was working fine.

Problems with control of primefaces components by Managed Bean

I hope somebody could help me with the trouble I am having with JSF 2 and Primefaces 3.0M3.
the problem is that the back bean methods do not fired from any component in the layoutunit 'center' they are inside a form and nothing happens, even I tried to update the components with remoteCommand, autoUpdate of the outputpanel, commandButton with action and actionListener and nothing, there is no error message. In the layoutunit west works the components well, renders the outputpanel (pfpInfo) of the center layoutunit but I do not know what is happening.
here is the code
<!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.prime.com.tr/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<title>Articulos</title>
</h:head>
<h:body>
<link rel="stylesheet" type="text/css" href="../css/estilos.css" />
<p:layout fullPage="true" id="lay">
<p:layoutUnit position="north" size="100" resizable="false"
closable="false" collapsible="false">
<img src="../images/logo.jpg" alt="PLL"
style="width: 413px; height: 83px;" align="left"></img>ss
<img src="../images/tel.jpg" alt="PLR"
style="width: 413px; height: 83px;" align="right"></img>
</p:layoutUnit>
<p:layoutUnit position="west" size="200" header="Categorías"
resizable="false" closable="false" collapsible="false">
<h:form id="frWest">
<p:growl id="message" showDetail="true" globalOnly="true"
autoUpdate="true"></p:growl>
<p:tree id="treeSingle" value="#{controlMBean.raizArbol}"
var="rama" dynamic="true" selectionMode="single"
selection="#{controlMBean.ramaElegida}" expanded="true">
<p:ajax event="select"
update=":frCenter:pfSeg :frCenter:pfpInfo :frCenter:pfpIma"
listener="#{controlMBean.procesaInformacionArt}"></p:ajax>
<p:treeNode>
<h:outputText value="#{rama}" styleClass="encabezadoUiLight" />
</p:treeNode>
</p:tree>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center">
<h:form id="frCenter">
<p:outputPanel id="pfSeg" rendered="true">
<p:outputPanel id="pfpIma" rendered="#{not controlMBean.cargado}">
<img src="../images/luchadores.jpg" />
</p:outputPanel>
<p:outputPanel id="pfpInfo" rendered="#{controlMBean.cargado}"
autoUpdate="true">
<p:dataTable dynamic="true" var="prnda" rowKey="#{prnda.id}"
value="#{controlMBean.infoArts}" paginator="true" rows="10"
selectionMode="single" paginatorAlwaysVisible="false"
selection="#{controlMBean.artElegido}"
rendered="#{controlMBean.cargado}">
<p:ajax event="rowUnselect"
listener="#{prestalana.deseleccionar}"></p:ajax>
<f:facet name="header">Articulo(s)</f:facet>
<p:ajax update=":frCenter:ppImg :frCenter:pgInfo"
oncomplete="prnd.show()" event="rowSelect"
listener="#{controlMBean.elegirFila}"></p:ajax>
<p:column sortBy="#{prnda.id}">
<f:facet name="header">
<h:outputText value="Id" />
</f:facet>
<h:outputText value="#{prnda.id}" />
</p:column>
<p:column sortBy="#{prnda.articulo}">
<f:facet name="header">
<h:outputText value="Modelo" />
</f:facet>
<h:outputText value="#{prnda.articulo}" />
</p:column>
<p:column sortBy="#{prnda.marca}">
<f:facet name="header">
<h:outputText value="Marca" />
</f:facet>
<h:outputText value="#{prnda.marca}" />
</p:column>
<p:column sortBy="#{prnda.edo}">
<f:facet name="header">
<h:outputText value="Ubicación" />
</f:facet>
<h:outputText value="#{prnda.edo}" />
</p:column>
<p:column sortBy="#{prnda.stsArticulo}">
<f:facet name="header">
<h:outputText value="Estatus" />
</f:facet>
<h:outputText value="#{prnda.stsArticulo} " />
</p:column>
<p:column sortBy="#{prnda.precio}">
<f:facet name="header">
<h:outputText value="Precio" />
</f:facet>
<h:outputText value="$ #{prnda.precio}" />
</p:column>
</p:dataTable>
<p:commandButton action="#{controlMBean.probar2}"
actionListener="#{controlMBean.probar}" value="Prueba"></p:commandButton>
</p:outputPanel>
<br />
<h:outputText value="#{controlMBean.mensaje}"
styleClass="textoUiLight" id="hotMen" />
</p:outputPanel>
<p:remoteCommand actionListener="#{controlMBean.probar}"
name="pruebaRc" update=":frCenter:ppImg"></p:remoteCommand>
<p:dialog appendToBody="true" dynamic="true" header="Info Prenda"
onShow="pruebaRc" widgetVar="prnd" resizable="false" width="750"
height="550" showEffect="fold" position="center"
hideEffect="explode">
<p:outputPanel id="ppImg" autoUpdate="true">
<h:panelGrid columns="2" id="pgInfo">
<p:galleria transitionInterval="3000" var="i"
value="#{controlMBean.imagenes}"
panelWidth="#{controlMBean.width}"
panelHeight="#{controlMBean.height}"
frameHeight="#{controlMBean.height/4}"
frameWidth="#{controlMBean.width/4}" effect="flash">
<p:graphicImage id="img" height="#{i.alto}" width="#{i.ancho}"
value="#{controlMBean.ruta}#{i.nombre}.jpg" />
</p:galleria>
<h:panelGrid columns="2" width="350">
<h:outputLabel value="ID:" styleClass="etiqueta" />
<h:outputText value="#{controlMBean.artElegido.id}"
styleClass="resultado" />
<h:outputLabel value="Prenda:" styleClass="etiqueta" />
<h:outputText
value="#{controlMBean.artElegido.prenda} adasd"
styleClass="resultado" />
<h:outputLabel value="Precio:" styleClass="etiqueta" />
<h:outputText value="$#{controlMBean.artElegido.precio}"
styleClass="resultado" />
<h:outputLabel value="Marca:" styleClass="etiqueta" />
<h:outputText value="#{controlMBean.artElegido.marca}"
styleClass="resultado" />
<h:outputLabel value="Sucursal:" styleClass="etiqueta" />
<h:outputText value="#{controlMBean.artElegido.suc}"
styleClass="resultado" />
<h:outputLabel value="Descripcion:" styleClass="etiqueta" />
<h:outputText value="#{controlMBean.artElegido.descr}"
styleClass="resultado" style="width:300px;height:100px;" />
</h:panelGrid>
</h:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</p:layoutUnit>
</p:layout>
</h:body>
</html>

Resources