jsf 2 - Primefaces Process binding problems -
i trying create data table editable , dynamic collumns , rows. when try process table, values entered not being processed (they coming null).
i post codes below , hope can me figure out going on.
(the code posting part of whole code, not working)
i creating table using binding attribute:
<p:panelgrid columns="2"> <p:panelgrid columns="1"> <h:outputtext value="fornecedor" styleclass="headercolumn" /> <p:panelgrid columns="2" columnclasses="inputbotao"> <p:selectonemenu value="#{orcamentoaction.idfornecedor}" id="selforn" filter="true" filtermatchmode="startswith"> <f:selectitem itemlabel=" - " itemvalue="#{null}" /> <f:selectitems value="#{orcamentoaction.fornecedores}" var="f" itemlabel="#{f.nomeforn}" itemvalue="#{f.idforn}" /> <p:ajax event="change" /> </p:selectonemenu> <p:commandbutton action="#{orcamentoaction.addfornecedor}" icon="ui-icon-plus" process=":formex:pftable @this" update=":formex:pftable :formex:selforn"> </p:commandbutton> </p:panelgrid> </p:panelgrid> <p:panelgrid columns="1"> <h:outputtext value="produto" styleclass="headercolumn" /> <p:panelgrid columns="2" columnclasses="inputbotao"> <p:selectonemenu value="#{orcamentoaction.idproduto}" id="selprod" filter="true" filtermatchmode="startswith"> <f:selectitem itemlabel=" - " itemvalue="#{null}" /> <f:selectitems value="#{orcamentoaction.produtos}" var="p" itemlabel="#{p.nomeprod}" itemvalue="#{p.idprod}" /> <p:ajax event="change" /> </p:selectonemenu> <p:commandbutton action="#{orcamentoaction.addproduto}" icon="ui-icon-plus" process=":formex:pftable @this" update=":formex:pftable :formex:selprod"> </p:commandbutton> </p:panelgrid> </p:panelgrid> </p:panelgrid> <p:datatable id="pftable" binding="#{orcamentoaction.datatable}" />
-
@managedbean @viewscoped @role(name = "orçamento") public class orcamentoaction { ... private datatable datatable; private static final object columns[][] = { { "produto", "produto.nomeprod", string.class, "width: 130px;" }, { "unidade", "produto.unidmedidaprod", string.class, "text-align: center; width: 50px;" }, { "quantidadae", "quantidade", float.class, "width: 75px;" } }; private static list<uicolumn> columns; ... private void createdatatable() { datatable = new datatable(); datatable.seteditable(true); datatable.seteditmode("cell"); datatable.setscrollable(true); datatable.setscrollwidth("750"); datatable.setscrollheight("150"); datatable.setemptymessage("nenhum item orçamento foi adicionado."); datatable.setresizablecolumns(true); datatable.setvar("o"); datatable.setvalue(list); } private void createcolumns() { columns = new arraylist<uicolumn>(); (int = 0; < columns.length; i++) { column c = new column(); c.setheadertext((string) columns[i][0]); if (i != 2) { htmloutputtext outputtext = new htmloutputtext(); outputtext.setvalueexpression("value", facesutils.getexpressionfactory().createvalueexpression( facesutils.getelcontext(), "#{o." + columns[i][1] + "}", (class<?>) columns[i][2])); c.getchildren().add(outputtext); } else { celleditor celleditor = new celleditor(); htmloutputtext outputtext = new htmloutputtext(); outputtext.setvalueexpression("value", facesutils.getexpressionfactory().createvalueexpression( facesutils.getelcontext(), "#{o." + columns[i][1] + "}", (class<?>) columns[i][2])); celleditor.getfacets().put("output", outputtext); inputtext inputtext = new inputtext(); inputtext.setvalueexpression("value", facesutils.getexpressionfactory().createvalueexpression( facesutils.getelcontext(), "#{o." + columns[i][1] + "}", (class<?>) columns[i][2])); celleditor.getfacets().put("input", inputtext); c.getchildren().add(celleditor); } c.setstyle((string) columns[i][3]); columns.add(c); } if (fornecedorescolumns != null && !fornecedorescolumns.isempty()) { (int = 0; < fornecedorescolumns.size(); i++) { fornecedor fornecedor = fornecedorescolumns.get(i); column c = new column(); c.setheadertext(fornecedor.getnomeforn()); celleditor celleditor = new celleditor(); htmloutputtext outputtext = new htmloutputtext(); outputtext.setvalueexpression("value", facesutils.getexpressionfactory().createvalueexpression( facesutils.getelcontext(), "#{o.precos[" + + "]}", float.class)); numberconverter numberconverter = new numberconverter(); numberconverter.settype("currency"); numberconverter.setcurrencycode("brl"); outputtext.setconverter(numberconverter); celleditor.getfacets().put("output", outputtext); inputtext inputtext = new inputtext(); inputtext.setvalueexpression("value", facesutils.getexpressionfactory().createvalueexpression( facesutils.getelcontext(), "#{o.precos[" + + "]}", float.class)); numberconverter = new numberconverter(); numberconverter.settype("currency"); numberconverter.setcurrencycode("brl"); inputtext.setconverter(numberconverter); celleditor.getfacets().put("input", inputtext); c.getchildren().add(celleditor); columns.add(c); } } datatable.setcolumns(columns); } public void addfornecedor() { if (idfornecedor != null) { fornecedor fornecedor = fornecedordao.load(idfornecedor); fornecedorescolumns.add(fornecedor); fornecedores.remove(fornecedor); (orcamentoprodutovo vo : list) { vo.getprecos().add(null); } createcolumns(); } } public void addproduto() { if (idproduto != null) { produto produto = produtodao.load(idproduto); produtos.remove(produto); orcamentoprodutovo vo = new orcamentoprodutovo(); vo.setproduto(produto); (int = 0; < fornecedorescolumns.size(); i++) { vo.getprecos().add(null); } list.add(vo); } } ... } public class orcamentoprodutovo implements serializable { private static final long serialversionuid = 1l; private produto produto; private float quantidade; private list<float> precos; public orcamentoprodutovo() { precos = new arraylist<float>(); } .... }
the values passed backing bean null
, because don't have h:form
wrapped around p:datatable
.
Comments
Post a Comment