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
bs881026bs881026 

How do i bind the extension with the visualforce action

Hello,
I have a scenario wherein i have to create a lookup field on the visualforce page--> select a contact--> fetch 5 fields of that contact --> make changes in the field value --> save it back--> Changes should reflect back in the backend.

Please let me know how to go about this.
I am new in this technology, so i very little idea of it.

Thanks,
Axaykumar VaruAxaykumar Varu
Create visualforce page with standard controller as contact put whichever fields you want to modify in apex:inputField tag. put save and cancel button as well.

for example:
 
<apex:page standardController="Contact" >

<apex:form>

<apex:commandButton value="Save" title="Save" action="{!save}" />

<apex:inputField value="{!contact.FirstName}" />

</apex:form>

</apex:page

 
bs881026bs881026
Hey Axay,
The thing that I need to do here is, first have a lookup field to Contact Object on the VF page--> then fetch 5 fields of the selected contact--> get the 5 field values in text boxes--> edit those values--> save it back.

I could not follow your previous code.
Please let me know,what is the way to achieve it.

Thanks,
bs881026bs881026
VF Page
----------------------
<apex:page standardController="Contact" extensions="ModifyContactData">
<apex:form >
<apex:inputField id="contactList" value="{!cont.SuperContact__c}"/>
<apex:pageBlock >
<apex:pageBlockTable id="pageblock1" value="{!contDetail}" var="contactdetail">
<apex:inputField id="contName" value="{!contactdetail.name}"/>
<apex:inputField id="contPhone" value="{!contactdetail.phone}"/>
<apex:inputField id="contEmail" value="{!contactdetail.Email}"/>
</apex:pageBlockTable>

 <apex:commandButton value="GO!" action="{!go}"/>   

</apex:pageBlock>

 </apex:form> 
</apex:page>

Class
------------
public class ModifyContactData
{    
    public Contact cont{get;set;}
    public Contact contDetail{get;set;}
  /*public string Name{get;set;}
    public string Phone{get;set;}
    public string email{get;set;}*/
    
    List<Contact> contactId;
     public ModifyContactData(ApexPages.StandardController std)
     {
         this.cont = (Contact)std.getrecord();
         cont = new Contact();
         //contactId = ApexPages.currentPage().getParameters().get('id');
     } 
     
     public Contact go()
     {
       system.debug('********');
       contDetail = [select Name, Phone,email from Contact where id =:cont.SuperContact__c];
       system.debug('Queried Values' +contDetail);
       return null;  
     }  


}
I am getting Could not resolve the entity from <apex:inputField> value binding '{!contactdetail.name}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.  Error

please let me know, what is going wrong.

Thanks,
bs881026bs881026
Hello,
Can anyone please let me know, how to go for this.
Thanks,