0
This is my method in managerBean
public void carregarDadosVenda(){
vendaCadastro.setHorario(new Date());
}
this is my page;
<p:panelGrid columns="2">
<h:outputText id="txtVendaValorTotal"
value="Valor Total: #{carrinhoComprasBean.vendaCadastro.valor} " />
<p:commandButton value="Finalizar Venda"
action="#{carrinhoComprasBean.carregarDadosVenda}"
oncomplete="PF('wvDlgFinVenda').show();" />
</p:panelGrid>
</h:form>
<p:dialog closable="true" draggable="true" modal="true"
resizable="false" header="Dados da Venda" widgetVar="wvDlgFinVenda"
appendTo="@(body)">
<h:form>
<p:panelGrid columns="2">
<h:outputText value="Horário " />
<h:outputText value="#{carrinhoComprasBean.vendaCadastro.horario}">
<f:convertDateTime pattern="dd/MM/yyyy"/>
</h:outputText>
<h:outputText value="Nome da Noticia " />
<h:outputText />
<h:outputText value="Valor Toral " />
<h:outputText />
</p:panelGrid>
<p:panelGrid columns="2">
<p:commandButton value="Salvar: " />
<p:commandButton value="Voltar: "
onclick="PF('wvDlgFinVenda').hide();" />
</p:panelGrid>
</h:form>
And I put this in the web.xml file
<context-param>
<param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
<param-value>true</param-value>
</context-param>
why doesn’t the date appear on my message box anyway?
I printed the value like this;
public void carregarDadosVenda(){
vendaCadastro.setHorario(new Date());
System.out.println("Horário >>>>>>>>>>>>>>>>" + vendaCadastro.getHorario());
}
And I got that result here;
Time >>>>>>>>>>>>>>>Mon Aug 31 14:59:05 BRT 2015
=======================================================================
Something even stranger happened;
I decided to redo the code all over again, and with that it worked again, but the time was wrong, and I wanted to synchronize the time with the Tomcat server, and I put this line of code on the web.xml
<context-param>
<param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
<param-value>true</param-value>
</context-param>
After I did this no longer appears the time in the dialog box, I even delete in the code line of the web.xml file, but no way, the time no longer appears in the dialog box.
why does this happen?
You have already printed on the console that date?
– Wellington Avelino
I just updated my post, take a look please.
– wladyband
I updated my post once again, take a look please.
– wladyband
Let me see if I understand, you want to display a date formatted in a text field?
– DiegoAugusto
positive, because there is some problem?
– wladyband
Would you have any good suggestions?
– wladyband