Using Apex:Variable in Visualforce to control rendering of HTML Markup
We mostly use apex:variable tag for declaring complex expressions or variables in visual force page. But the same can be used very easily to control the rendering too.
<apex:page controller="ApexVarController1">
<div>
<!-- apex:variable tag to control the rendering for Markup -->
<apex:variable
value="anything will go here" var="flag"
rendered="{!flag}">
<h1> Flag value is true </h1><br />
</apex:variable>
<!-- apex:variable tag used to not render for a Markup -->
<apex:variable value="anything will go here" var="flag1" rendered="{!flag1}">
<h1>Flag value is false</h1><br />
</apex:variable>
</div>
</apex:page>
--------------------------------------------------------------------------------------------------
public class ApexVarController1 {
public boolean flag { get;set;}
public boolean flag1{get;set;}
public ApexVarController1 (){
flag=true;
flag1=false;
}
}
--------------------------------------------------------------------------------------------------------
No comments:
Post a Comment