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
SurjenduSurjendu 

How to conditionally show a component?

I need to show a outputPanel depending on some clause.

IF(errorExists)
{
    <apex:pageBlockSection>
        <apex:outputText style="font-style:italic;font-weight:bold;color:red" value="{!error.errorDescription}"/>
    </apex:pageBlockSection>
}
else
{
    //show something else
}

How do I do this in VisualForce Page? Also the errorExists has to be read from the custom controller. Something like IF({!error.errorExists})???

Please help?
EnderEnder
Checkout the "rendered" attribute.  Should do you nicely.

Usually I wrap stuff in an output panel tag when I'm switching off a rendered true vs false.


SurjenduSurjendu
Thanks..I figured the rendered attribute after posting the message....:-)
dchasmandchasman
All components (and now custom components!) support the rendered attribute directly and I tend to only wrap in a container (e.g. apex:outputPanel) when I need to show or hide a group of components.