You need to sign in to do that
Don't have an account?
Brian Dombrowski 10
How to check if string is in an array/list of strings in VisualForce?
This can be done easily using javascript, so am wondering if it's possible with VisualForce.
Here is what I'm trying to do, but doesn't work:
One idea is to concat the string array into a string and then use CONTAINS, but that is a little sloppy because there could be false positives.
Concat idea: https://salesforce.stackexchange.com/questions/70094/checking-a-list-if-a-certain-string-exist-in-visualforce-page/70098#70098
Here is what I'm trying to do, but doesn't work:
<apex:repeat value="{!account.AttachedContentDocuments}" var="att"> <apex:outputPanel rendered="{!att.FileType IN ['JPG', 'PNG']}" layout="none"> <apex:variable var="attachmentCount" value="{!attachmentCount + 1}"/> </apex:outputPanel> </apex:repeat>
One idea is to concat the string array into a string and then use CONTAINS, but that is a little sloppy because there could be false positives.
Concat idea: https://salesforce.stackexchange.com/questions/70094/checking-a-list-if-a-certain-string-exist-in-visualforce-page/70098#70098
There are 2 ways you could to this.
1. Compare the Attachment FileType values within Apex using a for loop. Once done, store the match in a public Boolean property, say isImage within Apex which can be used to decide if the output panel is rendered or not. 2. Use a Javascript function within to iterate on the AttachedContentDocuments using a for loop and then rerender it from the client side. Refer the following link to understand How to compare Strings in Javascript. (https://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript)
Please mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.