Editing additional info in a dataTable on primeFaces - ajax

So, I have a dataTable on my page that shows some basic information and a row expansion to show the extra information. I'm trying to create a button/context menu to show a dialog so the user could edit the informations on the table (basic and extra, all in a form) but I'm having trouble in getting this data from the table. When I click the button to show the dialog, it only shows the information of the first row, and not the row I selected. Any ideas? Thank you. Code follows below.
<p:dataTable id="socios" var="socio" value="#{sociosBean.socios}" rowKey="#{socio.id}"
selection="#{sociosBean.socioEscolhido}" selectionMode="single" paginator="true"
widgetVar="socios" emptyMessage="Nenhum socio encontrado " filteredValue="#{sociosBean.socioFiltro}"
rows="10" paginatorAlwaysVisible="false">
<p:menuitem value ="Editar" update="socios" icon ="ui-icon-search"
oncomplete="editar.show();">
<f:setPropertyActionListener target="#{sociosBean.socioEditar}" value="#{socio}"/>
</p:menuitem>
<p:menuitem value="Excluir" update="socios" icon="ui-icon-close" onclick="excluir.show();"/>
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Socios" />
</p:outputPanel>
</f:facet>
<p:column style="width:2%">
<p:rowToggler />
</p:column>
<p:column headerText="ID" filterMatchMode="startsWith" id="id" filterBy="#{socio.id}">
<h:outputText value="#{socio.id}" />
</p:column>
<p:column headerText="Nome" filterBy="#{socio.nome}" filterMatchMode="startsWith" id="colunaNome" >
<h:outputText value="#{socio.nome}"/>
</p:column>
<p:column headerText="Sexo" style="width: 4%">
<h:outputText value="#{socio.sexo}"/>
</p:column>
<p:column headerText="Data de Nascimento">
<h:outputText value="#{socio.dataNascimento}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column headerText="Cargo">
<h:outputText value="#{socio.cargo}"/>
</p:column>
<p:column headerText="Status">
<p:selectBooleanButton value="#{socio.ativo}" offLabel="Inativo" onLabel="Ativo" disabled="true"/>
</p:column>
<p:column headerText="Editar">
<p:commandButton icon="ui-icon-search" oncomplete="editar.show();">
<f:setPropertyActionListener target="#{sociosBean.socioEditar}" value="#{socio}"/>
</p:commandButton>
</p:column>
<p:rowExpansion>
<p:panelGrid id ="informacao" columns="2" style="width:400px; alignment-baseline: middle" >
<f:facet name="header">
#{socio.nome}
</f:facet>
<h:outputText value="ID"/>
<h:outputText value ="#{socio.id}"/>
<h:outputText value="Data de Nascimento"/>
<h:outputText value="#{socio.dataNascimento}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
<h:outputText value="Nome do Pai"/>
<h:outputText value ="#{socio.nomePai}"/>
<h:outputText value="Nome da Mãe"/>
<h:outputText value ="#{socio.nomeMae}"/>
<h:outputText value="Cargo"/>
<h:outputText value ="#{socio.cargo}"/>
<h:outputText value="Telefone"/>
<h:outputText value ="#{socio.telefone}"/>
<h:outputText value="Ano de Admissão"/>
<h:outputText value ="#{socio.anoAdmissao}"/>
<h:outputText value ="Endereço"/>
<h:outputText value ="#{socio.endereco}"/>
</p:panelGrid>
</p:rowExpansion>
</p:dataTable>
<p:button href="AID.xhtml" value="Voltar"/>
<p:confirmDialog id="excluirSocio" message="Excluir sócio?"
header="Aviso" severity="alert" widgetVar="excluir">
<p:commandButton id="confirm" value="Sim" update="mensagem, socios" oncomplete="excluir.hide();"
actionListener="#{sociosBean.excluirSocio()}" icon="ui-icon-check"/>
<p:commandButton id="decline" value="Não" onclick="excluir.hide();" type="button" icon="ui-icon-close" />
</p:confirmDialog>
<p:dialog id="editarSocio" widgetVar="editar">
<p:panelGrid id="cadastro" columns="2">
<f:facet name="header">Editar Sócio</f:facet>
<p:outputLabel for="nome" value="Nome:"/>
<p:inputText id="nome" required ="true" value ="#{sociosBean.socioEditar.nome}"/>
<p:outputLabel for="s" value="Sexo:"/>
<p:selectOneRadio id="s" value="#{sociosBean.socioEditar.sexo}">
<f:selectItem itemValue="m" itemLabel="Masculino"/>
<f:selectItem itemValue="f" itemLabel="Feminino"/>
</p:selectOneRadio>
<p:outputLabel for ="serie" value="Série:"/>
<p:selectOneMenu id="serie" value="#{sociosBean.socioEditar.serie}">
<f:selectItem itemLabel="3º Ensino Médio" itemValue="3EM" />
<f:selectItem itemLabel="2º Ensino Médio" itemValue="2EM" />
<f:selectItem itemLabel="1º Ensino Médio" itemValue="1EM" />
<f:selectItem itemLabel="8º Ensino Fundamental" itemValue="8EF" />
<f:selectItem itemLabel="7º Ensino Fundamental" itemValue="7EF" />
<f:selectItem itemLabel="6º Ensino Fundamental" itemValue="6EF" />
<f:selectItem itemLabel="5º Ensino Fundamental" itemValue="5EF" />
</p:selectOneMenu>
<p:outputLabel for ="endereco" value ="Endereço:"/>
<p:inputText id ="endereco" maxlength="60" value="#{sociosBean.socioEscolhido.endereco}"/>
<p:outputLabel for ="telefone" value ="Telefone:"/>
<p:inputMask id="telefone" value="#{sociosBean.socioEscolhido.telefone}" mask="(99)9999-9999"/>
<p:outputLabel for ="nomePai" value ="Nome do Pai:"/>
<p:inputText id ="nomePai" maxlength="45" value="#{sociosBean.socioEscolhido.nomePai}"/>
<p:outputLabel for ="nomeMae" value ="Nome da Mãe:"/>
<p:inputText id ="nomeMae" maxlength="45" value="#{sociosBean.socioEscolhido.nomeMae}"/>
<p:outputLabel for ="dataNascimento" value ="Data de nascimento: "/>
<p:calendar id="dataNascimento" value="#{sociosBean.socioEscolhido.dataNascimento}" required="true" navigator ="true" locale ="pt" pattern="dd/MM/yyyy"/>
<p:outputLabel for ="cargo" value ="Cargo:"/>
<p:inputText id ="cargo" maxlength="25" value="#{sociosBean.socioEscolhido.cargo}"/>
<p:outputLabel for ="anoAdmissao" value ="Ano Admissão:"/>
<p:inputMask id ="anoAdmissao" maxlength="4" mask="9999" value="#{sociosBean.socioEscolhido.anoAdmissao}"/>
<f:facet name="footer">
<p:commandButton id="btnEditar" value="Editar" actionListener="#{sociosBean.editarSocio()}"/>
</f:facet>
</p:panelGrid>
</p:dialog>
</h:form>
Bean:
package com.beans;
import com.dao.SociosDAO;
import java.util.ArrayList;
import model.hibernate.Socios;
import java.util.Date;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
#ManagedBean
#SessionScoped
/**
*
* #author João Pedro Sacheti
*/
public class SociosBean {
private String nome;
private String serie;
private char sexo;
private String endereco;
private String nomePai;
private String nomeMae;
private Date dataNascimento;
private String cargo;
private Integer anoAdmissao;
private boolean ativo;
private String telefone;
private List<Socios> socioFiltro;
private ArrayList<Socios> socios;
private Socios socioEscolhido;
private Socios socioEditar;
//getters and setters
public SociosBean() {
this.socios = new ArrayList<Socios>();
this.socioEditar = new Socios();
}

I would guess that the problem is that you are not updating the content of the dialog when you show it. So you would have to add update="editarSocio:cadastro" to the commandButton you use to show the dialog.
But be aware that the id you will have to enter depends on the structure of the XHTML, which I dont know.

Related

setPropertyActionListener is not setting the target value in the bean

I am trying to set some information in dialogue box when the search button is clicked but the problem I am facing is that f:setPropertyActionListener is not setting the target value in the backing bean so when the popup comes its empty.
Dialogue box looks like this :
<h:form id="form">
<p:fieldset legend="Saved Branches" style="margin-bottom: 30px;">
<p:dataTable id="branches" var="branch" value="#{branchOnBoarding.savedBranches}">
<f:facet name="header">
Branch Information
</f:facet>
<p:column headerText="Branch Name">
<h:outputText value="#{branch.branchName}" />
</p:column>
<p:column headerText="Branch Code">
<h:outputText value="#{branch.branchCode}" />
</p:column>
<p:column headerText="Building">
<h:outputText value="#{branch.building}" />
</p:column>
<p:column headerText="Street">
<h:outputText value="#{branch.street}" />
</p:column>
<p:column headerText="City">
<h:outputText value="#{branch.city}" />
</p:column>
<p:column headerText="State">
<h:outputText value="#{branch.state}" />
</p:column>
<p:column headerText="Country">
<h:outputText value="#{branch.country}" />
</p:column>
<p:column style="width:32px;text-align: center">
<p:commandButton update=":form:branchDetail" oncomplete="PF('branchDialog').show()" icon="ui-icon-search" title="View">
<f:setPropertyActionListener value="#{branch}" target="#{branchOnBoarding.selectedBranch}" />
</p:commandButton>
</p:column>
</p:dataTable>
<p:dialog header="Branch Info" widgetVar="branchDialog">
<p:outputPanel id="branchDetail" style="text-align:center;">
<p:panelGrid columns="2" rendered="#{not empty branchOnBoarding.selectedBranch.branchName}" columnClasses="label,value">
<h:outputText value="Branch Name:" />
<h:outputText value="#{branchOnBoarding.selectedBranch.branchName}" />
<h:outputText value="Branch Code:" />
<h:outputText value="#{branchOnBoarding.selectedBranch.branchCode}" />
<h:outputText value="Building:" />
<h:outputText value="#{branchOnBoarding.selectedBranch.building}" />
<h:outputText value="Street:" />
<h:outputText value="#{branchOnBoarding.selectedBranch.street}" />
<h:outputText value="City:" />
<h:outputText value="#{branchOnBoarding.selectedBranch.city}" />
<h:outputText value="State:" />
<h:outputText value="#{branchOnBoarding.selectedBranch.state}" />
<h:outputText value="Country:" />
<h:outputText value="#{branchOnBoarding.selectedBranch.country}" />
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</p:fieldset>
Code for backing bean looks like this :
#Component(value="branchOnBoarding")
#ManagedBean
#SessionScoped
#SpringScopeView
public class BranchOnBoarding implements Serializable{
private BranchUI branchUI = new BranchUI();
private List<Branch> savedBranches = new ArrayList<>();
private Branch selectedBranch;
public Branch getSelectedBranch() {
return selectedBranch;
}
public void setSelectedBranch(Branch selectedBranch) {
this.selectedBranch = selectedBranch;
}
public List<Branch> getSavedBranches() {
savedBranches = branchDao.findAll();
//for(Branch b:savedBranches)
//System.err.println(b.getBranchName());
return savedBranches;
}
public void setSavedBranches(List<Branch> savedBranches) {
this.savedBranches = savedBranches;
}
}
Dialogue box looks like this :

How to validate a List<Object> in a Primefaces dataTable - JSF

I have a dataTable for Phone something like :
<p:dataTable value="#{billingInfoBean.billingProfile.payer.phones}" var="phone" id="payerPhoneTable">
<p:column>
<f:facet name="header">
<h:outputText value="Type" />
</f:facet>
<p:selectOneMenu value="#{phone.type}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{backOfficeLookupClient.allPhoneTypes}" />
</p:selectOneMenu>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Area Code" />
</f:facet>
<h:inputText value="#{phone.areaCode}" size="3" maxlength="3" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Exchange" />
</f:facet>
<h:inputText value="#{phone.exchange}" size="3" maxlength="3" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Local" />
</f:facet>
<h:inputText value="#{phone.local}" size="4" maxlength="4" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Extension" />
</f:facet>
<h:inputText value="#{phone.extension}" size="5" maxlength="5" />
</p:column>
</p:dataTable>
I am trying to use custom validation using the object Phone. I need to call a Phone Validation service which takes these column values as inputs. Can I make use of <f:validator> here in this case?, If yes, how ?
You could attach to the dataTable a validator listener
<f:event type="postValidate" listener="#{bean.customValidation}"/>
And validate the phone object in your bean
public void customValidation(ComponentSystemEvent event) {
...
}
Then iterate through all dataTable childrens and validate each one.
Here ther's a good tutorial to start with.
This omnifaces tag solved my problem :
http://showcase.omnifaces.org/validators/validateMultiple

Error Validation of a Dialog InputText Primefaces jsf

I have a DataTable and edit a listing you have to open the Dialog component with the respective values ​​that sends the selected object from theDataTable, but cannot open. I have noticed that the function is REQUIRED = "true" and also that no error is displayed, the only solution that helped me erase the function is REQUIRED.
How do I to bring up the Dialog component without taking the REQUIRED function. An example of the code:
<p:tab id="tab_listar" title="#{msg.labelListar}">
<h:form id="form_mostrar_listado">
<p:dialog id="ModificarLugar" header="Modificar Datos" widgetVar="LugarDialogo2"
modal="false" resizable="false" hideEffect="bounce" showEffect="explode">
<h:panelGrid id="ModificarLugar1" columns="2" cellpadding="5">
<h:outputText value="#{msg.labelCodigo}"/>
<h:outputText value="#{BeanLugar.objLugarMod.cod_lugar}"/>
<h:outputText value="#{msg.labelNombre}"/>
<p:inputText value="#{BeanLugar.objLugarMod.nombre}" id="nombre_lu_mod"
required="true" requiredMessage="#{msg.labelNoVacio}"
validatorMessage="#{msg.labelNoValido}"> </p:inputText>
<h:outputText value="#{msg.labelUbicacion}"/>
<h:panelGroup>
<p:selectOneMenu value="#{BeanLugar.objLugarMod.objPais.cod_pais}"
required="true" id="cod_pais_mod" effect="fade"
requiredMessage="#{msg.labelNoVacio}"
validatorMessage="#{msg.labelNoValido}">
<f:selectItem itemLabel="#{msg.labelEligePais}" itemValue=""/>
<f:selectItems value="#{Pais.cargarComboPais}"/>
</p:selectOneMenu>
<h:message showDetail="false" showSummary="true" for="cod_pais_mod"/>
</h:panelGroup>
<p:commandButton value="Cancelar" actionListener="#{BeanLugar.doiniciarModLugar()}"
update=":LugarTabView:form_mostrar_listado" icon="ui-icon-triangl-1-w"
immediate="true"> </p:commandButton>
<p:commandButton id="btn_actualizar" value="#{msg.btnActualizar}"
update=":LugarTabView:form_mostrar_listado"
actionListener="#{BeanLugar.doActualizaLugar()}"> </p:commandButton>
</h:panelGrid>
</p:dialog>
<p:panel id="datListadoLugar">
<h:outputText value="#{msg.labelListado}"/>
<h:panelGrid columns="3" cellspacing="10" width="100">
<p:commandButton value="#{msg.btnNuevo}" update="form_mostrar_listado"
actionListener="#{BeanLugar.doiniciarListadoLugar()}"/>
<p:commandButton value="#{msg.btnListar}" update="form_mostrar_listado"
actionListener="#{BeanLugar.doListarLugar()}"/>
</h:panelGrid>
<h:panelGrid columns="2" rendered="#{BeanLugar.sizeLugar ne '0'}">
<h:outputText value="#{msg.labelCantidad}"/>
<h:outputText value="#{BeanLugar.arrLugar.size()}"/>
</h:panelGrid>
<h:panelGrid columns="1" rendered="#{BeanLugar.sizeLugar ne '0'}">
<p:dataTable id="resListadoLugar" value="#{BeanLugar.doListarLugar()}" var="ls"
paginator="true" rows="5" paginatorPosition="both" rowsPerPageTemplate="5,10,15">
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.labelLugar}"/>
</f:facet>
<h:outputText value="#{ls.nombre}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.labelUbicacion}"/>
</f:facet>
<h:outputText value="#{ls.objPais.nomb_pais}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.labelVer}"/>
</f:facet>
<p:commandLink title="Ver" action="#{BeanLugar.mostrarLugar(ls)}"
value="Ver" update=":LugarTabView:form_mostrar_listado:DetalleLugar"
oncomplete="LugarDialogo.show()"> </p:commandLink>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.labelEditar}"/>
</f:facet>
<p:commandLink title="Editar" action="#{BeanLugar.editarLugar(ls)}"
value="Editar"
update=":LugarTabView:form_mostrar_listado:ModificarLugar"
oncomplete="LugarDialogo2.show()"> </p:commandLink>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.labelEliminar}"/>
</f:facet>
<p:commandLink title="Eliminar" action="#{BeanLugar.eliminarLugar(ls)}"
value="Eliminar"
update=":LugarTabView:form_mostrar_listado:EliminarLugar"
oncomplete="LugarDialogo3.show()"> </p:commandLink>
</p:column>
</p:dataTable>
</h:panelGrid>
</p:panel>
</h:form>
</p:tab>
You are processing all form so JSF tries yo validate all components with required true. You have to tell commandLink what you want to process, for example:
<p:commandLink title="Editar" action="#{BeanLugar.editarLugar(ls)}"
value="Editar"
update=":LugarTabView:form_mostrar_listado:ModificarLugar"
oncomplete="LugarDialogo2.show()"
process="resListadoLugar"> // or the path of the component you want to process
</p:commandLink>

jsf get selectOneMenu value from actionListener of h:commandButton

I have a primefaces datatable with the attribute editable="true" so I can't edit the rows dynamically. I have two fields: an inputText and a selectOneMenu. I want to be able to add rows dynamically from the footer. I added empty field in the footer and when the user click a button, I want to add the new line to the datatable with the correct values.
Here is the code I have:
<h:form>
...
<p:dataTable value="#{bean.myObjects}" id="myDatatable" editable="true" var="obj">
<f:facet name="header">
<h:outputText value="My Datatable" />
</f:facet>
<p:column headerText="My String value">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{obj.myString}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{obj.myString}"/>
</f:facet>
</p:cellEditor>
<f:facet name="footer">
<h:inputText value="#{bean.myNewObject.myString}" />
</f:facet>
</p:column>
<p:column headerText="My List Value">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{bean.myListValue ? 'yes' : 'no'}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{bean.myListValue}" >
<f:selectItem itemValue="true" itemLabel="yes" />
<f:selectItem itemValue="false" itemLabel="no" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
<f:facet name="footer">
<h:selectOneMenu value="#{bean.myNewObject.myListValue}" >
<f:selectItem itemValue="true" itemLabel="yes" />
<f:selectItem itemValue="false" itemLabel="no" />
</h:selectOneMenu>
</f:facet>
</p:column>
<p:column>
<p:rowEditor />
<f:facet name="footer">
<h:commandButton actionListener="#{bean.addRow}">
<f:ajax execute="myDatatable" render="myDatatable" />
</h:commandButton>
</f:facet>
</p:column>
</p:dataTable>
...
</h:form>
In my bean, I just have this for the addRow method:
public void addRow() {
this.myObjects.add(this.myNewObject);
this.myNewObject = new MyObject();
}
and the init:
#PostConstruct
public void init() {
this.myObjects = Controller.getAllMyObjects();
this.myNewObject = new MyObject();
}
I could precise that the bean is in ViewScope. The result is that the line is added, the string value is correct but the list value is always "no" even if I set it to true with this.myNewObject.setMyListValue(true) in the bean after instanciate the object.
I know that this is something with to render or the execute of attributes.
If I change the line:
<f:ajax execute="myDatatable" render="myDatatable" />
to:
<p:ajax update="#form" />
the list value is true but the string value is not set.
How to be sure that both of my attribute are rendered and how can I get there values without submiting the whole form?
Thanks

why does the p:dialog not submit values to bean

I have a small jsf/primefaces application with a datgrid that shows (order) items.
Now I want to add items during a dialog.
I open the dialog with a button click. - works
I want to submit the values from the dialog to the bean and update the datagrid.
If I use a default value (not from the dialog) it works. The item get shown in the datagrid and the dialog get closed. That means.
-addItem Function works
-update works
But if I want to add the values from the dialog I get a null Pointer Exception. So my values will not set in the bean.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<p:fieldset legend="Positionen" toggleable="true" toggleSpeed="500" styleClass="mbsFieldSet">
<h:form id="form_positions">
<p:growl id="messages" showDetail="true" />
<!-- Add position mask -->
<!-- Button to open the open position mask -->
<p:commandButton id="btOpenAddPositionMask" value="Position via Dialog" onclick="dlg.show();">
</p:commandButton>
<p:dataTable var="banfPosition" value="#{banfPositionBean.lsBanfPositions}"
id="tableBanfPositions" editable="true" >
<f:facet name="header">Positionen</f:facet>
<!-- AJAX Events for editing position values -->
<p:ajax event="rowEdit" listener="#{banfPositionBean.onEdit}"
update=":form_positions:messages"/>
<p:ajax event="rowEditCancel" listener="#{banfPositionBean.onCancel}"
update=":form_positions:tableBanfPositions" />
<p:column headerText="Menge" style="width:50px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.amount}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.amount}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Matr. / Lager-Nr." style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.stockNumber}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.stockNumber}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Artikel" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.article}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.article}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Preis/Einheit" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.price}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.price}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Gesamtpreis" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.sum}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.sum}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Etat-Nr" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.etat}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.etat}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Anlagen-Nr" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.complex}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.complex}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Ändern" style="width:20px; text-align:center">
<p:rowEditor />
</p:column>
<p:column headerText="Löschen" style="width:20px; text-align:center" >
<p:commandButton id="deletePos" actionListener="#{banfPositionBean.deletePos(banfPosition)}"
update=":form_positions:tableBanfPositions" ajax="true" icon="ui-icon ui-icon-close" iconPos="center"
title="Löscht den Eintrag in dieser Zeile." />
</p:column>
</p:dataTable>
</h:form>
</p:fieldset>
<p:dialog header="Neue Position hinzufügen" widgetVar="dlg"
resizable="false">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel value="Artikel:" />
<p:selectOneMenu id="selectArticleForPosition"
value="#{banfPositionBean.selectedArticle}" var="art"
panelStyle="width:150px" style="width:260px" effect="fade"
filterMatchMode="starts" filter="true">
<f:selectItems value="#{dataBean.lsArticle}" var="article"
itemLabel="#{article.name}" itemValue="#{article}" />
<p:column>
#{art.id} - #{art.name}
</p:column>
</p:selectOneMenu>
</h:panelGrid>
<p:commandButton id="btAddPosition" value="Position einfügen"
actionListener="#{banfPositionBean.addPos()}"
update=":form_positions:tableBanfPositions" oncomplete="dlg.hide();"
ajax="true" process="#all" type="submit">
</p:commandButton>
</p:dialog>
</ui:composition>
I try it with the h:form-Tag as it is shown on http://www.primefaces.org/showcase/ui/dialogForm.jsf But If I add this.
<p:dialog header="Neue Position hinzufügen" widgetVar="dlg"
resizable="false">
<h:form id="form_dialog">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel value="Artikel:" />
<p:selectOneMenu id="selectArticleForPosition"
value="#{banfPositionBean.selectedArticle}" var="art"
panelStyle="width:150px" style="width:260px" effect="fade"
filterMatchMode="starts" filter="true">
<f:selectItems value="#{dataBean.lsArticle}" var="article"
itemLabel="#{article.name}" itemValue="#{article}" />
<p:column>
#{art.id} - #{art.name}
</p:column>
</p:selectOneMenu>
</h:panelGrid>
<p:commandButton id="btAddPosition" value="Position einfügen"
actionListener="#{banfPositionBean.addPos()}"
update=":form_positions:tableBanfPositions" oncomplete="dlg.hide();"
ajax="true" process="#all" type="submit">
</p:commandButton>
</h:form>
</p:dialog>
the page get reloaded but my bean will not be called either.
Do anyone have an idea what i am doing wrong?
Thanks for help.
-------------------------------------------
*EDIT*
-------------------------------------------
I try it with an p:inputText instead of an selectOneMenu an the bean gets called.
<p:dialog header="Neue Position hinzufügen" widgetVar="dlg"
resizable="false" appendToBody="true">
<h:form id="form_dialog">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="inputTxt" value="Artikel:" />
<p:inputText id="inputTxt" value="#{banfPositionBean.testStr}"></p:inputText>
</h:panelGrid>
<p:commandButton id="btAddPosition" value="Position einfügen"
actionListener="#{banfPositionBean.addPos()}"
update=":form_positions:tableBanfPositions" oncomplete="dlg.hide();">
</p:commandButton>
</h:form>
</p:dialog>
So I just need to find out why it will not work for the selectOneMenu.
First I don't know what is a type of property selectedArticle, I guess it is the same type as article (in itemValue) attribute. You should define converter or on the other hand you should bind value of selectOneMenu to be the same type as article.id, and set itemValue to #{article.id}.

Resources