You need to sign in to do that
Don't have an account?
Ashok S 7
how to find the size of set
Hai guys,
my requirment is calculate the size of set
vf page
------------------
<apex:page controller="SetExample_Controller">
<apex:pageblock >
<apex:pageBlockTable value="{!names}" var="v">
<apex:column value="{!v}"/>
</apex:pageBlockTable>
</apex:pageblock>
</apex:page>
controller
---------------------
public class SetExample_Controller
{
public set<string> names{get;set;}
public SetExample_Controller()
{
names = new set<string>();
names.add('one');
names.add('two');
names.add('sam');
names.add('one');
names.add('one');
}
public Integer size()
{
Integer mysize = names.size();
return mysize;
}
}
plesae help me
my requirment is calculate the size of set
vf page
------------------
<apex:page controller="SetExample_Controller">
<apex:pageblock >
<apex:pageBlockTable value="{!names}" var="v">
<apex:column value="{!v}"/>
</apex:pageBlockTable>
</apex:pageblock>
</apex:page>
controller
---------------------
public class SetExample_Controller
{
public set<string> names{get;set;}
public SetExample_Controller()
{
names = new set<string>();
names.add('one');
names.add('two');
names.add('sam');
names.add('one');
names.add('one');
}
public Integer size()
{
Integer mysize = names.size();
return mysize;
}
}
plesae help me
names.size()
You want to use in VF page you can try like below
<apex:pageBlockTable value="{!names}" var="v" rerender="{!if(names.size > 0 , true,false)}">
Please let us know if this will help you
Thanks,
Amit Chaudhary
All Answers
names.size()
You want to use in VF page you can try like below
<apex:pageBlockTable value="{!names}" var="v" rerender="{!if(names.size > 0 , true,false)}">
Please let us know if this will help you
Thanks,
Amit Chaudhary
Just a heads up that the above solution doesn't actually work. That's only good for Lists. Looks like Visualforce doesn't allow .size for a Set. One actual solution for this is to setup a proxy variable, like this:
public Integer name_count {get {return names.size();}}