0

I Wanna Load data in fields when i click a simple link.

I have this, but is not working

apex:pageBlockSection columns="2" id="contactFields"> 
          <apex:pageBlockSection id="UpdateElectrodependiente" columns="2" >
                    <apex:commandLink action="{!actionElectrodependiente}" reRender="contactFields" value="Cargar Datos"/>
         </apex:pageBlockSection>
         <apex:pageBlockSection id="FirstName" columns="2">
                 <apex:inputField label="Nombre Paciente" value="{!contacto.FirstName}"></apex:inputField>
         </apex:pageBlockSection>
  </apex:pageBlockSection>

And this is my constructor and method to load data:

public class ATCL_VFC058_ElectrodependienteController {

public String idAccount = System.currentPageReference().getParameters().get('id');

public Contact contactoSolicitante = new Contact();  
public Contact contacto = new Contact();

public Case caso {get;set;}    

public List<Contact> Records {get; set;}

Public RecordType rt = [select Id,name from RecordType where Name ='AP' and SobjectType = 'Case'];  


public ATCL_VFC058_ElectrodependienteController() {

    this.caso=new Case();
    this.caso.Reason = 'CORTE Y REPOSICION / MOROSIDAD';
    this.caso.RecordTypeId=rt.id;
    this.contacto =contacto;//new Contact();

}       

public Contact getContacto() {
    return this.contacto;
}

public void setContacto(Contact cto) {
    this.contacto = cto;
} 
public void loadData(){
    this.contacto.LastName='HOLA';
}

When i click the command link i wanna load the hello in LastName field

0

2 Answers 2

0

Few thing you should notice..

In controller you have set the last name and your displaying the firstname in vf page. Declaration of contacto must be public in order to access in vf Page.

visual force Page

   <apex:form>
    <apex:pageBlock id="contactFields">
        <apex:pageBlockSection columns="2" > 
          <apex:pageBlockSection id="UpdateElectrodependiente" columns="2" >
                    <apex:commandLink action="{!loadData}" reRender="contactFields" value="Cargar Datos"/>
         </apex:pageBlockSection>
         <apex:pageBlockSection id="LastName" columns="2">
                 <apex:inputField label="Nombre Paciente" value="{!contacto.Lastname}"></apex:inputField>
         </apex:pageBlockSection>
    </apex:pageBlockSection>
    </apex:pageBlock>
  </apex:form>

controller

public class ATCL_VFC058_ElectrodependienteController {
   public contact contacto {get;set;}
   public ATCL_VFC058_ElectrodependienteController() {
   this.contacto =new Contact();
}       

public void loadData(){
    this.contacto.LastName='Hello';
}
}
0

you need to specify getters and setters or properties and instantiate field, that would interact with VF page.

public Contact contacto {get; set;}
...
public ATCL_VFC058_ElectrodependienteController(){
    ...
    this.contacto = new Contact();
    ...
} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .