The problem is, when I change the value of the spinner it puts the value instantly and if I click in cancel the values are been changed
see the code below:
Code: Select all
<p:dialog widgetVar="findServ"
id="findServ"
modal="true"
height="450"
width="800"
closable="false"
draggable="false"
resizable="false"
header="Serviços"
closeOnEscape="false">
<h:form id="formServ">
<p:panel>
<h:panelGrid columns="2">
<h:outputLabel>
Cód:
<h:inputText style="width: 100px;"
readonly="true"
value="#{contratoMB.servicoDoContrato.servico.codigo_produto}"
/>
Nome:
<h:inputText style="width: 350px;"
readonly="true"
value="#{contratoMB.servicoDoContrato.servico.nome}"
/>
</h:outputLabel>
<p:commandButton image="ui-icon-search"
process="@this"
onclick="dialogServ.show();"/>
</h:panelGrid>
<h:panelGrid columns="2">
<p:panel style="height: 180px;">
<h:panelGrid columns="2" width="200">
<h:outputLabel value="Unidade: "/>
<h:inputText readonly="true"
value="Un"
style="width: 100px;"/>
<h:outputLabel value="Quantidade: "/>
<p:spinner stepFactor="1"
min="0"
required="true"
requiredMessage="Campo [Quantidade] obrigatório"
value="#{contratoMB.servicoDoContrato.qtde}"
style="width: 100px;"
id="quantidade">
<p:ajax event="change"
process="quantidade"
listener="#{contratoMB.calculaPreco}"
update="total_serv"/>
</p:spinner>
<h:outputLabel value="Preço: "/>
<p:spinner min="0.00"
id="preco"
stepFactor="0.01"
value="#{contratoMB.servicoDoContrato.preco_unit}"
style="width: 100px;">
<p:ajax event="change"
process="preco"
listener="#{contratoMB.calculaPreco}"
update="total_serv" />
</p:spinner>
<h:outputLabel value="Total: "/>
<h:inputText style="width: 100px;"
id="total_serv"
readonly="true"
value="#{contratoMB.servicoDoContrato.preco_totalserv}">
<f:convertNumber type="currency" currencySymbol=""/>
</h:inputText>
</h:panelGrid>
</p:panel>
<p:panel>
<h:panelGrid columns="2" style="width: 455px;">
<h:outputLabel value="Finalidade: "/>
<h:selectOneMenu value="#{contratoMB.finalidade}"
converter="converteTAuxMovProdServ">
<f:selectItems value="#{contratoMB.finalidades}"
var="fin"
itemLabel="#{fin.finalidade}"
itemValue="#{fin}"/>
</h:selectOneMenu>
<h:outputLabel value="Periodicidade: "/>
<h:selectOneMenu>
<f:selectItem itemValue="Mensal" itemLabel="Mensal"/>
<f:selectItem itemValue="Bimestral" itemLabel="Bimestral"/>
<f:selectItem itemValue="Trimestral" itemLabel="Trimestral"/>
<f:selectItem itemValue="Semestral" itemLabel="Semestral"/>
<f:selectItem itemValue="Anual" itemLabel="Anual"/>
</h:selectOneMenu>
<h:outputLabel value="Próximo Pgto: "/>
<h:outputLabel >
<h:selectOneMenu>
<f:selectItem itemValue="1" itemLabel="Janeiro"/>
<f:selectItem itemValue="2" itemLabel="Fevereiro"/>
<f:selectItem itemValue="3" itemLabel="Março"/>
<f:selectItem itemValue="4" itemLabel="Abril"/>
<f:selectItem itemValue="5" itemLabel="Maio"/>
<f:selectItem itemValue="6" itemLabel="Junho"/>
<f:selectItem itemValue="7" itemLabel="Julho"/>
<f:selectItem itemValue="8" itemLabel="Agosto"/>
<f:selectItem itemValue="9" itemLabel="Setembro"/>
<f:selectItem itemValue="10" itemLabel="Outubro"/>
<f:selectItem itemValue="11" itemLabel="Novembro"/>
<f:selectItem itemValue="12" itemLabel="Dezembro"/>
</h:selectOneMenu>
de
<p:spinner stepFactor="1"
value="#{contratoMB.prox_pgto_ano}"
min="2011"
style="width: 55px;"
max="2100"/>
</h:outputLabel>
<h:outputLabel value="Prazo para reajuste: "/>
<h:outputLabel>
<p:spinner min="0"
value="#{contratoMB.servicoDoContrato.prazo_reajuste}"
style="width: 80px;"
stepFactor="3"/>
(meses)
</h:outputLabel>
<h:outputLabel value="Início Vigência: "/>
<p:inputMask mask="99/99/9999" style="width: 80px;"
required="true"
requiredMessage="Campo [Início Vigência] obrigatório"
value="#{contratoMB.inicioVigencia}">
</p:inputMask>
<h:outputLabel value="Término Vigência: "/>
<p:inputMask mask="99/99/9999" style="width: 80px;"
required="true"
requiredMessage="Campo [Término Vigência] obrigatório"
value="#{contratoMB.fimVigencia}">
</p:inputMask>
</h:panelGrid>
</p:panel>
</h:panelGrid>
<h:panelGrid columns="1">
<p:panel>
<h:panelGrid columns="2">
<h:outputLabel value="Observação: "/>
<h:inputTextarea cols="117"
value="#{contratoMB.servicoDoContrato.obs}"
rows="5"/>
</h:panelGrid>
</p:panel>
</h:panelGrid>
</p:panel>
<br/>
<p:commandButton image="ui-icon-plus" value="Adicionar"
disabled="#{empty contratoMB.servicoDoContrato.servico}"
action="#{contratoMB.adicionaServico}"
update="pesquisa:listaServicosContrato"
oncomplete="fechaAddServico(xhr, status, args);"/>
<p:commandButton image="ui-icon-cancel"
value="Cancelar"
process="@this"
onclick="findServ.hide();"/>
</h:form>
</p:dialog>