6

I am unable to understand why the inconsistency of the data that is displayed on the VF page. I am displaying Id and Date in the page block table. I am using the apex:column tag to display the data. When I declare the data in the value attribute without any space I get Id with 15 char in length but when I include a space in the value attirbute a 18 char Id is displayed. I am unable to understand why so?

enter image description here

<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>
2
  • 4
    I think we're going to need an internal Salesforce person to answer this. It's likely to do with how the Visualforce processer and parse deals with types. Is suspect that in each case one option involves a type cast to a string and the other uses a formatting/conversion method.
    – Matt Lacey
    Commented Jun 27, 2013 at 7:01
  • 1
    @LaceySnr personally I think you've hit apone the most likely answer here. Passing binding values to the attributes will result in the component dealing with it as the type it is, using a binding inline in the page will effectively call the .toString() result, as the context the output is going to is unknown this is the most generic option. Commented Jun 27, 2013 at 8:41

1 Answer 1

3

Unless we can get a definitive answer I'm going to go with automatic type conversion issues.

It seems likely that in the case of variables being inserted directly into the page (like the unformatted date) then the system will not necessarily understand the context of what is happening and perform a direct conversion of the value in question to a string.

When the date when is used in the value expression: value="{!a.CreatedDate}" then it would seem that it knows to treat it as a date.

What I can't explain right now is the difference with the ID, the space clearly makes a difference yet this is not the case when dealing with the date value.

4
  • It might be the same thing, when you do the value=" {!a.id}" its really doing (' ' + id.toString) and perhaps the concatenation of space and id results in a different outcome??? Commented Jun 28, 2013 at 4:38
  • Thanks LaceySnr. That makes sense. I think when we bind it to a value attribute the rendered data is formatted in a predetermined format else the raw data is displayed.
    – Sam
    Commented Jun 28, 2013 at 4:54
  • Steven that's what I was thinking, but it doesn't seem to affect dates the same way!
    – Matt Lacey
    Commented Jun 28, 2013 at 5:03
  • I think the implementation are dependent on the type of data that is bound. As said earlier by LaceySnr only a developer from salesforce will be able to answer this! :)
    – Sam
    Commented Jun 28, 2013 at 7:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .