localization的一些示例以供参考。

本文示例均来源于Oracle官网Working with Localization Formatting章节,详细资料可以参考 http://docs.oracle.com/cd/E36909_01/fusionapps.1111/e15524/ui_localize.htm

货币的格式化

Example 20-1 Syntax of fnd:currencyPatternWithPrecisionAndSymbol

fnd:currencyPatternWithPrecisionAndSymbol( 
  bindingToAmountCurrencyCode, bindingToAttrNamePrecision, 
  bindingToAttrNameCurrencySymbol)
Example 20-3 Number Preferences Determine Grouping and Decimal Separators

<af:outputText value="#{node.Amount}" id="ot28">
<af:convertNumber type="currency"
  currencyCode="#{bindings.CurrencyCode.attributeValue}"
  pattern="#{fnd:currencyPatternWithPrecisionAndSymbol
                 (bindings.CurrencyCode.attributeValue,2,'symbol'}"/>
</af:outputText>

数字格式化

Example 20-6 Formatting Decimal Output Fields

<af:outputText value="#{bindings.FromValue.inputValue}" id="ot19">
<af:convertNumber pattern="#{applCorePrefs.numberFormatPattern}"/>
</af:outputText>
Example 20-7 Formatting Input Decimal Fields

<af:inputText value="#{row.bindings.FromValue.inputValue}"
    label="#{bindings.PerformanceThreshold21.hints.FromValue.label}"
    required="#{bindings.PerformanceThreshold21.hints.FromValue.mandatory}"
    columns="#{bindings.PerformanceThreshold21.hints.FromValue.displayWidth}"                                              maximumLength="#{bindings.PerformanceThreshold21.hints.FromValue.precision}"
    shortDesc="#{bindings.PerformanceThreshold21.hints.FromValue.tooltip}"
    id="inputText9"
    autoSubmit="true">
    <af:convertNumber pattern="#{applCorePrefs.numberFormatPattern}"/>
</af:inputText>
Example 20-8 Decimal Number Formatting

<af:image id="img65"
     source="/images/upgreenplus_status.png"
     shortDesc="#{af:formatNamed(prcponnegotiationsuiBundle3['AltTxt.IncreasedbyVALUE.FavorablyIncreasedbyVALUE'], VALUE', fnd:formatNumber(bindings.ActiveResponsesChangeAmt.inputValue))}"
     visible="#{bindings.ActiveResponsesChange.inputValue == 'INCREASE'}"/>
Example 20-9 Using the fnd:formatNumber2 Function

<af:showDetailItem text="#{PjbWorkareaGenBundle['Header.SubmittedValues']} (#{fnd:formatNumber2(pageFlowScope.InvoiceWorkareaBean.invoiceValueRowNum[1],2)})"
       id="tabSubmitted"
       disclosureListener="#{InvoiceListBean.changeStatusTab}"
       partialTriggers="AT1:_ATp:menuSubmit AT1:_ATp:btnSubmit AT2:_ATp:menuApprove AT2:_ATp:menuReject AT2:_ATp:menuRelease AT2:_ATp:menuReturntoDraft cl1"
       stretchChildren="first"
       disclosedTransient="true"
       disclosed="#{pageFlowScope.pageFocus == '2'}">
Example 20-10 Formatting Integer Numbers

<af:outputText value="#{bindings.integerQuantity.inputValue}" id="ot19">
<af:convertNumber pattern="#{applCorePrefs.integerFormatPattern}"/>
</af:outputText>
Example 20-11 Formatting Input Integer Fields

<af:inputText value="#{bindings.Point1.inputValue}"
        label="#{bindings.Point1.hints.label}"
        required="#{bindings.Point1.hints.mandatory}"
        columns="#{bindings.Point1.hints.displayWidth}"
        maximumLength="#{bindings.Point1.hints.precision}"
        shortDesc="#{bindings.Point1.hints.tooltip}"
        inlineStyle="width:100%; border-color:InactiveBorder; border-width:thin;"
        id="inputText5">
    <f:validator binding="#{bindings.Point1.validator}"/>
    <af:validateLongRange minimum="0"/>
    <af:convertNumber pattern="#{applCorePrefs.integerFormatPattern}"/> 
 </af:inputText>
Example 20-13 Formatting ID Numbers

