【问题标题】:Inconsistent rendering of Date and ID value in Visualforce pageVisualforce 页面中日期和 ID 值的呈现不一致
【发布时间】:2013-06-26 15:56:00
【问题描述】:

我无法理解为什么 VF 页面上显示的数据不一致。我在页面块表中显示 Id 和 Date。我正在使用 apex:column 标签来显示数据。当我在没有任何空格的值属性中声明数据时,我得到长度为 15 个字符的 Id,但是当我在值属性中包含一个空格时,会显示一个 18 个字符的 Id。我无法理解为什么会这样?

<apex:pageblock>
<apex:pageblockTable value="{!acc}" var="a">
     <apex:column value="{!a.Id}" headerValue="Id without space(15 char)"/>
     <apex:column value=" {!a.Id}" headerValue="Id with space(18 char)"/>
     <apex:column value="{!a.CreatedDate}" headerValue="Date defined in the Value attributes"/>
     <apex:column headerValue="Date not declared in the Value Attribute" >{!a.CreatedDate}</apex:column>
</apex:pageblockTable>
</apex:pageblock>

【问题讨论】:

    标签: salesforce apex-code visualforce force.com


    【解决方案1】:

    当您只拉出列而不使用任何空格时,Visualforce 会使用该类型的开箱即用界面显示该字段。根据API docs

    Salesforce 用户界面中的 ID 字段包含 15 个字符、base-62、区分大小写的字符串

    将字符串附加到 ID 字段时,会将 ID 的值转换为字符串。由于页面只对值感兴趣,例如 SOQL 查询或 Apex 字符串方法,因此会返回“原始”值。

    所有 API 调用都会返回一个 18 位、大小写安全的 ID 版本

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-02
      相关资源
      最近更新 更多