I have been trying for a good few hours to only get my apex:outputLink to show up if it is a key within a map in my controller.
It keeps giving me the generic 'Syntax Error'.
Here's the VF:
<apex:repeat value="{!alphabet}" var="a">
<apex:outputLink value="{!a}" rendered="{!IF({!cons}.get({!a}) == null, true, false)}">{!a}</apex:outputLink>
|
</apex:repeat>
So "cons" is a Map>() that gets loaded in the constructor. "alphabet" is a simple List of Strings - "A", "B", "C" all the way to "Z".
Basically I would like to know if cons.get("A") == null, cons.get("B") == null, and only show the outputLink if this is not the case.
EDIT: I've tried with:
rendered="{!IF(!cons[a] != null, true, false)}"
which at least compiles, but gives me the error "Map key A not found in map"
EDIT2: I've made sure cons contains all the keys. So now I'm looking to see if the associated List size is greater than 0. However
<apex:outputLink value="{!a}" rendered="{!IF(cons[a].size!=0, true, false)}">{!a}</apex:outputLink>
gives the following: Incorrect parameter for subscript. Expected Number, received Text
EDIT3 - UPDATE FOR PETER
Controller:
public Map<String, ContactListViewController.ListWrapper> cons {get;set;}
private class ListWrapper{
public List<Contact> theList {get;set;}
public ListWrapper(){}
public ListWrapper(List<Contact> theList){
this.theList = theList;
}
public Integer size {
get {
return theList.size();
}
}
}
VF:
<apex:repeat value="{!alphabet}" var="a">
<apex:outputLink value="{!a}" rendered="{!IF(cons[a].size>0, true, false)}">{!a}</apex:outputLink>
|
</apex:repeat>
This code is working fine.