I have an output panel inside my apex:repeat tag.

My requirement is to conditionally display it.

So for one element in apex:repeat this panel might be rendered ..for some not. Rendering condition is,i need to check whether line item occurs in another controller set variable.

I find it difficult because of following reasons;

1)I understand you cannot check whether a set variable contains this element on visualforce page .or is this possible

2) i can see you cannot pass arguments in your rendered attribute.else i could have specify a boolean value for rendered attribute and set the value based on lineitem passed from front end

3)as the set variable is totally unrelated to line item.i cannot simply specify as below

<apex:repeat value="{!Proposals}" var="item">
        <apex:outputPanel rendered="{!item.LineCount > 0}">

Any clue experts Also it is one icon on the element i don't want to display.(not the whole element as such)(but that doesnt make much difference i guess)

2 Answers 2


A wrapper class is useful in this scenario. There is not enough controller code in the question to know for sure, but the implementation may look like something like this:

In the controller, define the wrapper class and change the method to return wrappers rather than sObjects. The controller will build the wrapper and set the isRendered member variable based on whether the sObject is contained in a Set someplace else in the controller.

public class ProposalWrapper {
    public Proposal__c proposal     { get; set; }
    public Boolean     isRendered   { get; set; }

public List<ProposalWrapper> getProposalWrappers() {
    List<ProposalWrapper> proposalWrappersToReturn = new List<ProposalWrapper>();

        // iterate over the list of Proposal__c sObjects
    for (Proposal__c proposal : ProposalsFromSomeList) {

        // create a wrapper to allow you to indicate visibility
        ProposalWrapper pWrapper = new ProposalWrapper();

        // stick the sObject into the wrapper
        pWrapper.proposal = proposal;

        // set the boolean field true/false based on whether the item is in the set
        pWrapper.isRendered = yourSet.contains(proposal);

        // add the wrapper to the list being returned

    return proposalWrappersToReturn;


In the page:

<!-- iterate over the wrappers and use the boolean field to control visibility -->
<apex:repeat value="{!ProposalWrappers}" var="item">
    <apex:outputPanel rendered="{!item.isRendered}">
            <apex:outputText value="{!item.proposal.Id}" />
            <apex:outputText value="{!item.proposal.Name}" />
  • yes ..adding element to the wrapper class will work..the thing is its an enhancement use case i am trying to avoid modification of existing wrapper class.do you know any way to check whether item is included in a set controller variable so that i can specifiy something like rendered="{!setvar.contains(item.id)}
    – sfdc99999
    Nov 28, 2013 at 19:52
  • You could add a new method (or a property), possibly getProposalsInSet(), to the controller which returns only the items which are in the set and then use that for the value on the <apex:repeat value="{!ProposalsInSet}" /> instead. To answer your question, no there isn't any VF functionality to do what you're describing there.
    – Mark Pond
    Nov 28, 2013 at 22:13

according to this page you can use a boolean condition to set the rendered attribute, I would suggest you to create a Boolean variable inside your controller code which determines whether to show or not this VF element. This is one way I did this before:

public Boolean mostrarDetalleTerminadas{
        if(mostrarDetalleTerminadas == null){
            mostrarDetalleTerminadas = false;
        return mostrarDetalleTerminadas;

    //check method
    public void checkTerminadas(Double i){
    if(i > 0){
        mostrarDetalleTerminadas = true;
        mostrarDetalleTerminadas = false;

    //And in your doSomething() method you can check the results
    public PageReference doSomething(){
         return null;

this how I call it from the VF page

 <TD WIDTH="15%" ALIGN="CENTER"><apex:commandLink value="ver detalle" rendered="{!mostrarDetalleTerminadas}" action="{!paginaTerminadas}" immediate="true" target="__blank"/></TD>
 <TD WIDTH="15%" ALIGN="CENTER"><apex:commandLink value="exportar" rendered="{!mostrarDetalleTerminadas}" action="{!exportarTerminadas}" immediate="true" target="__blank"/></TD>

I set the rendered attribute to an apex variable that runs at the time I called my methods, otherwise the attribute may not be set to true or false properly.

Hoe this helps.


  • the whole point of difficulty is this is an apex:repeat element.They way you have mentioned is option 2) i have specified. which still needs the repeat element id or some related thing
    – sfdc99999
    Nov 28, 2013 at 18:42
  • I still don´t see why you need to do it that way, can you post all the code to see what you are trying to accomplish?
    – Emilio
    Nov 28, 2013 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .