1

I have two VF pages i need to pass value from my 1 st VF input field to 2nd VF page using common custom controller.

this is My Apex Code;

public class Sample{
public Sample(ApexPages.StandardController controller)
{}
public String Registration__c.Email_id__c  {get;set;}

    public void email() {
    System.debug('This is your registered email' + Registration__c.Email_id__c);
  }
}

this is my Vf Code

<apex:page standardController="Registration__c" extensions="Sample"  showheader="False" sidebar="False">
    <apex:messages />

            <apex:form >
                <html>
      <head>
      <title>RegistrationPage</title>

        <span style="display:block; margin:50px auto; text-align:Center;color:black;font-size:150%;">REGISTRATION PAGE - ONE TIME</span>
          <style>

           div.btnGroup1{
          text-align:right;margin-top:-24px;margin-right:100px;
           }
               div.btnGroup2{
          text-align:center;margin-top:30px;margin-right:550px;padding:8px*20px;
           }

       </style>
       </head>
        </html>
            <apex:pageBlock >
            <apex:pageBlockSection >  

            <apex:inputField required="true" value="{!Registration__c.Email_id__c}"/><br /> <br /> 
            <apex:inputField required="false" value="{!Registration__c.Mobile_number__c}"/><br /> <br /> 
            <apex:inputField required="false" value="{!Registration__c.Employee_number__c}"/>  <br /> <br /> 
             </apex:pageBlockSection>


             <div class="btnGroup2">  
             <apex:commandButton value="Save" action="{!save}" styleClass="buttonStyle" style="background:thistle ;width:110px;height:25px;font-size: 14px"/>
             </div>



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

But i am getting Illegal variable declaration: Registration__c.Email_id__c Error how i can achieve this

2

You need to change variable initialization in your controller

public class Sample{
public Registration__c reg {get;set;}
public Sample(ApexPages.StandardController controller)
{
    reg  = (Registration__c)controller.getRecord();
}


    public void email() {
    System.debug('This is your registered email' + reg .Email_id__c);
    // now you can pass the email in parameter or can get that.
  }
}

And as you have mention you are using same controller then you can make a wizard where all values in controller will be stored

PageReference acctPage = new PageReference('Your page URL);
acctPage.setRedirect(false);
 return acctPage;
1

You are trying to declare an sObject field as variable. This is not possible. Try the below code.

public class Sample{
    public Registration__c reg {get; set;}
    public String emailId {get; set;}
    public Sample(ApexPages.StandardController controller){
        reg = (Registration__c)Controller.getRecord();
        emailId = reg.Email_id__c;
    }

    public void email() {
        System.debug('This is your registered email' + emailId);
    }
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.