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
jdogsailingjdogsailing 

Conditional component display

I have a component that has two possible display formats, so I created a new sub-component for each. Now I can't figure out how to switch between them. The {!IF()} expression does not seem to get the job done. Here's the fragment:

 

<apex:component >
    <apex:attribute name="fragment" description="This is the fragment for the component"
                    type="SurveyFragment" required="true"/>
    {!IF(fragment.singleton,
        <c:SingletonResponseWidget fragment="{!fragment}" />,
        <c:TableResponseWidget fragment="{!fragment}" />)}
</apex:component>

 

 Can somebody suggest how to do this?

Jeff

Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

each component can be placed in an outputPanel

 

The outputPanels can render or not using an expression in the rendered attribute

 

something like this is what i've used :

 

 

<apex:outputPanel rendered="{!requestToken}"> blah... blah </apex:outputPanel> <apex:outputPanel rendered="{!$CurrentPage.parameters.token != null}"> other blah .. blah </apex:outputPanel>

 

 

you would use your own conditions in the rendered expressions, not the ones shown here.