0

Actually, the requirement is: there is one application(other then salesforce application, example Java), they want to load a public VF page(Our Salesforce application page) by clicking a Link(Post Parameters request - Java Page). On page load, populate the POST Requested data in VF page.

Summary:

  1. Link(In Java Site): By Clicking on link, some data needs to be pass into salesforce application by using POST method.
  2. Salesforce application needs to parse the POST requested parameters and redirect to one vf page and pre-populate in page sothat user should not to fill some of the field again.

1 Answer 1

1

You can simply use traditional http post to a public VF page hosted on force.com site or community site and then process that information in apex controller tied with VF page.

UPDATE:

    public with sharing class YourPostEndpointController {
    // call this variable on VF page directly i.e. {!ResponseMsg}
    public string ResponseMsg{get{
         processRequest();
         return 'Data populated';
         }
         set;
         }
    public YourPostEndpointController(){

    }
    public void processRequest(){
         Map<String, object> parametersMap=new Map<String, object>();
            if (ApexPages.currentPage() != null 
            && ApexPages.currentPage().getParameters()!=null 
            && ApexPages.currentPage().getParameters().size()>0){
                 parametersMap=ApexPages.currentPage().getParameters();
            }
            /// do your processing here
    }
}

UPDATE 2: Here's the solution Post Request VF page


<apex:page showHeader="false">
<h1>Post your data</h1>
<form id="postDataForm" name="postDataForm" method="post"
    action="https://bsingh-developer-edition.na34.force.com/ff/SamplePostHandler" enctype="application/x-www-form-urlencoded">
    <div><label for="firstname">First name</label><input id="firstname" name="firstname" type="textbox"/></div>
    <div><label for="lastname">Last name</label><input id="lastname" name="lastname" type="textbox"/></div>
    <div><label for="email">Email</label><input id="email" name="email" type="textbox"/></div>
    <div> <input type="submit"
                    name="btnSubmit"
                    value="Submit" class="btn"/>
</div> </form>
</apex:page>

Post Handler VF page:


<apex:page showHeader="false" controller="SamplePostHandlerController">
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Page
{!ResponseMsg} 
<div><label for="firstname">Param 1</label><input id="firstname" type="textbox" value="{!param1}"/></div>
    <div><label for="lastname">Param 2</label><input id="lastname" type="textbox" value="{!param2}"/></div>
    <div><label for="email">Param 3</label><input id="email" type="textbox" value="{!param3}"/></div>
    <!-- End Default Content REMOVE THIS -->
</apex:page>

Post Handler Apex class

            public with sharing class SamplePostHandlerController {

            public string param1{get;set;}
            public string param2{get;set;}
            public string param3{get;set;}
                // call this variable on VF page directly i.e. {!ResponseMsg}
                public string ResponseMsg{get{
                    processRequest();
                    return '';
                    }
                    set;
                    }
                public SamplePostHandlerController(){
                param1='';
                param2='';
                param3='';
                }
                public void processRequest(){
                    Map<String, object> parametersMap=new Map<String, object>();
                        if (ApexPages.currentPage() != null 
                        && ApexPages.currentPage().getParameters()!=null 
                        && ApexPages.currentPage().getParameters().size()>0){
                            parametersMap=ApexPages.currentPage().getParameters();
                        }

                        for(String key: parametersMap.keyset()){

                        if(key=='firstname'){
                        param1=parametersMap.get(key)+'';
                        }
                        else if(key=='lastname'){
                        param2=parametersMap.get(key)+'';
                        }
                        else if(key=='email'){
                        param3=parametersMap.get(key)+'';
                        }
                        }
                        /// do your processing here
                }
            }
0

You must log in to answer this question.

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