function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
levi6dblevi6db 

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

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Pradeep_NavatarPradeep_Navatar

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

Dave SullivanDave Sullivan

I would think that would work, what is happening w/ that code exactly?

levi6dblevi6db

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?

Pradeep_NavatarPradeep_Navatar

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.

This was selected as the best answer
prathap raoprathap rao

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 .....

<apex:page>
   <apex:stylesheet value="{!$Resource.TestStyles(name of the style sheet you created)}"/>
   <apex:outputText value="Styled Text in a sample style class" styleClass="sample"/>
</apex:page>

 

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<apexcolumn>Component is going to give u a header for each column .

 

Using the <apex:column> inside the


<apex:dataTable width="100%" border="0">  

 

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"

 

levi6dblevi6db

Thanks for the info, it worked perfectly.