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

How do I reference and Integer on a VF Page?
Hi all,
I am new to Visual Force and trying to create my first page! I created a Class & VF page on the Campaign Object. What I am trying to do is pull all of the Leads that are associated to the Campaign that have been Disqualified.
If I use html, I can display the data on the VF page just fine, but I would like to use APEX instead.
Here is the Class:
public with sharing class CampaignMetricsRL { public CampaignMetricsRL(ApexPages.StandardController controller) { } public PageReference ViewData() { return null; } List<Campaign> rqs; Id cid = ApexPages.currentPage().getParameters().get('id'); public List<Campaign> getCampaign() { if(rqs == null){ rqs = [select Id, Name, Actual_Cost__c, NumberOfLeads, NumberOfContacts, NumberOfOpportunities, NumberOfWonOpportunities, AmountWonOpportunities, OwnerId, CreatedDate from Campaign limit 1]; } return rqs; } public Integer getDQLeads() { return [ select count() from CampaignMember where Lead.Lead_is_Disqualified__c = True AND Campaignid = :cid ]; } }
Here is the Visual Force Page:
<apex:page standardController="Campaign" extensions="CampaignMetricsRL" showHeader="false"> <apex:form id="test"> <apex:pageblock title=""> <tr> <apex:pageBlockTable value="{!Campaign}" var="C" id="table"> <apex:column > <table> <tr><td align="center"></td></tr> <tr><td align="center"></td></tr> <tr><td align="center"><u><font size="4" color="#000000">Leads</font></u></td></tr> <tr><td align="center"><font size="3" color="#000000"><b>{!C.NumberOfLeads}</b></font></td></tr> </table> </apex:column> <apex:column > <table> <tr><td align="center"><u><font size="4" color="#000000">Disqualified Leads</font></u></td></tr> <tr><td align="center"><font size="3" color="#000000"><b>{!DQLeads}</b></font></td></tr> </table> </apex:column> </apex:pageblock> </apex:form> </apex:page>
I would love to use APEX over HTML. Any help would be appreciated!
Thanks,
Alex
In my opinion you should not use html in the code. Try using the Visual Force component as per the sample code given below :
<apex:column headerValue="Leads" value="{!c.NumberOfLeads}" />
Hope this helps.
All Answers
I would think that would work, what is happening w/ that code exactly?
It is working, but I want to use APEX instead of html. I really want to know if you can reference the public integer from the visual force page while using apex. Can you do that?
In my opinion you should not use html in the code. Try using the Visual Force component as per the sample code given below :
<apex:column headerValue="Leads" value="{!c.NumberOfLeads}" />
Hope this helps.
I would create a style sheet and have it my Static Resources.
Reference in my Visual force page to get rid of the HTML code used for Aligning.
If this is what you want to do .... Resource refers to the Static Resources (Setup-> Develop->Static Resource)in Salesforce .....
Next when it comes to creating a exact table view instead of using the <apex:pageblocktable> component we can use <apex:dataTable> (dataTable is slightly different from pageblocktable it requires you to have a var as a compulsory attribute,look at visualforce documentation for more reference ) and using header value as pointed by the above person inside the<apex: column>Component is going to give u a header for each column .
Using the <apex:column> inside the
will give u neat little table with as many number of columns you want,provided u add the <apex:column> attribute as many times you want.
You can get a neat veiw of the table and the small trick that gives u a exact table veiw is by using border: ="1"
Thanks for the info, it worked perfectly.
prathap rao, your suggestion worked as well, thanks!