Find your content:

Search form

You are here

How to navigate to another page with param

 
Share
I have 2 recordType names with commandlink on my visual force page with the action attribute & param for Id passing to another page.

What Im look for is when link1 is clicked the page need to redirect to VF page1 & when link2 Is clicked the page need to redirect to another Vf page. so two different pages to two different links with Id Passing. Is this can be done 

link1 (visualforce page 1 with I/p fields)
link2 (visualforce page 2 with I/p fields )

Attribution to: rakesh

Possible Suggestion/Solution #1

Most traditional way is to use the controller and the Page Reference class.

public class mySecondController{
    public PageReference link1() {
        PageReference pr = new PageReference('url');
        pr.getParameters().put('recordTypeId', '..id..');
        pr.setRedirect(true);
        return pr;
    }


    public PageReference link2() {
            PageReference pr = new PageReference('url');
            PageReference.getParameters().put('recordTypeId', '..id..');
            pr.setRedirect(true);
            return pr;
        }
}

and on the page, reference these pagereference actions in the commandlinks:

<apex:page controller="mySecondController">
    <apex:sectionHeader title="New Account Edit Page" />
    <apex:form>
        <apex:pageBlock title="Create a New Account">
            <apex:pageBlockButtons location="bottom">
                <apex:commandLink action="{!link1}" value="Link1"/>
                <apex:commandLInk action="{!link2}" value="Link2"/>
                </apex:pageBlockButtons>
           </apex:pageBlock>
    </apex:form>
</apex:page>

Update

In the controller for the 2nd page, get the Id of the recordtype and assign it to the object your creating.

public controllerClassPage2{
   public controllerClassPage2{
       string recordTypeId = PageReference.getParameters().get('recordTypeId');
       //construct your new object with recordtypeid string.
   }
}

Attribution to: jordan.baucke
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/5012

My Block Status

My Block Content