You need to sign in to do that
Don't have an account?

HTML If condition in visualforce page
Hi,
I need to display text 'No Records' or put a button on visualforce page.
VF Page:
--------------
<apex:page controller="TestController">
<table border="0" width="100%" height="20">
<tr>
if({!count}<0)
<h3> No Records</h3>
else
{
<td>
<input id="callintent_button" type="button" align="left" value = "More >>" onclick="enablerestoreCallIntent();"/>
</td>
}
</tr>
</table>
</apex:page>
Controller:
---------------
public class TestController
{
public integer count;
public integer getCount()
{
return count;
}
public void setCount(integer value)
{
this.count=value;
}
}
Should i use any apex command to check the condition. How can i do that.
Thanks.
A bit hackish but you could try
You could also replace if with another outpanel that renders based on the value of count. I just wanted to show an example of using an if :)
Thanks for quick reply?
I am getting below errors in this line '<td>{!IF (count <= 0,'No Records', '')}</td>'
Create Apex property 'RCPRequestDecisionV2.CallIntentDisplayNonTopSize'
Create Apex method 'RCPRequestDecisionV2.getCallIntentDisplayNonTopSize'
--------------
Just try this one !
<apex:page controller="TestController">
<table border="0" width="100%" height="20">
<tr>
<apex:outputPanel rendered="{!If(count<0,true,false)}">
<h3> No Records</h3>
</apex:outputPanel>
<td>
<apeX:outputPanel rendered="{!If(count>0,true,false)}">
<input id="callintent_button" type="button" align="left" value = "More >>" onclick="enablerestoreCallIntent();"/>
</apex:outputPanel>
</td>
}
</tr>
</table>
</apex:page>
Create Apex property 'RCPRequestDecisionV2.CallIntentDisplayNonTopSize'
Create Apex method 'RCPRequestDecisionV2.getCallIntentDisplayNonTopSize'
These are not related to count I guess and should is originating from somewhere else
I think you didn't post all your code. Please post what you have in the controller and page so we can see specifically where the error is.
The if statements in the rendered attribute are over kill. You just need rendered="{! count > 0}
<apex:outputPanel rendered="{false}" >
public Integer listSize{get {
if(Warrants != null)
return Warrants.size();
else
return 0;}}
</apex:outputPanel>
Then I was able to use warrants.size in either if or outputPanel as noted in earlier posts above. I mostly used outputPanel to show or hide sections of a Visualforce page rendered as a pdf.
<apex:outputPanel rendered="{!Warrants.size>0}">
stuff to show if there are any records in Warrants list, else don't show
</apex:outputPanel>