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
Shwetal DesaiShwetal Desai 

Pass parameters From One VF page to another VF Page

Hi,
 
There are two Visual force pages i have,
 
One is for master custom object and another is for detail custom object
now what i have to do is when user click on save button on master vf page it will redirect the user to Detail vf page and also set the Id and Name of Master record in the apropriate <apex:inputfield> of master's in detail vf page.
I tried it with javascript and querystring, but its not work..
 
anyone has idea about it?
any help/guidance pls?  
 
 
Thanks
KevinKKevinK
This may give you a few ideas...

http://forums.sforce.com/sforce/board/message?board.id=Visualforce&message.id=4054
Shwetal DesaiShwetal Desai

Thanks for reply

let me make my problem more clear.

I have two visual force pages, On page-1 i have one command button onclick of which page-2 will get open as a pop up page.

now on page-2 i have two <apex:inputHidden> components one fir Id and one for Name.

I've passed the value of Id & name in a page-2 using query string.

now my problem is i need to save this id and name in custom object when other values will be saved using Save button and then i have to return on page-1.

to do this i need to fatch value of Id & Name from query string [I did this through javascript, i have these values in a javascript variable.]

but now how can i pass this values to controller and how can i save it.

please have a look on code

VF Page Code:
<apex:page Controller="GiftCertificate" tabStyle="GiftCertificate__c" showHeader="false" title="Sell Gift Certificate" wizard="true" >
<script type="text/javascript">
function IdName()
{
    var query = window.location.search.substring(1);  
    var vars = query.split("&");  
    for (var i = 0;i < vars.length ;i++) 
    {    
        var pair = vars[i].split("=");    
        if (pair[0] == "pos") 
        {   
            var posid = pair[1];
        }
        if (pair[0] == "name")
        {
            var posname = pair[1];
        }  
    }
document.getElementById("posid").value = posid;
document.getElementById("posname").value = posname;
}
</script>
<apex:form>
<apex:pageBlock title="Sell Gift Certificate">
  <apex:pageBlockButtons location="bottom">     
    <apex:commandButton action="{!save}" value="Save"/>
    <apex:commandButton onclick="window.top.close()" value="Cancel"/>
    <apex:commandButton onclick="getPOS();return false;" value="Get Ticket No."/>
  </apex:pageBlockButtons>

    <apex:pageBlockSection collapsible="true">
      <apex:inputHidden id="posname" value="{!posname}"/>
      <apex:inputHidden id="posid" value="{!posid}"/>
    </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Controller Code:
public class GiftCertificate 
{    
    GiftCertificate__c giftcert;
    
    public ID posid{get; set;}
    public String posname {get; set;}

    public GiftCertificate__c getgiftcert()
    {
        if(giftcert == null)
            giftcert = new GiftCertificate__c();
        return giftcert;
    }
    public PageReference save()
    {return null;}
}


 Please guide me and show me proper way to finish this functionality.. as its urgent.

 

Thank u much in advance.

 

SabaSaba

Please refer http://wiki.apexdevnet.com/index.php/Using_Browser_Technologies_in_Visualforce_-_Part_2

 

 

This provides a possible solution.