• newbiewvfdev
  • NEWBIE
  • 80 Points
  • Member since 2010

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 32
    Replies

Hi there,

 

I am pretty sure this is not possible, but I just want to make sure that I am right. I have a custom object and it has a look up fields to contact, account and lead. I am wondering if I could convert these three into one field on the custom object? So one field on the custom object will hold the contact, account and lead Ids.  Is this possible? If it is possible, if I go to a contact object, can I add my custom object as relatedList to the page?

Hi there,

 

We are building a JSP application that will be integrated into salesforce. I want to make it look like salesforce. How can I grab the salesforce stylesheet? Can someone guide me through this? Thank you very much.  Also, If you have done this before, and if you cans hare the pros and cons of it, that would be great. Thank you very much

Hi there,

 

I have implemented pagination for two objects contact and lead.  I have done this through StandardSetController.  The code is very similar for both except the QueryLocator is different.  I was thinking of merging both together and built something that would handle all of them. I am running into issues with this regard.

 

This is the original controller and visualforce page code which works with separate StandardSetController:

Controller: public with sharing class pagingControllerSeparate { Campaign campaign; public void pullCampaign() { con = null; lead = null; campaign = [SELECT Id, Name, NumberOfContacts, NumberOfLeads FROM Campaign WHERE Id = :'SomeID']; } public Campaign getCampaign() { if(campaign == null) campaign = new Campaign(); return campaign; } // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController con { get { if(con == null) { con = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Id, FirstName, LastName, MailingCity, MailingCountry FROM Contact Where Id in ( Select ContactId From CampaignMember where campaignId =:campaign.Id And ContactId <> null)])); // sets the number of records in each page set con.setPageSize(5); } return con; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } public List<Contact> getContacts() { return (List<Contact>) con.getRecords(); } // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController lead { get { if(lead == null) { lead = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Id, FirstName, LastName, City, Country FROM Lead Where Id in ( Select LeadId From CampaignMember where CampaignId =:campaign.Id And LeadId <> null)])); // sets the number of records in each page set lead.setPageSize(5); } return lead; } set; } // indicates whether there are more records after the current page set. public Boolean hasNextLead { get { return lead.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPreviousLead { get { return lead.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumberLead { get { return lead.getPageNumber(); } set; } // returns the first page of records public void firstLead() { lead.first(); } // returns the last page of records public void lastLead() { lead.last(); } // returns the previous page of records public void previousLead() { lead.previous(); } // returns the next page of records public void nextLead() { lead.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancelLead() { lead.cancel(); } public List<Lead> getLeads() { return (List<Lead>) lead.getRecords(); } } Visualforce Page: <apex:page Controller="pagingControllerSeparate"> <style> .activeTab {background-color: #236FBD; color:white; background-image:none} .inactiveTab { background-color: lightgrey; color:black; background-image:none} </style> <apex:form > <apex:commandLink value="Select" action="{!pullCampaign}" styleClass="btn" rerender="campaignContactsAndLeads"> <apex:param name="campaignId" value="{!campaign.Id}" /> </apex:commandLink> <apex:outputPanel id="campaignContactsAndLeads" > <apex:tabPanel switchType="client" selectedTab="tabCampaigns" id="MailingListTabPanel" rendered="{!IF(ISNULL(campaign.Id), false, true)}" tabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:tab label="Contacts({!campaign.NumberOfContacts})" name="contactSec" id="tabContacts"> <apex:pageBlock title="Category Results - Page #{!pageNumber}" > <apex:pageBlockTable id="cMContacts" value="{!Contacts}" var="cont"> <apex:column headerValue="First Name"> <apex:outputField value="{!cont.FirstName}"/>&nbsp; </apex:column> <apex:column headerValue="Last Name"> <apex:outputField value="{!cont.LastName}" />&nbsp; </apex:column> <apex:column headerValue="Mailing City"> <apex:outputField value="{!cont.MailingCity}"/>&nbsp; </apex:column> <apex:column headerValue="Mailing Country"> <apex:outputField value="{!cont.MailingCountry}" />&nbsp; </apex:column> </apex:pageBlockTable> </apex:pageBlock> <apex:panelGrid columns="4" id="contactLinks"> <apex:commandLink action="{!first}" rerender="cMContacts, contactLinks">First</apex:commandlink> <apex:commandLink action="{!previous}" rerender="cMContacts, contactLinks" rendered="{!hasPrevious}">Previous</apex:commandlink> <apex:commandLink action="{!next}" rendered="{!hasNext}" rerender="cMContacts, contactLinks">Next</apex:commandlink> <apex:commandLink action="{!last}" rerender="cMContacts, contactLinks">Last</apex:commandlink> </apex:panelGrid> </apex:tab> <apex:tab label="Leads({!campaign.NumberOfLeads})" name="leadSec" id="tabLeads"> <apex:pageBlock title="Category Results - Page #{!pageNumberLead}" > <apex:pageBlockTable id="cMLeads" value="{!Leads}" var="leadM"> <apex:column headerValue="First Name"> <apex:outputField value="{!leadM.FirstName}"/>&nbsp; </apex:column> <apex:column headerValue="Last Name"> <apex:outputField value="{!leadM.LastName}" />&nbsp; </apex:column> <apex:column headerValue="Mailing City"> <apex:outputField value="{!leadM.City}"/>&nbsp; </apex:column> <apex:column headerValue="Mailing Country"> <apex:outputField value="{!leadM.Country}" />&nbsp; </apex:column> </apex:pageBlockTable> </apex:pageBlock> <apex:panelGrid columns="4" id="leadLinks"> <apex:commandLink action="{!firstLead}" rerender="cMLeads, leadLinks">First</apex:commandlink> <apex:commandLink action="{!previousLead}" rerender="cMLeads, leadLinks" rendered="{!hasPreviousLead}">Previous</apex:commandlink> <apex:commandLink action="{!nextLead}" rerender="cMLeads, leadLinks" rendered="{!hasNextLead}">Next</apex:commandlink> <apex:commandLink action="{!lastLead}" rerender="cMLeads, leadLinks">Last</apex:commandlink> </apex:panelGrid> </apex:tab> </apex:tabPanel> </apex:outputPanel> </apex:form> </apex:page>

 

I am trying to merge both paging code into one so I could use one StandardSetController to handle both? Is this possible and how can I approach this?

 

I tried creating a property and based on the property I set the QueryLocator.

 

Here is what I have so far. But the problem is, it renderes fine, but when I click Next, Previous or any of the buttons, it doesn't do anything. Please help. Thanks.

Hi there,

 

I have three implementation of pagination for three objects using the StandardSetController.  The code is pretty much the same, except the QueryLocator's Query.  I want to merge all three into one code, which should be able to handle all three objects.  Is this possible? I thought I could change the Query based on a parameter that I pass in for the StandardSetController initialization. But It seem's I can't pass a parameter.  I am sure there must be someone who came across this same issue, could someone be kind enough to guide me through this? Thank You.

 

// instantiate the StandardSetController from a query locator public ApexPages.StandardSetController setController { get { if(setController == null) { setController = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Id, Name, CreatedDate, Status__c, CreatedBy.Name FROM Object1__c])); // sets the number of records in each page set setController.setPageSize(5); } return setController; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext2 { get { return setController.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious2 { get { return setController.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber2 { get { return setController.getPageNumber(); } set; } // returns the first page of records public void first2() { jobs2.first(); } // returns the last page of records public void last2() { setController.last(); } // returns the previous page of records public void previous2() { setController.previous(); } // returns the next page of records public void next2() { setController.next(); }

 

 

Please help. Thanks.

Hi there,

 

I have a visualforce page with a textBox and a save Button.  The textBox is an inputField and I have set it to required to true. How do I write testMethods to check if this works properly?

Hi there,

 

I am building a wizard application. On one of the page, I am asking the user to enter information using inputField tag and I have the required attribute set to true. I also have a 'Previous' Button on the page which will take me to the previous page. How can I ignore the required validation when I click the Previous Button? I only want the validation to occur when there I click next or save. Please help.

Hi there,

 

I have a page, where I am displaying a record(i.e Job).  There are two buttons on the page. One is 'Copy Job' and 'Edit Job'. When a user clicks 'Copy Job', I have an action method on the custom controller called copyJob and I am copying the existing Job. Now I need to pass this job object to another page, which has a different controller.  How can I pass an object (i.e Job) from one page's controller to another page? Thank You.

 

Hi there,

 

I just created a custom object called 'Job' with no additional custom fields. And I am trying to do paging on all the Job records.

 

When I try to save the following code it's throwing me an error:

 

'Could not resolve the entity from <apex:outputField> value binding '{!jobM.Name}'. outputField can only be used with SObject fields.'

 

Here is my code:

visualforce page code: <apex:page controller="customObjectPagingController" > <apex:pageBlock title="Page #{!pageNumberJob}" > <apex:pageBlockTable id="cMJobs" value="{!Jobs}" var="jobM"> <apex:column headerValue="Job Name"> <apex:outputField value="{!jobM.Name}"/>&nbsp; </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:page> Controller code: public class customObjectPagingController { // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController jobs { get { if(jobs == null) { jobs = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Name FROM Job__c])); // sets the number of records in each page set jobs.setPageSize(5); } return jobs; } set; } // indicates whether there are more records after the current page set. public Boolean hasNextJob { get { return jobs.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPreviousJob { get { return jobs.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumberJob { get { return jobs.getPageNumber(); } set; } // returns the first page of records public void firstJob() { jobs.first(); } // returns the last page of records public void lastJob() { jobs.last(); } // returns the previous page of records public void previousJob() { jobs.previous(); } // returns the next page of records public void nextJob() { jobs.next(); } public List<Job__c> getJobs() { return (List<Job__c>) jobs.getRecords(); } }

 

 

Hi there,

 

When you go to a record in salesforce's detail view. and if you double click a field, it will turn into edit mode. How can I implement this in visualforce? What tag am I suppose to use or what attribute do I need to set? Thanks.

 

 

Hi there,

 

I am having rerender issues. I have a commandLink button and when I click it I am putting a campaign record in the controller.  I have a outputPanel in the bottom of the commandLink button which holds a tabPanel. In the tabPanel, I am showing Contacts and Leads in the Campaign.  I have the rerender property of the commandLink set to outputPanel Id, because I only want to render this when they click the select button.  Also, I have an inline IF statement that checks if the campaign is null and if it's then don't render the Panel. When I click the select button it doesn't do anything. Can someone help me figure this out please. Thank you.

 

visualforce Page: <apex:page Controller="pagingController"> <style> .activeTab {background-color: #236FBD; color:white; background-image:none} .inactiveTab { background-color: lightgrey; color:black; background-image:none} </style> <apex:form > <apex:commandLink value="Select" action="{!pullCampaign}" styleClass="btn" rerender="campaignContactsAndLeads"> <apex:param name="campaignId" value="{!campaign.Id}" /> </apex:commandLink> <apex:outputPanel id="campaignContactsAndLeads" rendered="{!IF(ISNULL(campaign), false, true)}"> <apex:tabPanel switchType="client" selectedTab="tabCampaigns" id="MailingListTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:tab label="Contacts" name="contactSec" id="tabContacts"> <apex:pageBlock title="Category Results - Page #{!pageNumber}" > <apex:pageBlockTable id="cMContacts" value="{!Contacts}" var="cont"> <apex:column headerValue="First Name"> <apex:outputField value="{!cont.FirstName}"/>&nbsp; </apex:column> <apex:column headerValue="Last Name"> <apex:outputField value="{!cont.LastName}" />&nbsp; </apex:column> <apex:column headerValue="Mailing City"> <apex:outputField value="{!cont.MailingCity}"/>&nbsp; </apex:column> <apex:column headerValue="Mailing Country"> <apex:outputField value="{!cont.MailingCountry}" />&nbsp; </apex:column> </apex:pageBlockTable> </apex:pageBlock> <apex:panelGrid columns="4" id="contactLinks"> <apex:commandLink action="{!first}" rerender="cMContacts, contactLinks">First</apex:commandlink> <apex:commandLink action="{!previous}" rerender="cMContacts, contactLinks" rendered="{!hasPrevious}">Previous</apex:commandlink> <apex:commandLink action="{!next}" rendered="{!hasNext}" rerender="cMContacts, contactLinks">Next</apex:commandlink> <apex:commandLink action="{!last}" rerender="cMContacts, contactLinks">Last</apex:commandlink> </apex:panelGrid> </apex:tab> <apex:tab label="Leads" name="leadSec" id="tabLeads"> <apex:pageBlock title="Category Results - Page #{!pageNumberLead}" > <apex:pageBlockTable id="cMLeads" value="{!Leads}" var="leadM"> <apex:column headerValue="First Name"> <apex:outputField value="{!leadM.FirstName}"/>&nbsp; </apex:column> <apex:column headerValue="Last Name"> <apex:outputField value="{!leadM.LastName}" />&nbsp; </apex:column> <apex:column headerValue="Mailing City"> <apex:outputField value="{!leadM.City}"/>&nbsp; </apex:column> <apex:column headerValue="Mailing Country"> <apex:outputField value="{!leadM.Country}" />&nbsp; </apex:column> </apex:pageBlockTable> </apex:pageBlock> <apex:panelGrid columns="4" id="leadLinks"> <apex:commandLink action="{!firstLead}" rerender="cMLeads, leadLinks">First</apex:commandlink> <apex:commandLink action="{!previousLead}" rerender="cMLeads, leadLinks" rendered="{!hasPreviousLead}">Previous</apex:commandlink> <apex:commandLink action="{!nextLead}" rerender="cMLeads, leadLinks" rendered="{!hasNextLead}">Next</apex:commandlink> <apex:commandLink action="{!lastLead}" rerender="cMLeads, leadLinks">Last</apex:commandlink> </apex:panelGrid> </apex:tab> </apex:tabPanel> </apex:outputPanel> </apex:form> </apex:page> Controller code: public with sharing class pagingController { Campaign campaign; public void pullCampaign() { campaign = [SELECT Id, Name FROM Campaign WHERE Id = :'701A00000000kGz']; } public Campaign getCampaign() { return campaign; } // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController con { get { if(con == null) { con = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Id, FirstName, LastName, MailingCity, MailingCountry FROM Contact Where Id in ( Select ContactId From CampaignMember where campaignId =:campaign.Id And ContactId <> null)])); // sets the number of records in each page set con.setPageSize(5); } return con; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } public List<Contact> getContacts() { return (List<Contact>) con.getRecords(); } // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController lead { get { if(lead == null) { lead = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Id, FirstName, LastName, City, Country FROM Lead Where Id in ( Select LeadId From CampaignMember where CampaignId =:campaign.Id And LeadId <> null)])); // sets the number of records in each page set lead.setPageSize(5); } return lead; } set; } // indicates whether there are more records after the current page set. public Boolean hasNextLead { get { return lead.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPreviousLead { get { return lead.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumberLead { get { return lead.getPageNumber(); } set; } // returns the first page of records public void firstLead() { lead.first(); } // returns the last page of records public void lastLead() { lead.last(); } // returns the previous page of records public void previousLead() { lead.previous(); } // returns the next page of records public void nextLead() { lead.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancelLead() { lead.cancel(); } public List<Lead> getLeads() { return (List<Lead>) lead.getRecords(); } }

 

Hi there,

 

I am trying out paging using StandardSetController.  Everything works fine, until I do partial page refresh.  When I add rerender="test" to the commandLink, the previous button doesn't show up when I go to the next page. Does anyone know a way around to fix this issue?

 

Here is the code:

Visual force page: <apex:page controller="PagingController"> <apex:form > <apex:pageBlock id="test" title="Paging through Categories of Stuff"> <apex:pageBlockSection title="Category Results - Page #{!pageNumber}" columns="1"> <apex:pageBlockTable value="{!Contacts}" var="c"> <apex:column value="{!c.Name}" headerValue="Name"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> <apex:panelGrid columns="4"> <apex:commandLink action="{!first}" rerender="test">First</apex:commandlink> <apex:commandLink action="{!previous}" rendered="{!hasPrevious}" rerender="test">Previous</apex:commandlink> <apex:commandLink action="{!next}" rendered="{!hasNext}" rerender="test">Next</apex:commandlink> <apex:commandLink action="{!last}" rerender="test">Last</apex:commandlink> </apex:panelGrid> </apex:form> </apex:page> Controller Code: public with sharing class PagingController { // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController con { get { if(con == null) { con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name FROM Contact Order By Name])); // sets the number of records in each page set con.setPageSize(5); } return con; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } public List<Contact> getContacts() { return (List<Contact>) con.getRecords(); } }

 

Hi there,

 

Why can't I Data bind multiple data to the outputField?

 

 

<apex:outputField value="{!member.Contact.MailingCountry}{!member.Lead.Country}" />

 

I know I could use two outputField to archieve the same thing, but I am just wondering why I can't do the above? I was able to do that in <apex:column /> tag, but not in <apex:outputField />

 

This works:

 

<apex:column value="{!member.Contact.MailingCountry}{!member.Lead.Country}" headerValue="Country"/>

 

Hi there,

 

I have a list of records(i.e Campaigns) and when the user select a campaign, I am displaying the related CampaignMembers in the bottom of the page. Now I wanted to implement paging, and after implementing the paging, it is not displaying anything.

 

This is the code that I have on the Controller:

public ApexPages.StandardSetController campaignMembers { get { if(campaignMembers == null) { campaignMembers = new ApexPages.StandardSetController( Database.getQueryLocator([SELECT Id, Lead.Country, Lead.City, Lead.FirstName, Lead.LastName, LeadId, Contact.MailingCountry, Contact.MailingCity, Contact.FirstName, Contact.LastName, ContactId FROM CampaignMember WHERE CampaignId = :campaign.Id])); // sets the number of records in each page set campaignMembers.setPageSize(5); } return campaignMembers; } set; } public List<CampaignMember> getMembers() { if(campaign == null) return new List<CampaignMember>(); return (List<CampaignMember>) campaignMembers.getRecords(); }

 

When the user selects a campaign I am setting the variable campaign on the controller. How do I re-initialize the QueryLocator with the new campaign.Id?

Hi there I have the following code.

 

<apex:column value="{!IF(ISNULL(member.Contact), 'Lead', 'Contact')}" headerValue="Type" />

 

 

What is wrong with the above code? It's throwing a systax error. Missing ')'. Thanks.

Hi there,

 

I am trying to implement paging and I am not sure if this is doable and where to start.

 

Here is what I need to do:

 

I have a visualforce page that custom controller.  In the custom controller I have two set of arrays, and both of them hold CampaignMembers.  I am displaying both records on the UI. I want to do paging for both of them. Is it possible to do paging like this and where do I start? Thanks.

 

 

Hi there,

 

I am trying out the example on developers guide 'Building a Table of Data in a Page'(pg. 29)

 

<apex:page standardController="Account"> <apex:pageBlock title="Hello {!$User.FirstName}!"> You are viewing the {!account.name} account. </apex:pageBlock> <apex:pageBlock title="Contacts"> <apex:pageBlockTable value="{!account.Contacts}" var="contact"> <apex:column value="{!contact.Name}"/> <apex:column value="{!contact.Phone}"/> <apex:column value="{!contact.MailingCity}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>

 

 

I created an Account and I created two contacts for the Account.  One of the contact doesn't have MailingCity, so it's empty. The line below the first record stops after the Phone column. Is there a way to fix this?

Hi there,

 

I am trying to follow the example in the developers guide on page 21.

 

<apex:page standardController="Account">
    <apex:pageblock title="Hello {!$User.FirstName}">
        You are viewing the {!account.name} account.
    </apex:pageblock>
    <apex:detail />
</apex:page>

 

I dont' see the detail section. I only see the pageBlock section. What am I missing?

Hi there,

 

I have a list of dataTable with Campaigns with a select button for each row. When the user clicks the select button I would like to show the CampaignMembers(Contacts and Leads) in the bottom of the page in another page block.  I know in salesforce if you go to the Campaign record it shows the CampaignMembers in the related list.  Is there a control in visualforce that I can use do this or do I need to manually implement this? Please let me know which way I should start. Thank You.

 

newbie

Hello!

 

I am new to Apex / Visualforce, so will appreciate any help with the following. I have created a custom list using visual force to display all child accounts in a related list. I would like to repeat the same for Contacts of child accounts in the page for parent account.

 

Now, having done that, how do I implement pagination - if the number of contacts / child accounts is significant?

 

See my apex code below:

 

<apex:page standardController="Account" extensions="childAccount">

<style>

.fewerMore { display: none;}

</style>

<apex:form >

 <apex:pageMessages />

 <apex:detail relatedList="true"></apex:detail>

<apex:pageblock id="CustomList" title="Child Accounts"  >

   <apex:pageBlockTable value="{!acctz}" var="o" rendered="{!NOT(ISNULL(acctz))}">

        <apex:column headerValue="Action" >

            <apex:outputLink value="/{!o.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="color:blue; text-decoration:none">Edit</apex:outputLink>

        </apex:column>       

        <apex:column headerValue="Name"> <apex:outputLink value="/{!o.id}">{!o.Name}</apex:outputLink> </apex:column>

        <apex:column value="{!o.Address_Street__c}"/>

        <apex:column value="{!o.Address_City__c}"/>

    <apex:column value="{!o.Office__c}"/>

        <apex:column value="{!o.Type}"/>

   </apex:pageBlockTable>

   <apex:outputLabel value="No records to display" rendered="{!(ISNULL(acctz))}"></apex:outputLabel>

 </apex:pageblock>

 

</apex:form>

</apex:page>

 

 

 

 

public class childAccount {

   

    private List<Account> acctz;

    private Account acct;

 

    public childAccount(ApexPages.StandardController controller) {

        this.acct= (Account)controller.getRecord();

    }

 

    public List<Account> getAcctz()

    {

        Account act = [Select id FROM Account where id = :acct.id];

        acctz = [Select id, Name, Address_Street__c, Address_City__c, Office__c, Type from Account where parentid = :act.id];

    return acctz;

    }

}

 

 

Working with a large client that is using Ideas Base Theme.  We're having Pagination issues using the IdeaStandardSetController.  We are using the <ideas:listOutputLink> control to pass a status,sort, category, and communityId to navigate to our vforce page that lists the ideas that match the params.  The IdeaStandardSetController for the page seems to read the params for sort,category,community,and status fine and displays the proper ideas that match the parameters.  However, we're trying to display pagination at the bottom of the page that shows "Idea Page 1 of ###".  In order to determine the ### number we're doing a call to the controller.getResultSize() method but it always returns the number for the entire set of all ideas not taking into consideration the parameters for sort,category,status. So even when the IdeaStandardSetController only displays 1 record in the list the getResultSize() method still returns 700+ ideas.

 

Is this a problem with the IdeaStandardSetController or are we just not using it correctly to determine the number of ideas that fit the params?

 

Hi there,

 

I have implemented pagination for two objects contact and lead.  I have done this through StandardSetController.  The code is very similar for both except the QueryLocator is different.  I was thinking of merging both together and built something that would handle all of them. I am running into issues with this regard.

 

This is the original controller and visualforce page code which works with separate StandardSetController:

Controller: public with sharing class pagingControllerSeparate { Campaign campaign; public void pullCampaign() { con = null; lead = null; campaign = [SELECT Id, Name, NumberOfContacts, NumberOfLeads FROM Campaign WHERE Id = :'SomeID']; } public Campaign getCampaign() { if(campaign == null) campaign = new Campaign(); return campaign; } // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController con { get { if(con == null) { con = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Id, FirstName, LastName, MailingCity, MailingCountry FROM Contact Where Id in ( Select ContactId From CampaignMember where campaignId =:campaign.Id And ContactId <> null)])); // sets the number of records in each page set con.setPageSize(5); } return con; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } public List<Contact> getContacts() { return (List<Contact>) con.getRecords(); } // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController lead { get { if(lead == null) { lead = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Id, FirstName, LastName, City, Country FROM Lead Where Id in ( Select LeadId From CampaignMember where CampaignId =:campaign.Id And LeadId <> null)])); // sets the number of records in each page set lead.setPageSize(5); } return lead; } set; } // indicates whether there are more records after the current page set. public Boolean hasNextLead { get { return lead.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPreviousLead { get { return lead.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumberLead { get { return lead.getPageNumber(); } set; } // returns the first page of records public void firstLead() { lead.first(); } // returns the last page of records public void lastLead() { lead.last(); } // returns the previous page of records public void previousLead() { lead.previous(); } // returns the next page of records public void nextLead() { lead.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancelLead() { lead.cancel(); } public List<Lead> getLeads() { return (List<Lead>) lead.getRecords(); } } Visualforce Page: <apex:page Controller="pagingControllerSeparate"> <style> .activeTab {background-color: #236FBD; color:white; background-image:none} .inactiveTab { background-color: lightgrey; color:black; background-image:none} </style> <apex:form > <apex:commandLink value="Select" action="{!pullCampaign}" styleClass="btn" rerender="campaignContactsAndLeads"> <apex:param name="campaignId" value="{!campaign.Id}" /> </apex:commandLink> <apex:outputPanel id="campaignContactsAndLeads" > <apex:tabPanel switchType="client" selectedTab="tabCampaigns" id="MailingListTabPanel" rendered="{!IF(ISNULL(campaign.Id), false, true)}" tabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:tab label="Contacts({!campaign.NumberOfContacts})" name="contactSec" id="tabContacts"> <apex:pageBlock title="Category Results - Page #{!pageNumber}" > <apex:pageBlockTable id="cMContacts" value="{!Contacts}" var="cont"> <apex:column headerValue="First Name"> <apex:outputField value="{!cont.FirstName}"/>&nbsp; </apex:column> <apex:column headerValue="Last Name"> <apex:outputField value="{!cont.LastName}" />&nbsp; </apex:column> <apex:column headerValue="Mailing City"> <apex:outputField value="{!cont.MailingCity}"/>&nbsp; </apex:column> <apex:column headerValue="Mailing Country"> <apex:outputField value="{!cont.MailingCountry}" />&nbsp; </apex:column> </apex:pageBlockTable> </apex:pageBlock> <apex:panelGrid columns="4" id="contactLinks"> <apex:commandLink action="{!first}" rerender="cMContacts, contactLinks">First</apex:commandlink> <apex:commandLink action="{!previous}" rerender="cMContacts, contactLinks" rendered="{!hasPrevious}">Previous</apex:commandlink> <apex:commandLink action="{!next}" rendered="{!hasNext}" rerender="cMContacts, contactLinks">Next</apex:commandlink> <apex:commandLink action="{!last}" rerender="cMContacts, contactLinks">Last</apex:commandlink> </apex:panelGrid> </apex:tab> <apex:tab label="Leads({!campaign.NumberOfLeads})" name="leadSec" id="tabLeads"> <apex:pageBlock title="Category Results - Page #{!pageNumberLead}" > <apex:pageBlockTable id="cMLeads" value="{!Leads}" var="leadM"> <apex:column headerValue="First Name"> <apex:outputField value="{!leadM.FirstName}"/>&nbsp; </apex:column> <apex:column headerValue="Last Name"> <apex:outputField value="{!leadM.LastName}" />&nbsp; </apex:column> <apex:column headerValue="Mailing City"> <apex:outputField value="{!leadM.City}"/>&nbsp; </apex:column> <apex:column headerValue="Mailing Country"> <apex:outputField value="{!leadM.Country}" />&nbsp; </apex:column> </apex:pageBlockTable> </apex:pageBlock> <apex:panelGrid columns="4" id="leadLinks"> <apex:commandLink action="{!firstLead}" rerender="cMLeads, leadLinks">First</apex:commandlink> <apex:commandLink action="{!previousLead}" rerender="cMLeads, leadLinks" rendered="{!hasPreviousLead}">Previous</apex:commandlink> <apex:commandLink action="{!nextLead}" rerender="cMLeads, leadLinks" rendered="{!hasNextLead}">Next</apex:commandlink> <apex:commandLink action="{!lastLead}" rerender="cMLeads, leadLinks">Last</apex:commandlink> </apex:panelGrid> </apex:tab> </apex:tabPanel> </apex:outputPanel> </apex:form> </apex:page>

 

I am trying to merge both paging code into one so I could use one StandardSetController to handle both? Is this possible and how can I approach this?

 

I tried creating a property and based on the property I set the QueryLocator.

 

Here is what I have so far. But the problem is, it renderes fine, but when I click Next, Previous or any of the buttons, it doesn't do anything. Please help. Thanks.

Hi:

 I am repeating this table over and over again based on Term. So if the term changes and it pertains to the contact then repeat it with the information.

Can someone tell me a better way to do this:

 

<table> <tr> <td colspan="4" align="center">Term: 9.1</td></tr><tr> <td align="center">Subject Area</td> <td align="center">Total Courses<br/>Taken</td> <td align="center">CR Min Pass</td> <td align="center">Credits Earned</td> <td align="center">Gap</td> </tr> <apex:repeat value="{!queryResultsD}" var="de"> <apex:outputPanel rendered="{!de.TermD='9.1'}"> <tr> <td>{!de.on_TrackD}</td> <td>{!de.nosa}</td> <td>{!de.MinPassD}</td> <td>{!de.CED}</td> <td>{!de.CED-de.MinPassD}</td> </tr> </apex:outputPanel> </apex:repeat> </table> </td> <td valign="top"> <table> <tr> <td colspan="4" align="center">Term:9.2</td></tr><tr> <td align="center">Subject Area</td> <td align="center">Total Courses<br/>Taken</td> <td align="center">CR Min Pass</td> <td align="center">Credits Earned</td> <td align="center">Gap</td> </tr> <apex:repeat value="{!queryResultsD}" var="de"> <apex:outputPanel rendered="{!de.TermD='9.2'}"> <tr> <td>{!de.on_TrackD}</td> <td>{!de.nosa}</td> <td>{!de.MinPassD}</td> <td>{!de.CED}</td> <td>{!de.CED-de.MinPassD}</td> </tr> </apex:outputPanel> </apex:repeat>

 Thanks

 

 

 

Hi there,

 

I am building a wizard application. On one of the page, I am asking the user to enter information using inputField tag and I have the required attribute set to true. I also have a 'Previous' Button on the page which will take me to the previous page. How can I ignore the required validation when I click the Previous Button? I only want the validation to occur when there I click next or save. Please help.

Hi there,

 

I have a page, where I am displaying a record(i.e Job).  There are two buttons on the page. One is 'Copy Job' and 'Edit Job'. When a user clicks 'Copy Job', I have an action method on the custom controller called copyJob and I am copying the existing Job. Now I need to pass this job object to another page, which has a different controller.  How can I pass an object (i.e Job) from one page's controller to another page? Thank You.

 

Hi there,

 

I just created a custom object called 'Job' with no additional custom fields. And I am trying to do paging on all the Job records.

 

When I try to save the following code it's throwing me an error:

 

'Could not resolve the entity from <apex:outputField> value binding '{!jobM.Name}'. outputField can only be used with SObject fields.'

 

Here is my code:

visualforce page code: <apex:page controller="customObjectPagingController" > <apex:pageBlock title="Page #{!pageNumberJob}" > <apex:pageBlockTable id="cMJobs" value="{!Jobs}" var="jobM"> <apex:column headerValue="Job Name"> <apex:outputField value="{!jobM.Name}"/>&nbsp; </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:page> Controller code: public class customObjectPagingController { // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController jobs { get { if(jobs == null) { jobs = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Name FROM Job__c])); // sets the number of records in each page set jobs.setPageSize(5); } return jobs; } set; } // indicates whether there are more records after the current page set. public Boolean hasNextJob { get { return jobs.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPreviousJob { get { return jobs.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumberJob { get { return jobs.getPageNumber(); } set; } // returns the first page of records public void firstJob() { jobs.first(); } // returns the last page of records public void lastJob() { jobs.last(); } // returns the previous page of records public void previousJob() { jobs.previous(); } // returns the next page of records public void nextJob() { jobs.next(); } public List<Job__c> getJobs() { return (List<Job__c>) jobs.getRecords(); } }

 

 

Hi,

 

I was wondering if it is possible to pass parameters to our controller method while in a VF page.

I want to render a component only if the method called returns 'true':

 <c:NetworkForm case="{!case}" contact="{!contact}" rendered="{!DisplaySection}">

<apex:param name="sectionName" value="NetworkForm" />   

</c:NetworkForm>

And the method is the following:

 public Boolean getDisplaySection(){

String sectionName = apexpages.currentpage().getparameters().get('sectionName');

System.debug('SECTION NAME::::::::::' + sectionName);  //sectionName is null !!!!

if(listOfCategorySections.size() > 0 && callCategory!=null && sectionName!=null){

List<RF_Section_Map__c> sections = listOfCategorySections.get(calltype+callCategory);

for(RF_Section_Map__c loopSec : sections){

if(sectionName.equalsIgnoreCase(loopSec.Component_Name__c)){

return true;

}

}

}

return false;

}

But the parameter is null in my controller, any ideas?

 

Thanks in advance.

  • March 05, 2010
  • Like
  • 0

Hi there,

 

I am having rerender issues. I have a commandLink button and when I click it I am putting a campaign record in the controller.  I have a outputPanel in the bottom of the commandLink button which holds a tabPanel. In the tabPanel, I am showing Contacts and Leads in the Campaign.  I have the rerender property of the commandLink set to outputPanel Id, because I only want to render this when they click the select button.  Also, I have an inline IF statement that checks if the campaign is null and if it's then don't render the Panel. When I click the select button it doesn't do anything. Can someone help me figure this out please. Thank you.

 

visualforce Page: <apex:page Controller="pagingController"> <style> .activeTab {background-color: #236FBD; color:white; background-image:none} .inactiveTab { background-color: lightgrey; color:black; background-image:none} </style> <apex:form > <apex:commandLink value="Select" action="{!pullCampaign}" styleClass="btn" rerender="campaignContactsAndLeads"> <apex:param name="campaignId" value="{!campaign.Id}" /> </apex:commandLink> <apex:outputPanel id="campaignContactsAndLeads" rendered="{!IF(ISNULL(campaign), false, true)}"> <apex:tabPanel switchType="client" selectedTab="tabCampaigns" id="MailingListTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:tab label="Contacts" name="contactSec" id="tabContacts"> <apex:pageBlock title="Category Results - Page #{!pageNumber}" > <apex:pageBlockTable id="cMContacts" value="{!Contacts}" var="cont"> <apex:column headerValue="First Name"> <apex:outputField value="{!cont.FirstName}"/>&nbsp; </apex:column> <apex:column headerValue="Last Name"> <apex:outputField value="{!cont.LastName}" />&nbsp; </apex:column> <apex:column headerValue="Mailing City"> <apex:outputField value="{!cont.MailingCity}"/>&nbsp; </apex:column> <apex:column headerValue="Mailing Country"> <apex:outputField value="{!cont.MailingCountry}" />&nbsp; </apex:column> </apex:pageBlockTable> </apex:pageBlock> <apex:panelGrid columns="4" id="contactLinks"> <apex:commandLink action="{!first}" rerender="cMContacts, contactLinks">First</apex:commandlink> <apex:commandLink action="{!previous}" rerender="cMContacts, contactLinks" rendered="{!hasPrevious}">Previous</apex:commandlink> <apex:commandLink action="{!next}" rendered="{!hasNext}" rerender="cMContacts, contactLinks">Next</apex:commandlink> <apex:commandLink action="{!last}" rerender="cMContacts, contactLinks">Last</apex:commandlink> </apex:panelGrid> </apex:tab> <apex:tab label="Leads" name="leadSec" id="tabLeads"> <apex:pageBlock title="Category Results - Page #{!pageNumberLead}" > <apex:pageBlockTable id="cMLeads" value="{!Leads}" var="leadM"> <apex:column headerValue="First Name"> <apex:outputField value="{!leadM.FirstName}"/>&nbsp; </apex:column> <apex:column headerValue="Last Name"> <apex:outputField value="{!leadM.LastName}" />&nbsp; </apex:column> <apex:column headerValue="Mailing City"> <apex:outputField value="{!leadM.City}"/>&nbsp; </apex:column> <apex:column headerValue="Mailing Country"> <apex:outputField value="{!leadM.Country}" />&nbsp; </apex:column> </apex:pageBlockTable> </apex:pageBlock> <apex:panelGrid columns="4" id="leadLinks"> <apex:commandLink action="{!firstLead}" rerender="cMLeads, leadLinks">First</apex:commandlink> <apex:commandLink action="{!previousLead}" rerender="cMLeads, leadLinks" rendered="{!hasPreviousLead}">Previous</apex:commandlink> <apex:commandLink action="{!nextLead}" rerender="cMLeads, leadLinks" rendered="{!hasNextLead}">Next</apex:commandlink> <apex:commandLink action="{!lastLead}" rerender="cMLeads, leadLinks">Last</apex:commandlink> </apex:panelGrid> </apex:tab> </apex:tabPanel> </apex:outputPanel> </apex:form> </apex:page> Controller code: public with sharing class pagingController { Campaign campaign; public void pullCampaign() { campaign = [SELECT Id, Name FROM Campaign WHERE Id = :'701A00000000kGz']; } public Campaign getCampaign() { return campaign; } // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController con { get { if(con == null) { con = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Id, FirstName, LastName, MailingCity, MailingCountry FROM Contact Where Id in ( Select ContactId From CampaignMember where campaignId =:campaign.Id And ContactId <> null)])); // sets the number of records in each page set con.setPageSize(5); } return con; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } public List<Contact> getContacts() { return (List<Contact>) con.getRecords(); } // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController lead { get { if(lead == null) { lead = new ApexPages.StandardSetController( Database.getQueryLocator([ SELECT Id, FirstName, LastName, City, Country FROM Lead Where Id in ( Select LeadId From CampaignMember where CampaignId =:campaign.Id And LeadId <> null)])); // sets the number of records in each page set lead.setPageSize(5); } return lead; } set; } // indicates whether there are more records after the current page set. public Boolean hasNextLead { get { return lead.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPreviousLead { get { return lead.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumberLead { get { return lead.getPageNumber(); } set; } // returns the first page of records public void firstLead() { lead.first(); } // returns the last page of records public void lastLead() { lead.last(); } // returns the previous page of records public void previousLead() { lead.previous(); } // returns the next page of records public void nextLead() { lead.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancelLead() { lead.cancel(); } public List<Lead> getLeads() { return (List<Lead>) lead.getRecords(); } }

 

Hi there,

 

I am trying out paging using StandardSetController.  Everything works fine, until I do partial page refresh.  When I add rerender="test" to the commandLink, the previous button doesn't show up when I go to the next page. Does anyone know a way around to fix this issue?

 

Here is the code:

Visual force page: <apex:page controller="PagingController"> <apex:form > <apex:pageBlock id="test" title="Paging through Categories of Stuff"> <apex:pageBlockSection title="Category Results - Page #{!pageNumber}" columns="1"> <apex:pageBlockTable value="{!Contacts}" var="c"> <apex:column value="{!c.Name}" headerValue="Name"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> <apex:panelGrid columns="4"> <apex:commandLink action="{!first}" rerender="test">First</apex:commandlink> <apex:commandLink action="{!previous}" rendered="{!hasPrevious}" rerender="test">Previous</apex:commandlink> <apex:commandLink action="{!next}" rendered="{!hasNext}" rerender="test">Next</apex:commandlink> <apex:commandLink action="{!last}" rerender="test">Last</apex:commandlink> </apex:panelGrid> </apex:form> </apex:page> Controller Code: public with sharing class PagingController { // instantiate the StandardSetController from a query locator public ApexPages.StandardSetController con { get { if(con == null) { con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name FROM Contact Order By Name])); // sets the number of records in each page set con.setPageSize(5); } return con; } set; } // indicates whether there are more records after the current page set. public Boolean hasNext { get { return con.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } // returns the page number of the current page set public Integer pageNumber { get { return con.getPageNumber(); } set; } // returns the first page of records public void first() { con.first(); } // returns the last page of records public void last() { con.last(); } // returns the previous page of records public void previous() { con.previous(); } // returns the next page of records public void next() { con.next(); } // returns the PageReference of the original page, if known, or the home page. public void cancel() { con.cancel(); } public List<Contact> getContacts() { return (List<Contact>) con.getRecords(); } }

 

Hi there,

 

I have a list of records(i.e Campaigns) and when the user select a campaign, I am displaying the related CampaignMembers in the bottom of the page. Now I wanted to implement paging, and after implementing the paging, it is not displaying anything.

 

This is the code that I have on the Controller:

public ApexPages.StandardSetController campaignMembers { get { if(campaignMembers == null) { campaignMembers = new ApexPages.StandardSetController( Database.getQueryLocator([SELECT Id, Lead.Country, Lead.City, Lead.FirstName, Lead.LastName, LeadId, Contact.MailingCountry, Contact.MailingCity, Contact.FirstName, Contact.LastName, ContactId FROM CampaignMember WHERE CampaignId = :campaign.Id])); // sets the number of records in each page set campaignMembers.setPageSize(5); } return campaignMembers; } set; } public List<CampaignMember> getMembers() { if(campaign == null) return new List<CampaignMember>(); return (List<CampaignMember>) campaignMembers.getRecords(); }

 

When the user selects a campaign I am setting the variable campaign on the controller. How do I re-initialize the QueryLocator with the new campaign.Id?

Hi there I have the following code.

 

<apex:column value="{!IF(ISNULL(member.Contact), 'Lead', 'Contact')}" headerValue="Type" />

 

 

What is wrong with the above code? It's throwing a systax error. Missing ')'. Thanks.

Hi there,

 

I am trying to implement paging and I am not sure if this is doable and where to start.

 

Here is what I need to do:

 

I have a visualforce page that custom controller.  In the custom controller I have two set of arrays, and both of them hold CampaignMembers.  I am displaying both records on the UI. I want to do paging for both of them. Is it possible to do paging like this and where do I start? Thanks.

 

 

Hi there,

 

I am trying out the example on developers guide 'Building a Table of Data in a Page'(pg. 29)

 

<apex:page standardController="Account"> <apex:pageBlock title="Hello {!$User.FirstName}!"> You are viewing the {!account.name} account. </apex:pageBlock> <apex:pageBlock title="Contacts"> <apex:pageBlockTable value="{!account.Contacts}" var="contact"> <apex:column value="{!contact.Name}"/> <apex:column value="{!contact.Phone}"/> <apex:column value="{!contact.MailingCity}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>

 

 

I created an Account and I created two contacts for the Account.  One of the contact doesn't have MailingCity, so it's empty. The line below the first record stops after the Phone column. Is there a way to fix this?