+ Start a Discussion

Whats the difference betweet <apex:outputLabel> and <apex:outputtext>

Whats the difference between apex:outputLabel and apex:outputtext Both are looking for the same kind of purpose, whats the difference. Kiran.


Apex :Output Label

The outputLabel tag renders an HTML "label" element. It allows you to customize the appearance of the label using CSS styles. The outputLabel component is associated with another component via its "for" attribute. The other component must be created before the outputLabel component when the JSF page is rendered.

Note the use of the panelGroup container in the example below. The panelGroup component renders its children, allowing the outputLabel component to locate the inputText component at render time.



  <apex::outputLabel id="usernameLabel" for="username" value="#{bundle.usernameLabel}" />

  <apex::inputText id="username" value="#{userBean.user.username}}" />


 HTML Output

<label id="form:usernameLabel" for="form:username">Username</label>

<input id="form:username" name="form:username" type="text" value=""/>


Apex:Output Text


OutputText is for just that, text output, but keep in mind this will output text for html by default so it escapes characters as needed.

Displays text on a Visualforce page. You can customize the appearance of < apex:outputText > using CSS styles, in which case the generated text is wrapped in an HTML < span > tag. You can also escape the rendered text if it contains sensitive HTML and XML characters.




<apex:outputText style="font-style:italic" value="This is {0} text with {1}.">

       <apex:param value="my"/>

       <apex:param value="arguments"/>



HTML Output

<span>This is my text with arguments.</span>


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.