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
Nag86Nag86 

Session is not maintained between two visual force pages

Hi all, Urgent help required!!!! We have a requirement of opening a popup onselecting a checkbox. Iam able to open a visual force page from a visual force page after selecting check box. Both VF Pages are defined with extensions as same controller. When the pop up opens, the values in the controller are reset to null. How do i maintain session in between these two pages and use the values in the controller in the second page also. Thanks in Advance Nag
Best Answer chosen by Admin (Salesforce Developers) 
akschampakschamp

Hi All,


The problem of YUI popup with IE7 + is resolved........

 

We need to enable some security settings like cross domain script, Allow Scriptlets, Active scripting..etc etc, once we enabled all valid of these, YUI popup is working fine.

All Answers

Ron HessRon Hess

opening a new window will cause a new request, not a partial page request.  So, it is not possible to share a controller context.

 

You can pass query string parameters to the popup, but passing info back is not so easy.

 

I recomend a different type of popup, called a floating div or hidden div that is modal.

 

This is actually the same page, so page session/context is shared and user input info is available (in the controller) after the div is hidden again.

 

Simple examples are found here:

http://www.javascripttoolbox.com/lib/popup/example.php

 

 

 

There is a larger example of this method on the following site:

http://particletree.com/features/lightbox-gone-wild/

 

i believe YUI also has such a modal DIV that you could use to get the same result.

 

I don't have a visualforce sample of this yet, so if you do build one please post back your code!

 

 

 

Message Edited by Ron Hess on 02-04-2009 11:05 AM
Ron HessRon Hess

Ok, i found a good example of this on javascripttoolbox.com

 

lots of good libraries there.

 

here is the Visualforce version of a modal dialog

 

 

<apex:page controller="varController"> <!-- read : http://www.javascripttoolbox.com/lib/popup/example.php download JS from: http://www.javascripttoolbox.com/libsource.php/popup/combined/popup.js --> <apex:includeScript value="{!$Resource.popup}" /> <apex:form id="theform"> <apex:outputPanel id="modal" style="border:1px solid black; width:250px; display:none;"> <apex:pageBlock > This is a modal popup!<br /> Enter your new value here, click Done. <apex:inputText value="{!inputVar}" /> <apex:commandButton value=" Done " onClick="Popup.hide('{!$Component.modal}')" rerender="result" /> </apex:pageBlock> </apex:outputPanel> <apex:pageBlock > <apex:pageBlockButtons > <apex:commandButton onclick="Popup.showModal('{!$Component.modal}');return false;" value="Show Modal Popup" /> <apex:commandButton onclick="Popup.showModal('{!$Component.modal}',null,null,{'screenColor':'#999999','screenOpacity':.6});return false;" value="Show Modal Popup With A Custom Screen"></apex:commandButton> </apex:pageBlockButtons> <apex:outputPanel id="result"> <h2><apex:outputText value="{!inputVar}" /></h2> <br /> </apex:outputPanel> </apex:pageBlock> </apex:form> </apex:page>

 

 and the controller:

 

public class varController { public string inputVar { get; set; } }

 

 

You can download the library JS and store this in a static resource.

The library i used is here : 

 http://www.javascripttoolbox.com/libsource.php/popup/combined/popup.js

 

 

 

KashyapKashyap

Hi Ron,

 

Thanks for a quick response.

 

Iam stuck up with some issue.  I am landing up with some java scrpipt errors like "GenericSfdcPage" undefined, "Sidebar" undefined.

 

Do i need to do some additional settings for the code to work.?

 

 

 

Ron HessRon Hess

that's strange.

 

my entire page is just as posted.  did you try a simple page like this?

KashyapKashyap

Yes Ron.

 

I have tried the sample posted above.

Iam getting the javascript erros. Not sure about the issue.

In urgent need of help. We have a demo with client tommorrow.

KashyapKashyap

Ron,

 

I have tried tehsame code using mozilla.Its working fine.

 

May be i need to change the setting in my IE.

 

but how can i expect my client to change the settings....can there be any work around.??

Ron HessRon Hess

Here is an article on how to build this popup using YUI, thanks to Dave Carroll ( devAngel) for the code!

 

http://wiki.apexdevnet.com/index.php/Visualforce_Popup

 

Visualforce Popup

Message Edited by Ron Hess on 02-05-2009 10:47 AM
van_epvan_ep

I tried this example and is not working in IE, only Mozilla. Also, the recent posted example http://wiki.apexdevnet.com/index.php/Visualforce_Popup that uses the YAHOO library works only in this  browser. It seems both libraries use some assumptions that are only valid in Mozilla browser. 

 

More than that I removed the use of varController (display only a text and "Done" button in modal dialog), associate the page with standardController="Account" and insert it in Account page layout. The popup is "cut" by next subSection (in Mozilla, in IE doesn't work at all).

 

From the investigation I made so far the "cut" window behaviour seems to be a security cross domain issue.

I'm very interested to know if there is any solution to embedd an apex:page in a standard object page and to be able to open "any" window on top of any other existing windows (at least my parent page window).

Thanks in advance.

Ron HessRon Hess
I've updated the sample, it now works in IE7.  I had to remove the modal:true, for some reason YUI gets the zindex of the overlay wrong in IE7 and i don't know how to resolve that yet.
akschampakschamp

Hiiii,

 

I have just used the YAHOO modal popup with the IE 7 as suggested , it still gives error "YAHOO is undefined",

 

Not sure abt th issue, I need urgent help on this, please please suggest if any..........

 

Below is url for screnshot of the javascript error I am getting on IE

 

http://picasaweb.google.co.in/akshay.subscribe/YUI?feat=directlink#slideshow/5493005009522062930

 

Many Thanks,

Akshay

 

 

akschampakschamp

Hi All,


The problem of YUI popup with IE7 + is resolved........

 

We need to enable some security settings like cross domain script, Allow Scriptlets, Active scripting..etc etc, once we enabled all valid of these, YUI popup is working fine.

This was selected as the best answer