当前位置: 动力学知识库 > 问答 > 编程问答 >

jsf 2 - <f:convertNumber />and <f:convertDateTime /> is not working inside primefaces dialog

问题描述:

I am working with jsf 2.1 and primefaces 3.5

I am using "f:convertNumber" and "f:convertDateTime" to format the numbers and date, it is working in normal screen but, it is not working in dialog box(Once add button pressed, i am displaying the dialog box).

Here is my code:

<p:dialog id="receiptdialogprint" modal="true" widgetVar="printDlgId" header="Success" draggable="true" closable="false" resizable="false" maximizable="false" minimizable="false" style="font-family:Arial; font-size:11px;" appendToBody="true" width="50%">

<h:form id="receiptdialog_form">

<p:panelGrid id="payment_receipt_Panel" style="width:80%">

<p:row>

<p:column style="text-align:left;width:45%">

<p:outputLabel value="Date " style="font-size:16px" />

</p:column>

<p:column style="text-align:left;width:45%">

<h:outputText id="payment_date" value=":&#160;&#160; #{paymentreceipt.paymentdate}">

<!-- <f:convertDateTime for="payment_date" type="date"/> -->

<f:convertDateTime dateStyle="medium"/>

<f:convertDateTime type="date" pattern="dd-MM-yyyy" />

</h:outputText>

</p:column>

</p:row>

<p:row>

<p:column style="text-align:left;width:45%">

<p:outputLabel value="Annual Memebership Fee(In Rs) " style="font-size:16px" />

</p:column>

<p:column style="text-align:left;width:45%">

<h:outputText value=":&#160;&#160; #{paymentreceipt.paymentannualmemberfee_without_servicetax}" >

<f:convertNumber maxFractionDigits="2"/>

</h:outputText>

</p:column>

</p:row>

</<p:panelGrid>

</<h:form>

</p:dialog>

Output it showing like this:

Date : Fri Aug 01 14:21:53 IST 2014

Annual Memebership Fee(In Rs) : 3782.48487006052

For Others(In Rs) : 889.99644001424

Expected Out put:

Date :Friday, 1 August, 2014

Annual Memebership Fee(Without ST) :3,782.48

For Others(Without ST) :890

网友答案:

Try this,

             <p:row>
                <p:column style="text-align:left;width:45%">
                    <p:outputLabel value="Date :" style="font-size:16px" />
                </p:column>
                <p:column style="text-align:left;width:45%">

                    <h:outputText id="payment_date" value="#{paymentreceipt.paymentdate}">
                        <f:convertDateTime dateStyle="full" type="date"/>
                    </h:outputText>
                </p:column>
            </p:row>
            <p:row>
                <p:column style="text-align:left;width:45%">
                    <p:outputLabel value="Annual Memebership Fee(In Rs) :" style="font-size:16px" />
                </p:column>
                <p:column style="text-align:left;width:45%">
                    <h:outputText value="#{paymentreceipt.paymentannualmemberfee_without_servicetax}" >
                        <f:convertNumber maxFractionDigits="2" pattern="##,##0.00"/>
                    </h:outputText>
                </p:column>
            </p:row>

I am using richfaces if we use any special characters like space or : with the date and number format. It will not convert. So replace the colon and try. If you want the colon use seperate h:outputLabel for that.

分享给朋友:
您可能感兴趣的文章:
随机阅读: