You need to sign in to do that
Don't have an account?
Shwetal Desai
Returning Data from Pop up VF page to Parent VF Page
There are two VF Pages
X is parent vf page and Y is pop up vf page
there is a commandlink on Y page
and two <apex:param> component on pop vf page
There is one Command Link on X parent page on click of which Y pop up page will open.
Source Code:
X Page [parent page]:
<apex:page standardController="POS__c" extensions="PointOfSale" tabStyle="POS__c">
<script type="text/javascript">
<script type="text/javascript">
function openclient()
{
var clt = window.open("{!$Page.clientlookup}?ctxt=client&ctid=clientid","lookup","width=750,height=390");
}
</script>
<apex:form id="frmpos">
<apex:pageBlock title="New Ticket" id="pos">
<apex:inputText value="{!clientId}" id="client"/>
<apex:commandLink onclick="openclient();return false();">
</apex:commandLink>
<apex:inputText id="clientid"/>
{
var clt = window.open("{!$Page.clientlookup}?ctxt=client&ctid=clientid","lookup","width=750,height=390");
}
</script>
<apex:form id="frmpos">
<apex:pageBlock title="New Ticket" id="pos">
<apex:inputText value="{!clientId}" id="client"/>
<apex:commandLink onclick="openclient();return false();">
</apex:commandLink>
<apex:inputText id="clientid"/>
Y Page [pop up Page]:
<apex:page controller="ClientLookUp" showHeader="false" tabStyle="Client__c" sidebar="false" wizard="true">
<script type="text/javascript">
window.opener.document.getElementById('clientId').value = '{!$CurrentPageReference.parameters.cid}';
alert('{!$CurrentPageReference.parameters.cid}');
return false;
</script>
<script type="text/javascript">
window.opener.document.getElementById('clientId').value = '{!$CurrentPageReference.parameters.cid}';
alert('{!$CurrentPageReference.parameters.cid}');
return false;
</script>
<apex:form id="list">
<apex:pageblock title="Select Client">
<apex:pageBlockSection title="Client List" id="result">
<apex:outputPanel id="rlist" title="Result">
<apex:pageBlockTable value="{!searchresult}" var="clt" columns="5" id="list" width="100%">
<apex:column value="{!clt.Name}"/>
<apex:column >
<apex:facet name="header"><b>Client</b></apex:facet>
<apex:commandLink id="classtype" onclick="setvalue();">
<apex:param name="cid" value="{!clt.Id}"/>
<apex:param name="ccode" value="{!clt.Client__c}"/>
{!clt.Client__c}
</apex:commandLink>
</apex:column>
<apex:pageblock title="Select Client">
<apex:pageBlockSection title="Client List" id="result">
<apex:outputPanel id="rlist" title="Result">
<apex:pageBlockTable value="{!searchresult}" var="clt" columns="5" id="list" width="100%">
<apex:column value="{!clt.Name}"/>
<apex:column >
<apex:facet name="header"><b>Client</b></apex:facet>
<apex:commandLink id="classtype" onclick="setvalue();">
<apex:param name="cid" value="{!clt.Id}"/>
<apex:param name="ccode" value="{!clt.Client__c}"/>
{!clt.Client__c}
</apex:commandLink>
</apex:column>
</apex:pageBlockTable>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
ERRORS:
1. Onclick of commandLink on Y Page it gives error "window.opener.document is null or not an object".
2. {!$CurrentPageReference.parameters.cid} is blank.
for first error i tried "window.opener.document.form.client.value", "window.opener.form.client.value" but error remains same.
any help/suggesions are greatly appreciated.......
Thanks
should this be {!$CurrentPageReference.parameters.ctid} ? since that is what you are passing ?
1. Onclick of commandLink on Y Page it gives error "window.opener.document is null or not an object".
the id of an visualforce tag can be generated using something like {! $Component. frmpos .client }
see the documentation on $Component
http://www.salesforce.com/us/developer/docs/pages/Content/pages_access.htm#pages_access_dom
<apex:commandLink id="classtype" onclick="setvalue();">
<apex: param name="cid" value="{!clt.Id}"/>
<apex: param name="ccode" value="{!clt.Client__c}"/>
{!clt.Client__c}
</apex:commandLink>
</apex:column>
{
var newWindow = window.open("{!$Page.clientlookup}?txt=client&ctid=clientid","newWindow","width=670,height=390");
newWindow.creator=self;
Message Edited by Shwetal Desai on 09-09-2008 01:08 AM
Message Edited by Shwetal Desai on 09-09-2008 01:33 AM
in this code
it looks to me that this is supposed to be inside a function?
also, in this code
you have no action method, so the only thing that will run is a javascript method, which is not defined
the param tag works with Apex action methods, not onclick() javascript functions, so cid will never be set.
also, this code i wrote to pass values of {!clt.Id} and {!clt.Client__c} from this pop up page to parent page using javascript...
but as u say i havent wrote action for this commandlink and without action (apex code) param tag will not set its value..
Shwethal.
I don't know if you already found a solution for this. I was getting the same error and I was able to fix it by using window.top.opener.document.getElementById. Hope this helps.
yeah i got the solution...
I used same line
window.parent.opener.document.getElementById
H Shwetal,
I was facing the exact issue. This forum post helped me a lot!
Thanks much!
Regards
Mukul
H Shwetal,
I have used the code:
window.top.opener.document.getElementById....;
or
window.parent.opener.document.getElementById....;
but not returning data...
the syntax is correct?
thnk's
Antonio by italy