Activity › Forums › Salesforce® Discussions › How to render a VF page based on a criteria?
-
How to render a VF page based on a criteria?
Posted by shradha jain on August 24, 2018 at 12:52 PMHow to render a VF page based on a criteria?
shariq replied 7 years, 7 months ago 3 Members · 2 Replies -
2 Replies
-
Hi Shradha,
Here I am showing my code, hope this will help you:-
Vf Page:-
<apex:page controller=”ifblog”>
<apex:form>
<apex:commandButton action=”{!allacc}” value=”Show All Accounts” disabled=”{!If((total<=acclimit),true,If((acclist.size>acclimit),true,false))}”/>
<apex:dataTable value=”{!acclist}” var=”acc”>
<apex:column value=”{!acc.id}” headerValue=”Id”/>
<apex:column value=”{!acc.name}” headerValue=”Name”/>
</apex:dataTable>
</apex:form>
</apex:page>Controller:-
public class iftest {
public integer acclimit { get; set;}
public integer total { get; set;}
public list<account> acclist { get; set;}public iftest(){
acclimit = 5;
total = [select count() from account];
acclist = [select id, name from account limit :acclimit];
}public void allacc(){
acclist = [select id, name from account];
}
}Thanks.
- [adinserter block='9']
-
Hi,
Try this –
<apex:pageBlock id=”xxxpb1″>
<apex:pageBlockSection>
<apex:actionRegion ><apex:inputField id=”xxxif1″ value=”{!Object.picklistfieldapiname1}” required=”true” >
<apex:actionSupport event=”onchange” rerender=”xxxpb1″ />
</apex:inputField></apex:actionRegion>
</apex:pageBlockSection>
<apex:pageBlockSection id=”xxxpbs1″ rendered=”true”><apex:inputField id=”xxxif2″ value=”{!Object.Fieldtobedisplayed1}” rendered=”{!IF(Object.picklistfieldapiname1 =’picklist value 1′ || lead.Buyer_Type__c =’picklist value 2′ ,true,false)}”/>
</apex:pageBlockSection>
<apex:pageBlockSection id=”xxxpbs2″ rendered=”true”>
<apex:inputField id=”xxxif3″ value=”{!Object.Fieldtobedisplayed2}” rendered=”{!IF(Object.picklistfieldapiname1 =’picklist value 3′ || lead.Buyer_Type__c =’picklist value 4′ ,true,false)}”/>
</apex:pageBlockSection></apex:PageBlock>
In the above code block, fields are displayed on VF page only if the rendering criteria is met.
Hope this helps.
Log In to reply.