You need to sign in to do that
Don't have an account?
Soumya sri Reddy
hi iam new to salesforce, code is working fine used contains method, to check duplicate
hi, my code is working, fine. to check duplicates used contains method ,
if exists iam getting true value, but i need to get the false value also if not in list , how can i solve this issue ..
need to add : false ,for the 'b' as it wont exists
Apex class:
Visualforce Page:
please help in this issue iam stucked
advance thanks
soumya yerava .
if exists iam getting true value, but i need to get the false value also if not in list , how can i solve this issue ..
need to add : false ,for the 'b' as it wont exists
Apex class:
public class test3{ public list<string>listSelectedNames{get;set;} public list<Wrapperclass>wraplist{get;set;} public list<boolean> Selectedbooleanlist{get;set;} public list<string>duplicatevalues{get;set;} public test3(){ listSelectedNames = new list<string>(); Selectedbooleanlist= new list<boolean>(); duplicatevalues= new list<string>{'a','c'}; //duplicated to filter wraplist = new list<Wrapperclass>(); Wrapperclass wf = new Wrapperclass(); wf.selected=false; wf.name ='a'; Wrapperclass wf1 = new Wrapperclass(); wf1.selected=false; wf1.name ='b'; Wrapperclass wf2 = new Wrapperclass(); wf2.selected=false; wf2.name ='c'; wraplist.add(wf); wraplist.add(wf1); wraplist.add(wf2); } public void duplicatecheck(){ listSelectedNames.clear(); Selectedbooleanlist.clear(); for(wrapperclass wrap: wraplist){ if(wrap.selected == true){ listSelectedNames.add(wrap.name); } } //to check duplicate for(String s1 : duplicatevalues){ if(listSelectedNames.contains(s1)){ boolean selected = true; Selectedbooleanlist.add(selected); //add logic } } } //wrapper classs public class Wrapperclass{ public boolean selected{get;set;} public string Name{get;set;} } }
Visualforce Page:
<apex:page controller="test3"> <apex:form > <apex:pageBlock > <apex:pageblockTable value="{!wraplist}" var="a"> <apex:column ><apex:inputCheckbox value="{!a.selected}"/>{!a.name}</apex:column> </apex:pageblockTable> <apex:commandButton value="OrderSelected" reRender="one,two" action="{!duplicatecheck}"/> <apex:outputLabel id="one">{!listSelectedNames}</apex:outputLabel> <apex:outputLabel id="two">{!Selectedbooleanlist}</apex:outputLabel> </apex:pageBlock> </apex:form> </apex:page>//as it contains iam getting true, but to get false also if it dnt contains in the list of boolean
please help in this issue iam stucked
advance thanks
soumya yerava .
Please update your function duplicateCheck code like this
I checked using above code and it is working fine
Please let me know if you any other issue.
your code is Partially Working fine,
but if we select a, b, c, at a time ... it should be [ true,false ,true]
if we select only a --> it should be only [ ture]
if we select only b--> it should be only [false]
if we select only c--> it should be only[ture]
if we select b and c--> it should be false and ture --[false,true]
if we select a and c--> it should be false and ture --[true,true]
Please let me know in case of any issue.
thank u so much
Soumya,
We just need to resolved that question and mark an answer as Best