<af:column headerText="#{bindings.Deliveries.hints.SalesOrderLine.label} id="c9" >
   <af:outputText value="#{row.bindings.SalesOrderLine.inputValue}"
      label="#{bindings.Deliveries.hints.SalesOrderLine.label}" id="outputText3">
      <af:convertNumber pattern="#{applCorePrefs.numericCodeFormatPattern}"/>
   </af:outputText>
</af:column>
Example 20-14 Formatting Input Integer Fields

<af:inputText value="#{bindings.SequenceNumber.inputValue}"
         label="#{bindings.SequenceNumber.hints.label}"
         required="#{bindings.SequenceNumber.hints.mandatory}"
         columns="#{bindings.SequenceNumber.hints.displayWidth}"
         id="inputText1"
         partialTriggers="asgStat"
         helpTopicId="InvCoreSetup_755E15370133C364E040D30A688161D5V000"
         contentStyle="text-align:start"
         autoSubmit="true">
     <f:validator binding="#{bindings.SequenceNumber.validator}"/>
     <af:convertNumber pattern="#{applCorePrefs.numericCodeFormatPattern}"/>
 </af:inputText>
Example 20-15 Formatting Numbers in Hyperlinks

<af:commandLink id="outputText6" text="" 
                partialSubmit="true" immediate="true" 
                action="#{LocalAreaHandlerBean.showInventory}">
   <af:outputText value="#{row.InvPendingCount}" id="ot1">
      <af:convertNumber type="number" pattern=
          "#{applCorePrefs.integerFormatPattern}"/>
   </af:outputText>
</af:commandLink>
Example 20-16 Formatting a Number in af:goLink

<af:goLink text="" id="gl1"  destination="#{row.children[0].FileUrl}">
     <af:outputText id="id1" value="#{bindings.fromValue.inputValue}">
          <af:convertNumber type="number"
               pattern="#{applCorePrefs.numberFormatPattern}"/>
     </af:outputText>
 </af:goLink>
Example 20-17 Formatting a Number in a commandLink

<af:commandLink id="outputText6"text
     ="#{fnd:formatNumber2(row.InvPendingCount,0)}"
     partialSubmit="true" immediate="true" 
     action="#{LocalAreaHandlerBean.showInventory}">
</af:commandLink>
Example 20-18 Formatting af:goLink Using fnd:formatNumber

<af:goLink text="#{fnd:formatNumber(bindings.fromValue.inputValue)}" id="gl1"  destination="#{row.children[0].FileUrl}"/>
Example 20-19 Displaying Percentage Values

<af:outputText value="#{row.PercentComplete != null ? 
                   (row.PercentComplete * 0.01):  row.PercentComplete}"
                   id="outputText5">
     <af:convertNumber minFractionDigits="2" maxFractionDigits="2" 
                   type="percent"/>
     <af:showPopupBehavior triggerType="click"
                   popupId=":::progressTrendPopup"
                   alignId="rowHeadCol"/>
 </af:outputText>
Example 20-20 Formatting Input Percentage Fields

<af:inputText value="#{bindings.PercentQuantity.inputValue}"
     label="#{bindings.PercentQuantity.hints.label}"
     autoSubmit="true"
     id="inputText10"
     <f:validator binding="#{bindings.PercentQuantity.validator}"/>
     <af:convertNumber type="percent" minFractionDigits="2"
          maxFractionDigits="2"/>
</af:inputText>

日期格式化

Example 20-22 Formatting Dates with dateFormatPattern

<af:column sortProperty="OrderDate" filterable="true" 
           sortable="true"headerText=
           "#{bindings.NlsOrders1.hints.OrderDate.label}"
           id="c1">
<f:facet name="filter">
     <af:inputDate value="#{vs.filterCriteria.OrderDate}" 
                    id="id8" >
               <af:convertDateTime pattern="#{applCorePrefs.dateFormatPattern}"/>
     </af:inputDate>
</f:facet>
<af:inputDate value="#{row.bindings.OrderDate.inputValue}"
              label="#{bindings.NlsOrders1.hints.OrderDate.label}"
              required="#{bindings.NlsOrders1.hints.OrderDate.mandatory}"
              shortDesc="#{bindings.NlsOrders1.hints.OrderDate.tooltip}"
              id="id1">
     <f:validator binding="#{row.bindings.OrderDate.validator}"/>
     <af:convertDateTime pattern="#{applCorePrefs.dateFormatPattern}"/>
</af:inputDate>
</af:column>
Example 20-23 Getting the Current Date in UPTZ Using java Bean Classes

