Find your content:

Search form

You are here

Passing multiple methods into Apex 'rendered' attribute

 
Share

Can I pass a second method into the rendered attribute of the following apex element?

    <apex:outputText rendered="{!(firstMethod == true)}">           
        <img class="refresh_btn" src="{!URLFOR($Resource.Images, 'images/icon_refresh.png')}" alt=""/>
    </apex:outputText>

Would this work?

    <apex:outputText rendered="{!(firstMethod == true)} && {!(secondMethod == true)}">          
        <img class="refresh_btn" src="{!URLFOR($Resource.Images, 'images/icon_refresh.png')}" alt=""/>
    </apex:outputText>

So both firstMethod and secondMethod must return true for the element to render.


Attribution to: Daft

Possible Suggestion/Solution #1

Yes, you can do that, but like this:

rendered="{!firstMethod == true && secondMethod == true}"

Alternative use AND function:

rendered="{!AND(firstMethod, secondMethod)}"

Attribution to: Sergej Utko

Possible Suggestion/Solution #2

Yes you can, although your syntax is a little off. The following should work:

<apex:outputText rendered="{!(firstMethod == true) && (secondMethod == true)}"> 

Which you should be able to reduce to:

<apex:outputText rendered="{!firstMethod && secondMethod}"> 

Attribution to: Alex Tennant
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/32040

My Block Status

My Block Content