I have a method of SessioScoped bean called by the action attribute of a p:commandbutton . Nevertheless, the action is only called the second time i click the button.
here is the code : I´m not postig the complete page cause is long, only the datatable with rowselection that renders and displays the dialog with commandbutton in question (Inserir) The dialog is inside an outputpanel so becaus is the onçy way i could ajax rendered it. I tested by putting the exactly same panelgrid inside an ajax rendered p:panel in one of the layoutUnits, and the same thing happend , so it´s not the fact of being inside a dialog.
produtoBean is SessionScoped.
Code: Select all
<f:view>
<h:body>
<p:layout fullPage="true" >
<p:layoutUnit id="left" position="left" resizable="true" width="400" minWidth="200" scrollable="true" >
<p:tabView>
<p:tab title="Produtos">
<h:form>
<p:dataTable var="produto" value="#{produtoBean.lista}"
emptyMessage="Nenhum produto achado com essa descrição"
selection="#{produtoBean.produto}" selectionMode="single"
onRowSelectUpdate="produto" onRowSelectComplete="produtoDialog.show()" >
<p:column filterBy="#{produto.descricao}"
headerText="Descricão"
filterMatchMode="startsWith">
<h:outputText value="#{produto.descricao}" />
</p:column>
<p:column headerText="Preço" style="width:70px;" >
<h:outputText value="#{produto.precoVenda}" converter="moneda"/>
</p:column>
</p:dataTable>
</h:form>
</p:tab>
<p:tab> ...
</p:tab>
</p:tabView>
</p:layoutUnit>
...(other layout units here)
</p:layout>
....
<p:outputPanel id="produto" >
<h:form prependId="false">
<p:dialog header="Produto escolhido" widgetVar="produtoDialog" resizable="false"
width="600" position="center" draggable="false" modal="true">
<h:panelGrid columns="5" cellpadding="10" >
<h:outputLabel value="#{produtoBean.produto.descricao}" />
<h:outputLabel value="Preço :" style="font-weight: bold;"/>
<h:outputLabel value="#{produtoBean.produto.precoVenda}" converter="moneda"/>
<p:spinner id="qtde2" value="#{produtoBean.qtde}" min="1" max="100" style="width:40px;" />
<p:commandButton value="Inserir" action="#{produtoBean.adicionaItem}" update="center" />
</h:panelGrid>
</p:dialog>
</h:form>
</p:outputPanel>
</h:body>
</f:view>
</html>
I would really apreciate your help.
Thank you!