import java.sql.Date;
import oracle.apps.fnd.applcore.common.ApplSessionUtil;
...
Date currentDate = ApplSessionUtil.getCurrentLocalSqlDate();
...
Example 20-24 shows how to display the current date in the JSF page.

Example 20-24 Displaying the Current Date in the JSF Page

<af:outputText value="#{applCorePrefs.currentLocalSqlDate}" id="ot1">
          <af:convertDateTime pattern="#{applCorePrefs.dateFormatPattern}"/>
</af:outputText>
example shows how to set the current date in UPTZ as a value in entity object files.

Example 20-25 Setting the Current Date in UPTZ as a Value in Entity Object Files

<Attribute 
    Name="CreationDate" 
    IsNotNull="true" 
    ColumnName="CREATION_DATE" 
    SQLType="TIMESTAMP" 
    Type="java.sql.Date" 
    ColumnType="DATE" 
    TableName="FND_TERRITORIES_B" 
    RetrievedOnInsert="true"> 
    <DesignTime> 
      <Attr Name="_DisplaySize" Value="11"/> 
    </DesignTime> 
    <TransientExpression><![CDATA[oracle.apps.fnd.applcore.common.
      ApplSessionUtil.currentLocalSqlDate]]> 
    </TransientExpression> 
  </Attribute>
Example 20-26 Formatting Timestamp Values

<af:column sortProperty="LastUpdateDate" filterable="true" 
           sortable="true"
           headerText="#{bindings.NlsOrders1.hints.LastUpdateDate.label}"
           id="c1">
<f:facet name="filter">
         <af:inputDate value="#{vs.filterCriteria.LastUpdateDate}" id="id8" >
             <af:convertDateTime pattern="#{applCorePrefs.UPTZPattern}"/>
         </af:inputDate>
</f:facet>
<af:inputDate value="#{row.bindings.LastUpdateDate.inputValue}"
              label="#{bindings.NlsOrders1.hints.LastUpdateDate.label}"
              required="#{bindings.NlsOrders1.hints.LastUpdateDate.mandatory}"
              shortDesc="#{bindings.NlsOrders1.hints.LastUpdateDate.tooltip}"
              id="id1">
    <f:validator binding="#{row.bindings.LastUpdateDate.validator}"/>
    <af:convertDateTime pattern="#{applCorePrefs.UPTZPattern}"/>
</af:inputDate>
</af:column>

格式化时区

In Oracle Fusion Applications, datetime values can be calculated according to one of these time zones:

Server Reporting Time Zone

This is the default and simply is the time zone of the server's operating system.

User Preferred Time Zone (UPTZ)

When UPTZ is used, the date-time changes in the UI when a user changes the Time Zone preference in User Preferences. For example, if a user switches the Time Zone preference from UTC-08:00 to UTC-11:00, the date-time 04/27/2010 01:00:00 will change to 04/26/2010 23:00:00. The value in the database is not changed, and the conversion occurs after the value is retrieved from the database and before it is shown on the user interface.

Legal Entity Time Zone (LETZ)

LETZ is defined with legal entities. It is an attribute of a legal entity business object. For example, when creating a legal entity ORACLE-CDC, it can have a time zone attribute (LETZ) which value is UTC+08:00. Thus a date-time 04/27/2010 01:00:00 in UTC will change to 04/27/2010 09:00:00 accordingly. The value in the database is not changed, and the conversion occurs after the value is retrieved from the database and before it is shown on the user interface.
Example 20-28 Using the Server Reporting Time Zone

<af:outputText value="#{bindings.StartDate.inputValue}" ... >
     <af:convertDateTime type="both" pattern="#{applCorePrefs.UPTZPattern}" />
</af:outputText>
Example 20-29 Using the Preferred Time Zone

<af:outputText value="#{bindings.StartDate.inputValue}" ... >
     <af:convertDateTime type="both" pattern="#{applCorePrefs.UPTZPattern}"
                         timeZone="#{applCorePrefs.UPTZ}" />
</af:outputText>
Use this PL/SQL API to obtain the Legal Entity Time Zone code. This API is found in the package XLE_LE_TIMEZONE_GRP and is to be called in the following way:

Get_Le_Tz_Code(?,?)
Example 20-30 Using Get_Le_Tz_Code(?,?)

l_timezone_code = XLE_LE_TIMEZONE_GRP.Get_Le_Tz_Code('BUSINESS_UNIT_ID', p_ou_id);
l_timezone_code = XLE_LE_TIMEZONE_GRP.Get_Le_Tz_Code ('INVENTORY_ORG_ID', p_inv_org_id);
l_timezone_code = XLE_LE_TIMEZONE_GRP.Get_Le_Tz_Code ('LEGAL_ENTITY_ID', p_le_id);
Example 20-31 Determining the Current Date and Time in the LETZ

