Class ASTExpression

    • Method Detail

      • getDataNodes

        public Map<VfTypedNode,​String> getDataNodes()
                                                   throws ASTExpression.DataNodeStateException

        An Expression can contain one or more strings that map to a piece of data. This method maps the string from the Visualforce page to terminal AST node that the string represents. The terminal node will be either an ASTIdentifier or ASTLiteral. It is the terminal node that is most important since it represents the type of data that will be displayed in the page.

        The string representation can be reconstructed by starting at the Identifier node and traversing its siblings until a node other than a DotExpression is encountered. Some more advanced situations aren't currently handled by this method. The method will throw an exception in such cases.

        
         <apex:outputText value="{!MyValue}" /> results in AST
         <Identifier Image='MyValue'/>
         The method would return key=ASTIdentifier(Image='MyValue'), value="MyValue"
         
        
         <apex:outputText value="{!MyObject__c.Text__c}" /> results in AST (It's important to notice that DotExpression is
         a sibling of Identifier.
         <Identifier Image='MyObject__c'/>
         <DotExpression Image=''>
             <Identifier Image='Text__c'/>
         </DotExpression>
         This method would return key=ASTIdentifier(Image='Text__c'), value="MyObject__c.Text__c"
         
        THE FOLLOWING SITUATIONS ARE NOT HANDLED AND WILL THROW AN EXCEPTION. This syntax causes ambiguities with Apex Controller methods that return Maps versus accessing a CustomObject's field via array notation. This may be addressed in a future release.
        
         <apex:outputText value="{!MyObject__c['Text__c']}" /> results in AST
         <Identifier Image='MyObject__c'/>
         <Expression Image=''>
             <Literal Image='&apos;Text__c&apos;'>
         </Expression>
        
         <apex:outputText value="{!MyObject__c[AnotherObject__c.Id]}" /> results in AST
         <Identifier Image='MyObject__c'/>
         <Expression Image=''>
             <Identifier Image='AnotherObject__c'/>
                 <DotExpression Image=''>
                     <Identifier Image='Id'/>
                 </DotExpression>
             </Identifier>
         </Expression>
         
        Throws:
        ASTExpression.DataNodeStateException - if the results of this method could have been incorrect. Callers should typically not rethrow this exception, as it will happen often and doesn't represent a terminal exception.