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
newcloudcodernewcloudcoder 

Problems with Apex Coding to develop a Visual Force Page..How to call a object?

Hi all,

I'm new to this programming language. Pls help me out in this.

 

Actually I tried to create a visual force Membership page with few fields such as Firstname, last name, city, phone, email & type ( type being picklist.).. Addittionally  I want to display all the member records in the second page(MembershipDetail) in a table format with the same fields as columns. (An exact replica of an account.) I wrote the pages and classes but couldn't finish this task .. I had created an custom Membership object (Membership__c) with the six custom fields as mentioned above..

 

I went on writing my code and was facing problems in calling an object from first page to second page. my coding goes like this..

 

 



 

<apex:page tabStyle="Membership__c" controller="MembershipController">
<apex:sectionHeader title="Membership Edit" subtitle=" New Membership"/>
    <apex:form >
        <apex:pageBlock title="Membership Edit">
        <apex:pageBlockSection title="Information"/>
            <apex:pageblockButtons >
                <apex:commandButton value="Save" action="{!Save}" />
                <apex:commandButton value="Save&New" action="{!SaveAndNew}" />
                <apex:commandButton value="Cancel" action="{!Cancel}" />
            </apex:pageblockButtons>
            <apex:pageBlockSection columns="4">
            First Name<apex:inputText value="{!member.First_Name__c}"/>
            Last Name<apex:inputText value="{!member.Last_Name__c}" />
            City<apex:inputText value="{!member.City__c}" />       
            Phone<apex:inputText value="{!member.Phone__c}" />
            Email<apex:inputText value="{!member.Email__c}" />     
            Type <apex:selectList id="Type" size="1">
                    <apex:selectoption itemLabel="Prospect" itemValue="Prospect"></apex:selectoption>
                    <apex:selectoption itemLabel="Customer-Direct" itemValue="Customer-Direct"></apex:selectoption>
                    <apex:selectoption itemLabel="Customer Channel" itemValue="Customer Channel"></apex:selectoption>
                    <apex:selectoption itemLabel="Tech Partner" itemValue="Tech Partner"></apex:selectoption>
                </apex:selectList>
            </apex:pageblocksection>
            </apex:pageBlock>
    </apex:form>
</apex:page> 


 

 

public class MembershipController {

  
    public PageReference Cancel() {
        return null;
    }


   public Membership__c member{get;set;}
    
    public MembershipController (){
     member=new Membership__c();
    
    }
  
    public PageReference SaveAndNew() {
        return null;
    }
    
    public void SaveOperation(String operation){       
        }  

    public PageReference Save() {
        insert member;  
        PageReference pg = new PageReference('/apex/MembershipDetailsPage');
        
         return pg;
    }

}

 

</apex:page>

 

<apex:page tabStyle="Membership__c" controller="MembershipDetailsController">
 <apex:form >
    <apex:pageblock >
        <apex:pageBlockSection columns="8">
            <apex:pageBlockTable value="{!HistoryList}" var="hl">
             <apex:actionFunction name="Edit"/>
               <apex:actionFunction name="Delete"/>             
               <apex:column value="{!hl.First_Name__c}"/>
               <apex:column value="{!hl.Last_Name__c}"/>
               <apex:column value="{!hl.City__c}"/>
               <apex:column value="{!hl.Phone__c}"/>
               <apex:column value="{!hl.Email__c}"/>
               <apex:column value="{!hl.Type__c}"/> 
            </apex:pageblocktable>      
       </apex:pageBlockSection>    
    </apex:pageblock>
  </apex:form> 
           

 

public class MembershipDetailsController{

public List<Membership__c> getHistoryList(){                    
        List<Membership__c> MemberHistory = [Select id,First_Name__c,Last_Name__c,

City__c,Email__c,Phone__c,Type__c from Membership__c order by createddate desc];    

                return memberhistory;

}

}



in the membership detail page (second page) , I need to call the object instead of calling each and every parameter from the membership page(first page).  

Overview: If I  fill in the new membership details and click save, i need to be redirected to the Membership detail page where I can see the tabular list of all the members and their details.. (Same as if you see account detail page)

Could someone pls help me out with this..? your help is gratly appreciated.

 

thanks

 

rohitsfdcrohitsfdc

hi,

i didnt get your problem. when u click save on the first page, what do you want to see?? tabular list of all the records or detail page of newly inserted record?

 

newcloudcodernewcloudcoder

YEs Rohit. I need that tablular list of all the records in my membership detail page..hoping for a prompt reply. thanks in advance..

rohitsfdcrohitsfdc

hi,

in  your second page, simply call standardSetController, which will work on all the records.

 

<apex:page standardController="Membership__c" recordSetVar="members">
 <apex:form >
    <apex:pageblock >
        <apex:pageBlockSection columns="8">
            <apex:pageBlockTable value="{!members}" var="hl">
             <apex:actionFunction name="Edit"/>
               <apex:actionFunction name="Delete"/>             
               <apex:column value="{!hl.First_Name__c}"/>
               <apex:column value="{!hl.Last_Name__c}"/>
               <apex:column value="{!hl.City__c}"/>
               <apex:column value="{!hl.Phone__c}"/>
               <apex:column value="{!hl.Email__c}"/>
               <apex:column value="{!hl.Type__c}"/> 
            </apex:pageblocktable>      
       </apex:pageBlockSection>    
    </apex:pageblock>
  </apex:form>
</apex:page>

 there is no need for custom controller or extensions.

 

hope this helps you

newcloudcodernewcloudcoder

rohit,

I appreciate your help.. how to add up the columns in the search item list? When I click view all memberships a page displays with all new members added along with their details ina tabular column..right? Here in this table I could only see the membership name. how to add other columns to it? find the page in the link below.. You would know what exactly I'm asking for..

 http://tinyurl.com/3thz4yb

thanks for your help..