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.
Related
I have a problem with PrimeFaces <p:confirmDialog>, when I click on the <p:commandLink> that must show up the dialog and choose 'No', everything is fine. But when I click on yes,everything works just the first time.
When the process is over and I click again on any <p:commandLink>, the dialog doesn't show up unless I refresh the whole page.I had try everything but I cannot figure out what can be the problem.
<h:form>
<p:dataTable border="0" rules="all" value="#{userBean.users}" var="user" autoUpdate="true" styleClass="table table-hover" paginator="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="6,10,15" >
<p:column>
<f:facet name="header">
<h:outputText value="Login" />
</f:facet>
<h:outputText value="#{user.login}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandLink class="badge bg-red marge-left" onclick='PF("cdu#{user.id}").show()' title="Supprimer un utilisateur"><span class="fa fa-trash-o"/></p:commandLink>
<p:confirmDialog ajax="true" message="Voulez vous vraiment supprimer l'utilisateur '#{user.login}'" closable="true" header="Confirmation" severity="alert" widgetVar="cdu#{user.id}" >
<p:commandButton value="oui" actionListener="#{userBean.deleteUser}" update="#form" onclick='PF("cdu#{user.id}").hide()' styleClass="btn btn-primary"/>
<p:commandButton value="non" onclick='PF("cdu#{user.id}").hide()' type="button" styleClass="btn btn-danger" />
</p:confirmDialog>
</p:column>
</p:dataTable>
</h:form>
I had finally resolved my problem. I changed the <p:confirmDialog> by a global one and it works.
<h:form>
<p:dataTable border="0" rules="all" value="#{userBean.users}" var="user" autoUpdate="true" styleClass="table table-hover">
<p:column>
<f:facet name="header">
<h:outputText value="Login" />
</f:facet>
<h:outputText value="#{user.login}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Nom" />
</f:facet>
<h:outputText value="#{user.firstName} #{user.lastName}" />
</p:column>
<p:column style="width:200px;">
<f:facet name="header">
<h:outputText value="Email" />
</f:facet>
<h:outputText value="#{user.email}" />
</p:column>
<p:column >
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandLink class="badge bg-blue marge-left" action="#{userBean.getUserRowToEdit}" title="Editer un utilisateur" ><span class="fa fa-edit"/></p:commandLink>
<p:commandLink class="glyphicon glyphicon-trash icon-trash" actionListener="#{userBean.deleteUser}" title="Supprimer un utilisateur" update="#form">
<p:confirm header="Confirmation" message="Voulez-vous vraiment supprimer l'utilisateur?" icon="ui-icon-alert"/>
</p:commandLink>
</p:column>
</p:dataTable>
<p:confirmDialog global="true">
<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>
</h:form>
I tried your code and repaired it a little. Hope it will work for you too.
-I removed ajax="true"
-usersBean.deleteUser function need to know which user to so -> deleteusersBean.deleteUser(user)
Under is my code that i use to test your case. A few things are changed due to existing beans i have. This code is tested on latest primefaces(5.2).
my xhtml file:
<p:column>
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<p:commandLink class="badge bg-red marge-left" value="delete" onclick='PF("cdu#{user.userId}").show()' title="Supprimer un utilisateur"><span class="fa fa-trash-o"/></p:commandLink>
<p:confirmDialog message="Voulez vous vraiment supprimer l'utilisateur '#{user.name}'" closable="true" header="Confirmation" severity="alert" widgetVar="cdu#{user.userId}" >
<p:commandButton value="oui" actionListener="#{loginBean.deleteUser(user)}" update="#form" onclick='PF("cdu#{user.userId}").hide()' styleClass="btn btn-primary"/>
<p:commandButton value="non" onclick='PF("cdu#{user.userId}").hide()' type="button" styleClass="btn btn-danger" />
</p:confirmDialog>
</p:column>
</p:dataTable>
</h:form>
my loginBean:
public class LoginBean implements Serializable {
private static final long serialVersionUID = 6188046073588310656L;
private List<User> users= new ArrayList<User>();
public LoginBean() {
}
public List<User> getUsers() {
if(users.size()==0){
for (int i= 0; i<3; i++){
User u = new User();
u.setUserId(i);
u.setName("noob"+i);
users.add(u);
}
}
return users;
}
public void deleteUser(User user){
users.remove(user);
}
}
I use jsf 2.2 and Primefaces 4.0 in my project. but I faced a problem . After Filter Primefaces Datatable. I want to show the filtered Row ditails in a dialog but after filter, Row ditails not show dialog box . Even Until Reload the page don't show Row Details in the dialog box . My Jsf Code Is ..........
<h:form id="Form_showRequest" style="font-size: 10pt;">
<input type="text" id="search" placeholder="Search now..."></input>
<p:growl id="MSG_grl" autoUpdate="false" showDetail="true"/>
<p:dataTable id="TBL_data" var="List_request" value="#{allRequestBean.requestDetailsList}" scrollable="true" widgetVar="reTab"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
scrollHeight=" 460" style="font-size: 10pt; font-family: serif;margin-bottom:0;">
<p:column headerText="Mobile No" style="width: 80px;" filterBy="#{List_request.mobileNumber}" >
#{List_request.mobileNumber}
</p:column>
<p:column headerText="User Name" style="width: 80px;">
#{List_request.userName}
</p:column>
<p:column headerText="Amount" style="width: 50px;">
#{List_request.rechargeAmount}
</p:column>
<p:column headerText="Cost" style="width: 50px;">
#{List_request.costAmount}
</p:column>
<p:column headerText="Service" style="width: 100px;">
#{List_request.serviceName}
</p:column>
<p:column headerText="Bank " style="width: 50px;">
#{List_request.bankName}
</p:column>
<p:column headerText="Bank Tran Id" style="width: 100px;">
#{List_request.bankTrankId}
</p:column>
<p:column headerText="Date Time" style="width: 150px;" >
#{List_request.rechargeDate}
</p:column>
<p:column headerText="Conformation Id" style="width: 100px;">
#{List_request.conformationId}
</p:column>
<p:column headerText="Status" style="width: 80px;">
<h:outputText value="#{List_request.rechargeStatusName}"/>
</p:column>
<p:column id="op" headerText="Option" style="width: 100px">
<p:commandButton id="but" value="Action" action="#{actionBean.allReRowDetails()}"
update=":Form_showRequest:PNL_action" style=" font-size: 10px" onclick="PF('widget_action').show();"
ajax="true" disabled="#{List_request.rechargeStatusId eq 4 or List_request.rechargeStatusId eq 5}">
<f:setPropertyActionListener value="#{List_request}" target="#{actionBean.allRequestBeanValue}"/>
</p:commandButton>
<p:commandLink id="requestDetails" value="Details" action="#{allRequestDetailsBean.rowDetails()}"
update=":Form_showRequest:PNL_request" oncomplete="PF('widget_request').show();" ajax="true" >
<f:setPropertyActionListener value="#{List_request}" target="#{allRequestDetailsBean.allRequestBeanValue}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:dialog id="Dialog_acton" header="Action" widgetVar="widget_action" modal="true">
<h:panelGrid id="PNL_action" style="margin-bottom:10px; width: 300px;" cellpadding="10">
<p:selectOneRadio id="action" columns="1" value="#{actionBean.actionType}">
<f:selectItem itemLabel="Resend" itemValue="1" />
<f:selectItem itemLabel="Complete" itemValue="4" />
<f:selectItem itemLabel="Cancel" itemValue="5" />
</p:selectOneRadio><br/>
<p:outputLabel value="Reason" style="width:20px; "/>
<p:inputTextarea value="#{actionBean.confirmId}" style="width: 250px" />
</h:panelGrid>
<p:commandButton value="Ok" action="#{actionBean.action()}" update="Form_showRequest:TBL_data,MSG_grl"
oncomplete="widget_action.hide()" style="width: 200px; margin-left: 50px;"/>
</p:dialog>
<p:dialog id="Dialog_request" header="Request Details Information" widgetVar="widget_request" showEffect="clip" hideEffect="fold" resizable="false" >
<p:panelGrid id="PNL_request" columns="2" style="width: 450px" >
<p:outputLabel value="Recharge Id :"/>
<p:outputLabel value=" #{allRequestDetailsBean.rechargeId}"/>
<p:outputLabel value="User Name:"/>
<p:outputLabel value=" #{allRequestDetailsBean.userName}"/>
<p:outputLabel value="Mobile Number :"/>
<p:outputLabel value=" #{allRequestDetailsBean.mobileNumber}"/>
<p:outputLabel value="Recharge Amount:"/>
<p:outputLabel value=" #{allRequestDetailsBean.rechargeAmount}"/>
<p:outputLabel value="Cost :"/>
<p:outputLabel value=" #{allRequestDetailsBean.costAmount}"/>
<p:outputLabel value="Number Type:"/>
<p:outputLabel value=" #{allRequestDetailsBean.numberType}"/>
<p:outputLabel value="Operator :"/>
<p:outputLabel value=" #{allRequestDetailsBean.operatorName}"/>
<p:outputLabel value="Service :"/>
<p:outputLabel value=" #{allRequestDetailsBean.serviceName}"/>
<p:outputLabel value="Bank Nmae:"/>
<p:outputLabel value=" #{allRequestDetailsBean.bankName}"/>
<p:outputLabel value="Bank Transaction Id:"/>
<p:outputLabel value=" #{allRequestDetailsBean.bankTrankId}"/>
<p:outputLabel value="Ip Address:"/>
<p:outputLabel value=" #{allRequestDetailsBean.ipAddress}"/>
<p:outputLabel value="Time:"/>
<p:outputLabel value=" #{allRequestDetailsBean.rechargeDate}"/>
<p:outputLabel value="Invoice No:"/>
<p:outputLabel value=" #{allRequestDetailsBean.invoiceNo}"/>
<p:outputLabel value="Conformation Id:"/>
<p:outputLabel value=" #{allRequestDetailsBean.conformationId}"/>
<p:outputLabel value="Status:"/>
<p:outputLabel value=" #{allRequestDetailsBean.rechargeStatusName}"/>
</p:panelGrid>
</p:dialog>
</h:form>
I Solved it by this code write in p:dataTable tag ....
filteredValue="#{allRequestDetailsBean.filteredRequest}"
and also create a list in allRequestDetailsBean
private List<AllRequestBean> filteredRequest;
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
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...
Why, when I call print method filter returnt null?
<ui:define>
<h:form>
<div>
<div>
<span>
<h:form>
<p:panelgrid>
...
<p:outputLabel value="Исполнитель-инженер :"/>
<h:inputText id="Eng" value="#{issueMoscowBean.changeIssue.engineerInf}"/>
...
close tags
and PrintMEthod
#Named
#Scope("session")
public class IssueMoscowBean implements Serializable {
...
public void saveOpen() throws CloneNotSupportedException {
if (listOpenI.contains(current)) {
System.out.println("CURRENT IN " + current.getEngineerInf());
listOpenI.set(listOpenI.indexOf(current), changeIssue);
System.out.println("Change IN " + changeIssue.getEngineerInf());
...
}
Console out is:
CURRENT IN null
Change IN null
<ui:composition template="/templates/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<ui:define name="content">
<style>
.colStyle1 { width: 25% !important;
}
.colStyle2 { width: 85% !important;
}
</style>
<h:form id="form">
<div style="width:88%; margin:auto !important; text-align: center;">
<p:tabMenu activeIndex="2" style=" width:100%; font-size: 14px !important; margin:0px auto !important; ">
<p:menuitem value="#{issueMoscowBean.getAllI()}" url="/modules/core/views/all.xhtml" onclick="#{issueMoscowBean.setFirstOpen()}"/>
<p:menuitem value="#{issueMoscowBean.getNewI()}" url="/modules/core/views/new.xhtml" />
<p:menuitem value="#{issueMoscowBean.getOpenI()}" url="#" />
<p:menuitem value="#{issueMoscowBean.getSetI()}" url="/modules/core/views/set.xhtml"/>
<p:menuitem value="#{issueMoscowBean.getExecI()}" url="/modules/core/views/execute.xhtml"/>
<p:menuitem value="#{issueMoscowBean.getClI()}" url="/modules/core/views/close.xhtml"/>
<p:menuitem value="#{issueMoscowBean.getRetI()}" url="/modules/core/views/return.xhtml"/>
</p:tabMenu>
<br/>
<br/>
<p:panelGrid style="padding-top: 0">
<p:selectOneMenu value="#{issueMoscowBean.param}" style="width: 20% !important; height: 100px">
<f:selectItem itemLabel="Выбрать критерий" itemValue="10" />
<f:selectItem itemLabel="По номеру заявки" itemValue="0" />
<f:selectItem itemLabel="По серийному номеру устройства" itemValue="1" />
<f:selectItem itemLabel="По ID регистраиции в ПС" itemValue="2" />
<f:selectItem itemLabel="По контактному лицу банка-клиента" itemValue="3" />
</p:selectOneMenu>
<h:inputText id="myFilter_text" value="#{issueMoscowBean.filter}" style="float: left;width: auto !important"/>
<p:commandButton value="Поиск" update="#all" ajax="true" style="float: left;width: auto !important"/>
</p:panelGrid>
<div style="width: 100%;padding-bottom: 5%;height: 75%">
<span style="float: left; width: 25%">
<p:dataTable id="dataTable" var="mem" value="#{issueMoscowBean.listOpenI}" widgetVar="Заявки"
style="width:100% !important; text-align: left; width: 100%;height: 100% !important; overflow-y: auto;overflow-x: auto;font-family: Cambria;background-color: white"
selection="#{issueMoscowBean.current}" selectionMode="single" rowKey="#{mem.docId}" rowStyleClass="#{mem.status eq 'Новая' ? 'new':
null}">
<p:ajax event="rowSelect" update=":form:issueDetailForm:display" />
<p:column filterMatchMode="contains" sortBy="#{mem.docId}" headerText="Список всех заявок" style="font-family: Cambria">
<h:outputText value="Время получения наряда:#{mem.taskRetrieved}" title="View" style="font-size: 15px !important;"/>
<br/>
<h:outputText value="№ серийный устройства:#{mem.atmSerial}" title="View" style="font-size: 15px !important;"/>
<br/>
<h:outputText value="Город:#{mem.city}" title="View" style="font-size: 15px !important;"/>
</p:column>
</p:dataTable>
</span>
<span style="float: left;width: 75%;height: available">
<h:form id="issueDetailForm" rendered="#{issueMoscowBean.openIsEmptyTAble()}" >
<p:panelGrid id="display" columns="2" columnClasses="colStyle1,colStyle2" style="margin:0 auto;width: 100%;" >
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Просмотр данных заявки"/>
</p:outputPanel>
</f:facet>
<h:outputText value="№ документа ССС :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.docId}"/>
<h:outputText value="№ наряда :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.naryadRecId}"/>
<h:outputText value="Тип наряда :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.naryadType}"/>
<h:outputText value="TransmasterID :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.transmasterID}"/>
<h:outputText value="Модель устройства :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.atmModel}"/>
<h:outputText value="№ серийный устройства:"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.atmSerial}"/>
<h:outputText value="Районный центр :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.rc}"/>
<h:outputText value="Область :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.oblast}"/>
<h:outputText value="Город :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.city}"/>
<h:outputText value="Адрес :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.adress}"/>
<h:outputText value="Название организации установки:"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.org}"/>
<h:outputText value="Время сбоя :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.issueCreated}"/>
<h:outputText value="Код ошибки :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.errorCode}"/>
<h:outputText value="MSTATUS_MDATA :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.mstatus_mdata}"/>
<h:outputText value="№ инцидента ITSM :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.incidentNumber}"/>
<h:outputText value="Дата инцидента в ITSM :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.incidentCreated}"/>
<h:outputText value="Дата наряда в ITSM :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.naryadCreated}"/>
<h:outputText value="Тип сбоя в ITSM :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.srbCode}"/>
<h:outputText value="Описание для ССС:"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.sssDescription}"/>
<h:outputText value="Cтатус сейфа :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.safeStatus}"/>
<h:outputText value="Код закрытия :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.closeStstus}"/>
<h:outputText value="Время получения наряда :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.taskRetrieved}"/>
<h:outputText value="Время последнего обновления :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.taskLastUpdated}"/>
<h:outputText value="Источник последнего обновления :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.taskLastUpdatedBy}"/>
<p:outputLabel value="Тип обслуживания :">
<p:message for="LevelService" id="wrongTypeService" />
</p:outputLabel>
<p:selectOneMenu id="LevelService" value="#{issueMoscowBean.changeIssue.taskLevelService}">
<f:selectItem itemLabel="ПСО" itemValue="1" />
<f:selectItem itemLabel="Разовое" itemValue="2" />
<p:ajax event="blur" update="wrongTypeService"/>
</p:selectOneMenu>
<p:outputLabel value="Номер договора :">
<p:message for="NumIssue" id="wrongNumIssue" />
</p:outputLabel>
<h:inputText id="NumIssue" value="#{issueMoscowBean.changeIssue.numIssue}" size="100" />
<p:outputLabel value="Дата начала обслуживания :"/>
<p:calendar id="DateBegin" value="#{issueMoscowBean.tempDate4}" locale="ru" pattern="MM/dd/yyyy HH:mm:ss" />
<p:outputLabel value="Время устранения неисправности :"/>
<h:inputText id="Time" value="#{issueMoscowBean.changeIssue.sla}" size="100" />
<p:outputLabel value="Исполнитель-инженер :"/>
<h:inputText id="Eng" value="#{issueMoscowBean.changeIssue.engineerInf}"/>
<p:outputLabel value="Дата и время передачи заявки инженеру :"/>
<p:calendar id="SendEng" value="#{issueMoscowBean.tempDate5}" locale="ru" pattern="MM/dd/yyyy HH:mm:ss" />
<p:outputLabel value="Тип работ :"></p:outputLabel>
<p:selectOneMenu value="#{issueMoscowBean.changeIssue.taskWorkValue}" style="width: 100%">
<f:selectItem itemLabel="Ремонт" itemValue="1" />
<f:selectItem itemLabel="Профилактика" itemValue="2" />
<f:selectItem itemLabel="Апгрейд" itemValue="2" />
<f:selectItem itemLabel="Запуск в эксплуатацию" itemValue="2" />
</p:selectOneMenu>
<p:outputLabel value="Номер заявки вендора :"/>
<h:inputText id="NumVendor" value="#{issueMoscowBean.changeIssue.numIssueVendor}" size="100" />
<h:outputText value="Cтатус :"></h:outputText>
<h:outputText value="#{issueMoscowBean.changeIssue.status} " />
<f:facet name="footer">
<p:commandButton value="Отменить изменения" update="issueDetailForm" process="#this" action="#{issueMoscowBean.back}" immediate="true" />
<p:commandButton value="Cохранить изменения" update="issueDetailForm" process="#this" action="#{issueMoscowBean.saveOpen}" immediate="true" />
<p:commandButton value="Назначить заявку" update=":form:dataTable, :growl" oncomplete="issueDialog2.show()" actionListener="#{issueMoscowBean.setI()}"/>
<p:commandButton value="Отменить Заявку" update=":form:issueDetailForm:display" process="#this" action="#{issueMoscowBean.setShowForm(1)}" immediate="true" />
<p:panelGrid id="display2" columns="2" columnClasses="colStyle1,colStyle2" rendered="#{issueMoscowBean.showForm}">
<h:outputText value="Опишите причину отмены :"></h:outputText>
<p:inputTextarea value="#{issueMoscowBean.changeIssue.closeComment}" cols="10"/>
<p:commandButton value="Отправить" update=":form:dataTable" process="#this" action="#{issueMoscowBean.returnIOpen()}" />
<p:commandButton value="Отмена" update=":form:issueDetailForm:display" process="#this" action="#{issueMoscowBean.setShowForm(0)}" immediate="true" />
</p:panelGrid>
</f:facet>
</p:panelGrid>
</h:form>
</span>
</div>
</div>
</h:form>
<p:growl id="growl" showDetail="true" life="5000" />
</ui:define>
</ui:composition>