Hello guys i have a problem updating some components, i am using JSF, Primefaces 5.3, Hibernate.
i Have this tab that contains a datatable: tab 1 and i have this other tab tab 2 what i want to do is when i change Farmaceutica column in tab 2 and click Guardar Cambios i want to update the datatable of the tab 1. I can update the datatabase and when i logout and login again the change is there but i want the change without logout.
This is my admin.xhtml:
<h:form id="frm">
<p:growl id="growl" life="3500" sticky="false" showDetail="true" />
<div class="navbar color-bar"></div>
<div class="container-fluid">
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-12">
<p:tabView id="tabs">
<p:tab title="Estado asignaciones">
<p:panel id="panelEstado">
<h:form id="formDta">
<p:dataTable
value="#{estadoAsignaciones.listaEstadoAsignaciones}"
var="data" paginator="true" rowKey="#{data.idAuditor}"
rows="10" selectionMode="single"
selection="#{estadoAsignaciones.estadoAsignaciones}">
<p:ajax event="rowSelect"
listener="#{estadoAsignaciones.onRowSelect()}"
onstart="PF('blockUIWidget').show()"
oncomplete="PF('overPnl').show()" update="frm" />
<p:column headerText="Auditor">
<h:outputLabel
value="#{data.nombreAuditor} #{data.apellidoAuditor}" />
</p:column>
<p:column headerText="Farmacéutica">
<h:outputLabel value="#{data.farmaceuticaAsignada}" />
</p:column>
<p:column headerText="Progreso">
<p:progressBar value="#{data.porcentaje}"
labelTemplate="{value}%" id="avanceBar" style="width:80%" />
</p:column>
</p:dataTable>
</h:form>
</p:panel>
<p:overlayPanel id="panelOver" widgetVar="overPnl"
showEffect="fade" hideEffect="fade" dismissable="false"
showCloseIcon="true">
<p:panel id="avance" header="Avance auditoria"
class="space robotome">
<p:progressBar id="avanceBar"
value="#{estadoAsignaciones.porcentajeValue}"
style="width:100%" labelTemplate="{value}%" />
</p:panel>
<p:panel id="tiempo" header="Tiempo" class="space robotome">
<h:outputLabel
value="Fecha inicio: #{estadoAsignaciones.fecha}" />
<br />
<h:outputLabel
value="Fecha Actual: #{estadoAsignaciones.fechaActual}" />
<br />
<h:outputLabel
value="Hora inicio: #{estadoAsignaciones.hora}" />
<br />
<h:outputLabel
value="Tiempo transcurrido: #{estadoAsignaciones.calHoraDif} horas" />
</p:panel>
<p:panel id="auditor" header="Auditor" class="robotome">
<p:outputLabel
value="Nombres: #{estadoAsignaciones.getEstadoAsignaciones().nombreAuditor}" />
<br />
<p:outputLabel
value="Apellidos: #{estadoAsignaciones.getEstadoAsignaciones().apellidoAuditor}" />
</p:panel>
</p:overlayPanel>
<p:blockUI block="frm" widgetVar="blockUIWidget">
<p:graphicImage name="imgs/loading.gif" width="50" height="50" />
</p:blockUI>
</p:tab>
<p:tab title="Asignaciones">
<p:dataTable id="dtA"
value="#{asignacionesBean.seleccionAuditores}" var="auditor"
paginator="true" rows="5">
<p:column headerText="Auditor">
<h:outputText value="#{auditor.nombreAuditor}" />
</p:column>
<p:column headerText="Farmaceutica">
<p:selectOneMenu value="#{auditor.idFarmaceutica}">
<f:selectItem itemLabel="#{data.farmaceutica}"
noSelectionOption="true" itemDisabled="true" itemValue="" />
<f:selectItems
value="#{asignacionesBean.mapSeleccionFarmaceuticas}" />
</p:selectOneMenu>
</p:column>
<p:column>
<p:commandButton value="Guardar cambios" update=":frm"
actionListener="#{asignacionesBean.guardarRespuestaAsignaciones(auditor)}"
process="#this"
onclick="PF('blockUIWidgetAsignaciones').hide()"
onsuccess="PF('blockUIWidgetAsignaciones').show()" />
</p:column>
</p:dataTable>
I appreciate your help.
I could not understant why you are using form inside form. Delete all forms except the main one.
In your first tab, add id to your datatable. and put prependId=false to your panel grid as below.
<p:panel id="panelEstado" prependId="false">
<p:dataTable id="firstTable" value="#{estadoAsignaciones.listaEstadoAsignaciones}"
var="data" paginator="true" rowKey="#{data.idAuditor}"
rows="10" selectionMode="single" selection="#{estadoAsignaciones.estadoAsignaciones}">
Then in Farmaceutica column in tab 2 change code like below
<p:selectOneMenu value="#{auditor.idFarmaceutica}">
<f:selectItem itemLabel="#{data.farmaceutica}" noSelectionOption="true" itemDisabled="true" itemValue="" />
<f:selectItems value="#{asignacionesBean.mapSeleccionFarmaceuticas}" />
<p:ajax event="valueChange" update=":firstTable"/>
</p:selectOneMenu>
in Guardar Cambios change your code to this one.
<p:commandButton value="Guardar cambios" update=":firstTable" actionListener="#{asignacionesBean.guardarRespuestaAsignaciones(auditor)}" process="#this"
onclick="PF('blockUIWidgetAsignaciones').hide()" onsuccess="PF('blockUIWidgetAsignaciones').show()" />
Related
I have a p:datascroller configured to display a list of entities and lazy loading them upon clicking the more button.
<h:form id="investigationOperationsForm">
<p:dataScroller
value="#{investigationManagerBackingBean.lazyLoadedInvestigationOperations}"
var="investigationOperation" chunkSize="9" lazy="true"
rowIndexVar="test">
<f:facet name="header">
Scroll down to load investigations
</f:facet>
<h:panelGrid columns="2" style="width:100%"
columnClasses="logo,detail">
<p:commandLink oncomplete="PF('investigationDialogW').show()"
update="investigationEditorForm" immediate="true">
<f:setPropertyActionListener value="#{investigationOperation}"
target="#{investigationManagerBackingBean.selection}" />
<p:graphicImage alt="Investigation Operation"
url="/images/common/investigation-operation.png" />
</p:commandLink>
<!-- h:outputText value="#{investigationOperation.name}" /-->
<p:outputPanel id="pnl">
<h:panelGrid columns="2" cellpadding="5">
<h:outputText value="Name:" />
<h:outputText value="#{investigationOperation.name}"
style="font-weight: bold" />
<h:outputText value="Description:" />
<h:outputText value="#{investigationOperation.shortDescription}"
style="font-weight: bold" />
</h:panelGrid>
<p:draggable for="pnl" />
</p:outputPanel>
</h:panelGrid>
<f:facet name="loader">
<p:outputPanel
visible="#{investigationManagerBackingBean.lazyLoadedInvestigationOperations.rowCount gt 10}"
rendered="#{investigationManagerBackingBean.lazyLoadedInvestigationOperations.rowCount gt 10}">
<p:commandLink value="More" />
</p:outputPanel>
</f:facet>
</p:dataScroller>
</h:form>
In addition, I have a dialog that pops up when the p:commandLink oncomplete method is executed where I can update the value of the current selection and persist the changes.
<p:dialog id="investigationDialog"
header="#{msg['inv-manager.invDialog.header.title']}"
widgetVar="investigationDialogW" minWidth="400" minHeight="400"
resizable="false" position="center center" modal="true">
<p:panel id="investigationEditorPanel">
<h:form id="investigationEditorForm">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="name"
value="#{msg['inv-manager.invDialog.nameFieldLabel']}" />
<p:inplace id="nameInplaceEditor" editor="true">
<p:inputText
value="#{investigationManagerBackingBean.selection.name}"
id="name" required="true" immediate="true"
label="#{msg['inv-manager.invDialog.nameFieldInputLabel']}" />
</p:inplace>
<h:outputLabel for="shortDescription"
value="#{msg['inv-manager.invDialog.shortDescriptionFieldLabel']}" />
<p:inplace id="shortDescriptionInplaceEditor" editor="true">
<p:inputText
value="#{investigationManagerBackingBean.selection.shortDescription}"
id="shortDescription" required="true" immediate="true"
label="#{msg['inv-manager.invDialog.shortDescriptionFieldInputLabel']}" />
</p:inplace>
<h:outputLabel for="description"
value="#{msg['inv-manager.invDialog.descriptionFieldLabel']}" />
<p:inputTextarea id="description" required="false"
label="#{msg['inv-manager.invDialog.descriptionFieldInputLabel']}"
immediate="true"
value="#{investigationManagerBackingBean.selection.description}" />
<p:commandButton id="okButton"
value="#{msg['inv-manager.invDialog.okButton']}" type="submit"
partialSubmit="true" process="investigationEditorForm"
action="#{investigationManagerBackingBean.createOrUpdate()}"
onclick="dlg.hide();" />
</h:panelGrid>
</h:form>
</p:panel>
</p:dialog>
The backing bean is configured to be #ViewScoped and everything works as defined. However, upon update the values of the p:datascroller are reset and the load method of the lazy loading model is executed and the datascroller is repopulated with new values from the database.
I have no reference to the datascroller or its containing form in the p:dialog and am wondering why the datascroller is being updated automagically? What am I missing in the equation. Have I overlooked something or something specific to the p:datascroller model that I need to consider when following this approach?
Look forward to the expertise of the community in resolving this issue.
Many thanks in advance :)
I have a dialog that open when the page is reloaded and ask for the login. This was working perfectly until I create another dialog that open when I click in a button. Both have different names and I am calling then right! I really don't know what is wrong..
Now, when I reload the page it shows me the login dialog and I put the right login and password but it rejects.. But if I remove the other dialog and do the same thinh, it works.
My code:
<body onload="PF('dlgLogin').show();">
<h:form name="">
<p:growl id="growl" sticky="true" showDetail="true" life="2000" />
<p:dialog header="Login" widgetVar="dlgLogin" modal="true" closable="false" resizable="false">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="login" value="Username:" />
<p:inputText id="login" value="#{loginView.login}" required="true" label="Login" />
<h:outputLabel for="password" value="Password:" />
<p:password id="password" value="#{loginView.senha}" required="true" label="Password" />
<f:facet name="footer">
<p:commandButton value="Login" update="growl" action="#{loginView.login}"
oncomplete="handleLoginRequest(xhr, status, args)" />
</f:facet>
</h:panelGrid>
</p:dialog>
<p:dialog header="Nova classificação" widgetVar="dlgClassificacao" modal="true" resizable="false">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="nome" value="Nome:" />
<p:inputText id="nome" value="#{adminView.classNome}" required="true" label="Nome" />
<h:outputLabel for="valor" value="Valor:" />
<p:inputText id="valor" value="#{adminView.classPreco}" required="true" label="Valor" />
</h:panelGrid>
<f:facet name="footerAdicionar">
<p:commandButton value="Adicionar" action="#{adminView.novaClassificacao}" />
</f:facet>
</p:dialog>
<p:layout>
<p:layoutUnit position="center">
<p:dataTable id="classificacoes" selection="#{adminView.selectedClassificacao}" var="classificacao" value="#{adminView.classificacoes}" style="margin-bottom:20px">
<p:ajax event="rowSelect" listener="#{adminView.onRowSelect}"/>
<p:column>
<f:facet name="header">
<h:outputText value="Nome" />
</f:facet>
<h:outputText value="#{classificacao.nome}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Valor" />
</f:facet>
<h:outputText value="#{classificacao.preco}" />
</p:column>
</p:dataTable>
<f:facet name="footer">
<p:commandButton title="Novo" icon="ui-icon-document" onclick="PF('dlgClassificacao').show();" type="button"/>
<p:commandButton title="Editar" icon="ui-icon-pencil" />
<p:commandButton title="Deletar" icon="ui-icon-trash" update="classificacoes" actionListener="#{adminView.excluirClassificacao}"/>
</f:facet>
</p:layoutUnit>
</p:layout>
</h:form>
<script type="text/javascript">
function handleLoginRequest(xhr, status, args) {
if(args.validationFailed || !args.loggedIn) {
PF('dlg').jq.effect("shake", {times:5}, 100);
}
else {
PF('dlg').hide();
$('#loginLink').fadeOut();
}
}
</script>
</body>
The problem is that you are sending all the form data when you press the login button. Then you obtain messages indicating that you have not (naturally) typed any data for Nome nor Valor fields.
You can fix it by adding an id attribute to your login dialog and to your form and also adding a process attribute to your login button:
<p:commandButton process=":yourForm:dlgLogin" value="Login"
update="growl" action="#{loginView.login}" />
I have a problem related to a <p:contextMenu> within a <p:dataTable> of PrimeFaces. There is a <p:commandLink> and also some command buttons within columns in this table, when I open the context menu automatically inserted is the value of that column my variable, but the problem is this when I open this <p:contexMenu> menu by clicking the right button on top of one of these link command or command button the value of this column is not passed to variable.
This is my code.
<h:form id="form-arquivo-listar">
<p:contextMenu id="menuArquivos" for="dataArquivos">
<p:menuitem value="Baixar" icon="ui-icon-disk" url="../../arquivos/#{arquivoBean.arquivoSelecionado.nome}" target="arquivo"/>
<p:menuitem value="Excluir" icon="ui-icon-close" actionListener="#{arquivoBean.excluir()}" update="form-arquivo-listar"/>
<p:menuitem value="Transferir" icon="ui-icon-extlink" actionListener="#{arquivoBean.getPastas()}" update=":formArquivoTransferir:treeArquivos" oncomplete="PF('arquivoTransferirDialog').show()"/>
</p:contextMenu>
<p:menubar model="#{arquivoBean.menu}"/>
<p:dataTable id="dataArquivos" value="#{arquivoBean.objetos}" var="o" rowKey="#{o.id}" selection="#{arquivoBean.arquivoSelecionado}" selectionMode="single" styleClass="ui-datatable-no-border">
<f:facet name="header">#{text['arquivo.pagina.listar.titulo']}</f:facet>
<p:column style="width: 20px">
<i class="#{o.tipo.icone}"></i>
</p:column>
<p:column headerText="#{text['arquivo.pagina.form.nome']}" rendered="#{o.tipo.id != 5}">
<p:link value="#{o.nomeOriginal}" href="../../arquivos/#{o.nome}" target="arquivo">
</p:link>
</p:column>
<p:column headerText="#{text['arquivo.pagina.form.nome']}" rendered="#{o.tipo.id == 5}">
<p:commandLink styleClass="link" id="link" value="#{o.nomeOriginal}" actionListener="#{arquivoBean.alterarPasta(o.id)}" update=":form-arquivo-listar" >
</p:commandLink>
</p:column>
<p:column headerText="#{text['arquivo.pagina.form.publico']}" style="width: 50px">
<h:outputText value="#{o.publico ? 'Sim' : 'Não'}" rendered="#{o.tipo.id != 5}"/>
</p:column>
<p:column style="width: 26px">
<p:commandButton id="editarButton" title="Exibir" icon="ui-icon-search" update=":form-arquivo-listar:arquivo-detalhes" oncomplete="PF('arquivoDialog').show()" rendered="#{o.tipo.id != 5}">
<f:setPropertyActionListener value="#{o}" target="#{arquivoBean.objeto}" />
</p:commandButton>
</p:column>
<p:column style="width: 26px">
<p:commandButton icon="ui-icon-pencil" oncomplete="PF('cadastroArquivo').show()">
<f:setPropertyActionListener value="#{o}" target="#{arquivoBean.objeto}" />
</p:commandButton>
</p:column>
<p:column style="width: 26px">
<p:commandButton id="excluirButton" title="#{text['arquivo.pagina.form.confirmacao.botao.titulo']}" icon="ui-icon-close" update=":form-arquivo-listar" actionListener="#{arquivoBean.excluir(o.id)}">
<p:confirm header="#{text['arquivo.pagina.form.confirmacao.titulo']}" icon="ui-icon-alert" message="#{text['arquivo.pagina.form.confirmacao.mensagem']}" />
</p:commandButton>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton icon="ui-icon-check" value="#{text['arquivo.pagina.form.confirmacao.sim']}" type="button" styleClass="ui-confirmdialog-yes" />
<p:commandButton icon="ui-icon-close" value="#{text['arquivo.pagina.form.confirmacao.nao']}" type="button" styleClass="ui-confirmdialog-no" />
</p:confirmDialog>
</p:column>
</p:dataTable>
<p:dialog id="arquivo-detalhes" widgetVar="arquivoDialog">
<h:panelGrid columns="2" cellpadding="4" style="margin:0 auto;">
<h:outputLabel value="#{text['arquivo.pagina.form.id']}:" />
<h:outputText value="#{arquivoBean.objeto.id}" />
<h:outputLabel value="#{text['arquivo.pagina.form.arquivo']}:" />
<h:graphicImage value="../../arquivos/#{arquivoBean.objeto.nome}" width="200" rendered="#{arquivoBean.isImagem()}" />
<p:media value="../../arquivos/#{arquivoBean.objeto.nome}" width="200" height="80" player="quicktime" rendered="#{arquivoBean.isAudio()}" />
<p:media value="../../arquivos/#{arquivoBean.objeto.nome}" width="300" height="300" rendered="#{arquivoBean.isVideo()}"/>
</h:panelGrid>
</p:dialog>
</h:form>
<p:dialog id="arquivoTransferirDialog" widgetVar="arquivoTransferirDialog">
<h:form id="formArquivoTransferir">
<p:growl id="msg" showDetail="false"/>
<h:panelGrid columns="1">
<p:tree id="treeArquivos" value="#{arquivoBean.raiz}" var="arquivo" selection="#{arquivoBean.raizSelecionada}" selectionMode="single">
<p:treeNode expandedIcon="ui-icon ui-icon-folder-open" collapsedIcon="ui-icon ui-icon-folder-collapsed">
<h:outputText value="#{arquivo.nomeOriginal}" />
</p:treeNode>
</p:tree>
<h:panelGrid columns="2">
<p:commandButton value="Transferir" actionListener="#{arquivoBean.transferirArquivo()}" oncomplete="PF('arquivoTransferirDialog').hide()" update="formArquivoTransferir, :form-arquivo-listar:dataArquivos"/>
<p:commandButton value="Cancelar" onclick="PF('arquivoTransferirDialog').hide()"/>
</h:panelGrid>
</h:panelGrid>
</h:form>
</p:dialog>
<p:dialog id="arquivoCriarPasta" widgetVar="arquivoCriarPasta">
<h:form id="formCriarPasta">
<p:growl id="msg" showDetail="false"/>
<h:panelGrid columns="2">
<h:outputText value="Nome" />
<p:inputText value="#{arquivoBean.objeto.nomeOriginal}" required="true"/>
<h:column/>
<h:panelGrid columns="2">
<p:commandButton value="Salvar" actionListener="#{arquivoBean.salvarPasta()}" update="formCriarPasta,:form-arquivo-listar:dataArquivos" oncomplete="PF('arquivoCriarPasta').hide()"/>
<p:commandButton value="Cancelar" onclick="PF('arquivoCriarPasta').hide()"/>
</h:panelGrid>
</h:panelGrid>
</h:form>
</p:dialog>
<p:dialog id="cadastroArquivo" header="#{text['arquivo.pagina.editar.titulo']}" widgetVar="cadastroArquivo" >
<h:form id="form-arquivo-editar" enctype="multipart/form-data">
<p:growl id="msg" showDetail="false"/>
<h:inputHidden value="#{arquivoBean.objeto.id}" rendered="#{arquivoBean.objeto.id!=null}" />
<h:panelGrid columns="2" style="margin:20px">
<p:outputLabel value="#{text['arquivo.pagina.form.arquivo']}" for="inputArquivo" />
<p:fileUpload id="inputArquivo" value="#{arquivoBean.file}" required="true" label="#{text['arquivo.pagina.form.arquivo']}" mode="simple"
disabled="#{arquivoBean.objeto.id!=null and arquivoBean.objeto.id!=0}" />
<p:outputLabel value="#{text['arquivo.pagina.form.nome']}" rendered="#{arquivoBean.objeto.id!=null and arquivoBean.objeto.id!=0}" />
<h:outputText value="#{arquivoBean.objeto.nomeOriginal}" rendered="#{arquivoBean.objeto.id!=null and arquivoBean.objeto.id!=0}" />
<p:outputLabel value="#{text['arquivo.pagina.form.descricao']}" for="inputDescricao" />
<p:inputTextarea id="inputDescricao" value="#{arquivoBean.objeto.descricao}" />
<p:outputLabel value="#{text['arquivo.pagina.form.publico']}" for="inputPublico" />
<p:selectBooleanCheckbox id="inputPublico" value="#{arquivoBean.objeto.publico}" />
<p:outputLabel value="#{text['arquivo.pagina.form.tipo']}" for="inputTipo" />
<p:selectOneMenu id="inputTipo" value="#{arquivoBean.objeto.tipo}" required="true" label="#{text['arquivo.pagina.form.tipo']}"
converter="#{arquivoTipoBean.converter()}">
<f:selectItem itemLabel="#{text['arquivo.pagina.form.tipo.default']}" />
<f:selectItems value="#{arquivoTipoBean.selectObjetos}" />
</p:selectOneMenu>
</h:panelGrid>
<h:panelGrid columns="2" style="margin-bottom:10px">
<p:commandButton value="#{text['arquivo.pagina.form.salvar']}" update=":form-arquivo-editar,:form-arquivo-listar"
process="#form" actionListener="#{arquivoBean.salvar}" ajax="false" />
</h:panelGrid>
</h:form>
</p:dialog>
I tried to update a Gmap which placed in a tabView. But i am getting the
java.lang.IllegalArgumentException: tab2
error. I have searched this problem a little and noticed that it is available only if tab is visible. So what can I do ? The code block is below:
<h:form id="form">
<p:tabView orientation="left" id="tabView" styleClass="tabView">
<p:ajax event="tabChange" listener="#{sucBean.onTabChange}"
update=":form:tabView:map" />
<p:tab title="Bütün Suçlar" id="tab1">
<p:gmap zoom="10" type="HYBRID" center="40.78470,29.94873" id="map"
model="#{sucBean.advancedModel}"
style="width:740px;height:500px;margin:-14px 0 0 -10px;">
<p:ajax event="overlaySelect" listener="#{sucBean.onMarkerSelect}" />
<p:gmapInfoWindow>
<p:outputPanel
style="text-align:justify;display:block;margin:auto:">
<p:panelGrid columns="2" cellpadding="8">
<h:outputText value="Suç Tipi:" style="color:red" />
<h:outputText value="#{sucBean.marker.data.sucTipi}" />
<h:outputText value="Tarih: " style="color:red" />
<h:outputText value="#{sucBean.marker.data.islenmeZamani}" />
<h:outputText value="Adres: " style="color:red" />
<h:outputText value="#{sucBean.marker.data.adres}" />
<h:outputText value="Suçu İşleyen:" style="color:red" />
<h:outputText value="#{sucBean.marker.data.isleyenBilgisi}" />
</p:panelGrid>
</p:outputPanel>
</p:gmapInfoWindow>
</p:gmap>
</p:tab>
<p:tab title="Suç Ara" id="tab2">
<p:fieldset legend="Ayrıntılı Arama" styleClass="searchField"
id="fieldSet">
<p:panelGrid columns="4" cellpadding="10">
<p:inputText value="#{sucBean.arananKelime}" style="width:300px" />
<h:outputText value=" Kriter:" />
<p:selectOneMenu value="#{sucBean.aramaKriteri}">
<f:selectItem itemLabel="Suç Tipi" itemValue="sucTipi" />
<f:selectItem itemLabel="Adres" itemValue="adres" />
<f:selectItem itemLabel="İşlenme Zamanı" itemValue="zaman" />
<f:selectItem itemLabel="Cinsiyet" itemValue="cinsiyet" />
<f:selectItem itemLabel="Yaş" itemValue="yas" />
</p:selectOneMenu>
<p:commandButton value="Ara"
actionListener="#{sucBean.sucKaydiAra}" update="aramaSonucu" />
</p:panelGrid>
</p:fieldset>
<p:dataTable var="suc" value="#{sucBean.sucModel}" paginator="true"
rows="10" id="aramaSonucu" selection="#{sucBean.selectedSuc}">
<p:column selectionMode="multiple" style="width:18px"></p:column>
<p:column headerText="Suç Tipi">
<h:outputText value="#{suc.sucTipi}" />
</p:column>
<p:column headerText="İşlenme Zamanı">
<h:outputText value="#{suc.islenmeZamani}" />
</p:column>
<p:column headerText="Adres">
<h:outputText value="#{suc.adres}" />
</p:column>
<p:column headerText="Suçu İşleyen">
<h:outputText value="#{suc.isleyenBilgisi}" />
</p:column>
<!-- <f:facet name="footer"> -->
<!-- </f:facet> -->
</p:dataTable>
<p:commandButton id="multiSelectButton" actionListener="#{sucBean.secilenleriGetir}" update=":form:tabView:tab2:map2"
value="Secilenleri Haritada Göster" icon="ui-icon-pin-s" />
<p:gmap zoom="12" type="HYBRID" center="40.78470,29.94873"
id="map2" model="#{sucBean.advancedModel2}"
style="width:740px;height:300px;margin:10px 0 0 -10px;">
When you reference a component inside container components like tabView or accordion, you don't need to include the actual tab id in your update target.
In your case update=":form:tabView:map2" would be the correct update target.
I have a page with 2 dropdown lists that fill a data-table (depending on the choice made in the dropdown lists). The data table contains check-boxes for selecting multiple lines and then opening a dialogue that shows information based on the selected lines. the problem is: the first time I click on the button to open the dialogue it's empty, when I change the content of the dropdown lists and open the dialogue it will show the information of the previous selection not the one i just made and it'll stay that way until i change the dropdown list and so on... the dialogue always shows the information of the previous selection before changing the choice made in the dropdown list.
the page:
<h:form id="form">
<f:view>
<p:growl id="msgs" showDetail="true" />
<p:layout style="min-width:300px;min-height:200px;" id="layout">
<p:layoutUnit position="west" resizable="true" size="200" minSize="40" maxSize="300">
<!-- _______________________________________start drop down________________________________________________________ -->
<h:panelGrid columns="1" cellpadding="5">
<p:selectOneMenu id="Item" value="#{ThemeBean.idItem}">
<f:selectItem itemLabel="Select un Item " itemValue="" />
<f:selectItems value="#{ItemBean.listItemsUser}" var="utilisateur" />
<p:ajax listener="#{ThemeBean.handleCityChange}" update="suburbs" />
</p:selectOneMenu>
<p:selectOneMenu id="suburbs" value="#{ReponseBean.idTheme}">
<f:selectItem itemLabel="Select un Theme" itemValue="" />
<f:selectItems value="#{ThemeBean.suburbs}" />
<p:ajax listener="#{ReponseBean.handleCityChange_Ecart}" update=":form:dropArea" />
</p:selectOneMenu>
</h:panelGrid>
<p:separator />
</p:layoutUnit>
<!-- _______________________________________end drop down________________________________________________________ -->
<p:layoutUnit position="center">
<p:outputPanel id="dropArea">
<p:dataTable id="dt1" var="car"
value="#{ReponseBean.listPartheme_ecart}"
rendered="#{not empty ReponseBean.listPartheme_ecart}"
rowKey="#{car.id}" editable="true"
selection="#{EcartBean.selectedCars}">
<p:column selectionMode="multiple" style="width:18px" />
<p:column headerText="Questions">
<h:outputText value="#{car.q1.text}" />
</p:column>
<p:column headerText="Reponse">
<h:outputText value="#{car.rep}" />
</p:column>
<f:facet name="footer">
<p:commandButton id="multiViewButton" value="Ajouter Ecart" icon="ui-icon-search"
update=":form:multiDialog :form:displayMulti" oncomplete="multiCarDialog.show()"/>
</f:facet>
</p:dataTable>
<!-- ________________________________________dialogue________________________________________________ -->
<p:dialog id="multiDialog" header="Ajout Ecart" widgetVar="multiCarDialog" height="300" showEffect="fade">
<p:dataList id="displayMulti" value="#{EcartBean.selectedCars}" var="selectedCare">
#{selectedCare.q1.text} (#{selectedCare.rep})
</p:dataList>
<p:messages />
<h:panelGrid columns="3" cellpadding="5">
<h:outputLabel value="Niveau Ecart" />
<p:selectOneMenu id="idUtilisateur" value="#{EcartBean.idNiveauAudit}">
<f:selectItems value="#{NiveauEcartBean.listNiveauSelect}" var="nivecart" />
</p:selectOneMenu>
<p:message for="idUtilisateur" />
<h:outputLabel value="Constatation" id="Constatation" />
<h:inputText value="#{EcartBean.consta}" />
<p:message for="Constatation" />
<p:commandButton icon="ui-icon-disk" value="Ajouter" id="ViewButton" action="#{EcartBean.save}"
oncomplete="multiCarDialog.hide();">
</p:commandButton>
</h:panelGrid>
</p:dialog>
</p:outputPanel>
</p:layoutUnit>
</p:layout>
</f:view>
</h:form>
the methode ThemeBean.handleCityChange :
public void handleCityChange() {
qu = respQue.lister_Ques(idItem);
if (qu != null) {
List<SelectItem> listuti = new ArrayList<SelectItem>();
List<Theme> list = resp.lister_Par_Thme(qu.getId());
for (Theme p : list) {
listuti.add(new SelectItem(p.getId(), p.getLibelle()));
}
this.setSuburbs(listuti);
} else {
System.out.println("erreur");
}
}
ReponseBean.handleCityChange_Ecart :
public void handleCityChange_Ecart() {
listPartheme_ecart= new ArrayList<Reponse>();
System.out.println("taiile avant "+listPartheme_ecart.size());
List<Reponse> lr = respQ.findByTheme_ecart(idTheme);
System.out.println(idTheme);
for (int i = 0; i < lr.size(); i++) {
if (lr.get(i).getAudit().getId() == aud.getId())
listPartheme_ecart.add(lr.get(i));
}
}
I should mention that in the console i see the write information when i open the dialogue, it just doesn't show write away on the dialogue.
thank you for your time and help.
I am updating this post to say that i finaly solved the probleme of filling the popup
i put the dialogue in a new form like this:
</h:form>
<!-- ________________________________________dialogue________________________________________________ -->
<h:form id="hh" >
<p:dialog id="multiDialog" header="Ajout Ecart" widgetVar="multiCarDialog" height="300" showEffect="fade">
<p:dataList id="displayMulti" value="#{EcartBean.selectedCars}" var="selectedCare">
#{selectedCare.q1.text} (#{selectedCare.rep})
</p:dataList>
<p:messages />
<h:panelGrid columns="3" cellpadding="5">
<h:outputLabel value="Niveau Ecart" />
<p:selectOneMenu id="idUtilisateur" value="#{EcartBean.idNiveauAudit}">
<f:selectItems value="#{NiveauEcartBean.listNiveauSelect}" var="nivecart" />
</p:selectOneMenu>
<p:message for="idUtilisateur" />
<h:outputLabel value="Constatation" id="Constatation" />
<h:inputText value="#{EcartBean.consta}" />
<p:message for="Constatation" />
<p:commandButton icon="ui-icon-disk" value="Ajouter" action="#{EcartBean.save}" id="ViewButton" oncomplete="multiCarDialog.hide();" />
</h:panelGrid>
</p:dialog>
</h:form>
i have now one little probleme: the commandButton in the dialogue does not fire the methode save i have tried
<p:commandButton icon="ui-icon-disk" value="Ajouter" action="#{EcartBean.save}" id="ViewButton" oncomplete="multiCarDialog.hide();" />
and
<p:commandButton icon="ui-icon-disk" value="Ajouter" actionListener="#{EcartBean.save}" id="ViewButton" oncomplete="multiCarDialog.hide();" />
and
<p:commandButton icon="ui-icon-disk" value="Ajouter" id="ViewButton" oncomplete="multiCarDialog.hide();" >
<f:actionListener binding="#{EcartBean.save}"/>
</p:commandButton>
but nothing :( . where have gone wrong?
As per the documentation of <p:ajax>, listener is triggered only on partial request which I don't see happening in the code that you pasted. Use event="valueChange" to trigger a partial request which would result the current update to be shown in dialog.
<p:ajax event="valueChange" listener="#{ThemeBean.handleCityChange}" update="suburbs" />
<p:ajax event="valueChange" listener="#{ReponseBean.handleCityChange_Ecart}" update=":form:dropArea" />