l_sysdate = XLE_LE_TIMEZONE_GRP .Get_Le_SysDate_Time('BUSINESS_UNIT_ID', p_ou_id);
l_sysdate = XLE_LE_TIMEZONE_GRP .Get_Le_SysDate_Time ('INVENTORY_ORG_ID', p_inv_org_id);
l_sysdate = XLE_LE_TIMEZONE_GRP .Get_Le_SysDate_Time ('LEGAL_ENTITY_ID', p_le_id);
Example 20-32 Converting a Date and Time to the LETZ Using Get_Le_Day_Time

l_le_day_time = XLE_LE_TIMEZONE_GRP . Get_Le_Day_Time ('BUSINESS_UNIT_ID', p_ou_id, p_trxn_date);
l_le_day_time = XLE_LE_TIMEZONE_GRP . Get_Le_Day_Time ('INVENTORY_ORG_ID', p_inv_org_id. p_trxn_date);
l_le_day_time = XLE_LE_TIMEZONE_GRP . Get_Le_Day_Time ('LEGAL_ENTITY_ID', p_le_id, p_trxn_date);
Example 20-33 Converting the LETZ Timestamp to the Server Time Zone with Get_Server_Day_Time(?,?,?)

l_Server_Date := XLE_LE_TIMEZONE_GRP .Get_Server_Day_Time ('INVENTORY_ORG_ID', p_inv_org_id, p_Le_Date);
l_Server_Date := XLE_LE_TIMEZONE_GRP .Get_Server_Day_Time ('BUSINESS_UNIT_ID', p_ou_id, p_Le_Date);
l_Server_Date := XLE_LE_TIMEZONE_GRP. Get_Server_Day_Time ('LEGAL_ENTITY_ID', p_inv_org_id, p_Le_Date);
 
Example 20-34 Converting a Date Field into the LETZ

<af:inputDate value="#{bindings.InvoiceDate.inputValue}"
              label="#{bindings.InvoiceDate.hints.label}"
              required="#{bindings.InvoiceDate.hints.mandatory}"
              shortDesc="#{bindings.InvoiceDate.hints.tooltip}"
              showRequired="true" autoSubmit="true"
              valueChangeListener="#{pageFlowScope.invoiceActionsBean.
                                  invoiceDateValueChangeListener}"
              columns="#{bindings.InvoiceDate.hints.displayWidth}"
              disabled="#{pageFlowScope.matchPopupVisible}"
              id="id2">
     <f:validator binding="#{bindings.InvoiceDate.validator}"/>
     <af:convertDateTime pattern="#{applCorePrefs.dateFormatPattern}"/>
</af:inputDate>
Example 20-35 Using the setOrgID() Method

public void setOrgID(Long orgID)
{
     ...
     // To convert the current timestamp to the LETZ, call another method
     // getLEDateTime.
this.setInvoiceDate(this.getLEDateTime(orgID, this.getDBTransaction()));
}
//This method calls the PL/SQL API to get the current date and time in the LETZ.
public Date getLEDateTime(Long orgId, DBTransaction dbTransaction)
{
  // 1. Define the PL/SQL block for the statement to invoke
  String stmt = "begin ? := XLE_LE_TIMEZONE_GRP.Get_Le_Sysdate_Time(?,?);  end;";
  // 2. Create the CallableStatement for the PL/SQL block
  st = (OracleCallableStatement)dbTransaction.createCallableStatement(stmt, 0);
  // 3. Register the positions and types of the OUT parameters
  st.registerOutParameter(1, Types.DATE);
  // 4. Set the bind values of the IN parameters
  st.setObject(2,"BUSINESS_UNIT_ID");
  st.setObject(3,orgId);
  //5. Execute Query
  st.executeUpdate();
 return  st.getDate(1);
}
 
Example 20-62 Area Graph Y1 Axis Currency Value Formatting

<dvt:y1TickLabel>
       <af:convertNumber  pattern="#{ fnd:currencyPattern(YourCurrencyCode)}"/>
</dvt:y1TickLabel>
<dvt:markerText><dvt:y1Format>
<af:convertNumber pattern="#{ fnd:currencyPattern(YourCurrencyCode) }/>
</dvt:y1Format></dvt:markerText>

 

发表评论