function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sunfishettesunfishette 

Content of variable

I am trying to get the content of a variable and display it on a visualforce page in an effort to track where I am going wrong.  Something similar to Visual Basics MessageBox.Show(variable) or a javascripts alert(variable); function.

 

I need to make sure that what I "think" is inside my variable is actually there.  I am sure this is a simple thing, but I cant find the answer!

 

Thanks!

 

 

Best Answer chosen by Admin (Salesforce Developers) 
sunfishettesunfishette

For the rest of us that suck at Visualforce and Apex, the FULL answer was ( -- it took me an extra HOUR to figure out the syntax!):

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




with "variable" being the name of my variable

All Answers

Scott_VSScott_VS

To show a variable on a visualforce page, use {!variable} on the page.

 

To show a variable from within Apex code, use System.debug(variable). Then open the Developer Console, run the code, and check the log that is generated. 

sunfishettesunfishette

For the rest of us that suck at Visualforce and Apex, the FULL answer was ( -- it took me an extra HOUR to figure out the syntax!):

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




with "variable" being the name of my variable
This was selected as the best answer
sfdcfoxsfdcfox

It's actually not necessary to use outputText. Just using the merge syntax works fine:

 

<apex:page standardController="Account">
  This is the Account {!Account.Name}.
</apex:page>

But, you may need to use outputText if you want to disable automatic HTML escaping.