0

I have a set named "voted" in my controller and I want to use that set on my visualforce to check if the user already voted on the idea.

public Set<String> voted = new Set<String>();

I used the voted for assigning the styleclass for the commandlink but it's not working.

<apex:commandLink styleClass="{!IF(voted.contains(i.Id+'-'+u.id+'-Down'),light-blue-link,light-gray-link)}" action="{!downVote}" reRender="forum, messages" status="loading">

2

No. The best you can do is Map<String, Boolean> to track if your data keys exist.

Please note, you have to actually use property notation in order to reference any property on your controller, supported markup syntax or no.

Controller

public Map<String, Boolean> mySetContains { get; private set; }

Markup

styleClass="{!IF(mySetContains[key], 'foo', 'bar')}"

This approach will only work if you can pre-compute all keys which might be checked.

  • Hi Adrian, I used the Map <String, Boolean> but it's not working – user51015 Nov 21 '18 at 9:28
  • styleClass="{!IF(CONTAINSKEY(voted[i.Id+'-'+u.id+'-Down'],true),'light-blue-link','light-gray-link')}" – user51015 Nov 21 '18 at 9:28
  • No if you have Map<String, Boolean> mySetContains you then do {!IF(mySetContains[key])} – Adrian Larson Nov 21 '18 at 12:47
  • styleClass="{!IF(voted.[i.Id+'-'+u.id+'-Down'],'light-blue-link','light-gray-link')} – user51015 Nov 21 '18 at 12:52
  • I got an error "Unknown property 'CustomerSuccess_IdeasController.voted'" – user51015 Nov 21 '18 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy