0

I know this is the format for displaying outputs on to VF pages

<apex:pageBlock title="CustomObject">
    <apex:pageBlockSection>
        <apex:outputField value="{! CustomObject.var1 }"/>
        <apex:outputField value="{! CustomObject.var2 }"/>
        <apex:outputField value="{! CustomObject.var3 }"/>
        <apex:outputField value="{! CustomObject.var4 }"/>
    </apex:pageBlockSection>
</apex:pageBlock>

I was wondering if we can display independent variable values . for example-

<apex:outputField value="{!var5 }"/>

where var5 is an int value calculated in the custom controller and is not an attribute of the custom object.

2 Answers 2

5

<apex:outputField value="{!var5 }"/>

change this into

<apex:outputText value="{!var5 }"/>

It will work for you. apex:outputfield works with Object field while displaying controller variable you can use apex:outputText

2
  • Can i display a collection(List) of values using Output Text?? How can I do this?
    – goSF
    Commented Nov 24, 2015 at 21:27
  • to display a list you need to use apex:repeat. Commented Nov 25, 2015 at 5:11
2

If you want to display any integer values or string values.

Use apex:outputText

<apex:outputText value="{!var5}"/>

<apex:outfield> bind with only sobject's field

Display List<String> lstString = new List<String>(); in VF page.

<apex:repat value="{!lstString }" var="str"/>
<apex:outputText value="{!str}"/>
</apex:repeat>
2
  • Can i display a collection(List) of values using Output Text?? How can I do this?
    – goSF
    Commented Nov 24, 2015 at 21:27
  • Yes you can. Updated my ans above.
    – Ratan Paul
    Commented Nov 25, 2015 at 2:26

You must log in to answer this question.

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