2
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 )

1 Answer 1

5

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.
   }
}
3
  • Link1 & Link2 is the two Recordtype names
    – rakesh
    Dec 3, 2012 at 16:55
  • OK it's still possible in a pretty similar way Dec 3, 2012 at 16:57
  • Is this Correct patern to proceed with<br/> <apex:pageblocktable value="{!record}" var="r"> <br/> <apex:commandLink action="{!r.link1}" value="Link1"/><br/> <apex:commandLInk action="{!r.link2}" value="Link2"/><br/> <apex:param name="rId" value="{!r.Id}" assignTo="{!rId}"/>
    – rakesh
    Dec 3, 2012 at 17:09

You must log in to answer this question.

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