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
Aditya Rayavarapu 5Aditya Rayavarapu 5 

Passing InputFIELD from one VF page to another

Hello,
I have two VF pages and would like to pass info from the first page to the second.

If the field was an inputTEXT field, then I pass the info using:

Page:
<apex:page controller="xxxx">
    <a href="/apex/page2?MyVariable=25">Click Me</a>
            <apex:pageblockButtons >
             <apex:commandButton value="click Me" action="{!Transfer}" />
            </apex:pageblockButtons>
                  <apex:inputText value="{!Value2Pass}" />
     </apex:page>

Controller:
public class xxxx {
    public String Value2Pass { get; set; }
    public PageReference Transfer() {
        PageReference newPAge = page.page2;
        newPage.getParameters().put('MyVariable1', Value2Pass);
        return newPage; 
        }


And then using the corresponding code on page 2 to get these values as an OutputText:

<apex:page controller="yyyy">
            <apex:Outputtext value="{!Var01}" />
 </apex:page>

Controller:
public class yyyy {
    public String Var01 { get; set; }
    public yyyy() {
        Var01 = Apexpages.currentPage().getParameters().get('MyVariable1');
          }
}
HOWEVER, how would I achieve the same thing if I wanted to have an InputField in the first page (Case_FirstName__c) and transfer the information in this field as an OutputField in page 2?
I've tried using the standard controller for Case, but it does not work with.

Thanks!
RamuRamu (Salesforce Developers) 
The below article outlines different ways to accomplish your requirement

http://www.forcetree.com/2009/06/passing-parameters-to-visualforce-page.html
VaasuVaasu
Use same class for both the pages. Then you can save the value selected in one page in the class variable and use that to display in the other page.

<apex:page standardController="Case" extensions="xxxx">
<apex:form >
    <a href="/apex/page2?MyVariable=25">Click Me</a>
           
             <apex:commandButton value="click Me" action="{!Transfer}" />
           
                  <!--<apex:inputText value="{!Value2Pass}" />-->
                  <apex:inputfield value="{!obj.accountId}"/>
 </apex:form>
     </apex:page>
     
     
     public class xxxx {
public Case obj{get;set;}
public xxxx(apexpages.standardcontroller std)
{
    obj = new Case();
}
    public String Value2Pass { get; set; }
    public PageReference Transfer() {
        PageReference newPAge = page.page2;
        newPage.getParameters().put('MyVariable1', Value2Pass);
        return newPage; 
        }
        }
        
        
        <apex:page standardController="Case" extensions="xxxx">
            <apex:Outputtext value="{!obj.accountId}" />
 </apex:page>