I am trying to achieve the following.
- An icon on a parent page will open a new child pop-up.
- In the child pop-up, the user selects a value from the picklist and clicks add. When the user clicks add it gets populated in the table below. The user can add multiple records. The user then clicks Close to close the pop up. Now if the user clicks on the icon again, it should display the values already selected by the user in the child pop- up.
How can I achieve this i.e. displaying the recently added data on reopening of the pop up ? Any help would be appreciated. Here is my code:
Parent page:
<apex:page>
<script>
function openPopup()
{
var url="/apex/AddLanguage";
popupWindow=window.open(url, 'Popup','height=700,width=850,left=100,top=100,scrollbars=no,toolbar=no,status=no, resizable=no');
if (window.focus)
{
popupWindow.focus();
}
return false;
}
function closePopUp()
{
if (null!=popupWindow)
{
popupWindow.close();
}
}
</script>
<apex:outputLink id="addLanguage" onclick="openPopup(); return false;">
<apex:image url="SomeIcon"/>
</apex:outputLink>
</apex:page>
Child Pop Up:
<apex:page controller="AddLanguageController">
<script>
var popup=window.parent.opener;
function ClosePopUpWindow()
{
if (null!=popup)
{
popup.closePopUp();
}
return false;
}
</script>
<apex:form >
Language Known: <apex:inputText value="{!LanguageKnown}" />
<apex:commandButton value="Add" action="{!Add}"/>
<table border="0">
<tr>
<td><b>Language</b></td>
<td><b> Created Date</b> </td>
</tr>
<apex:repeat value="{!data}" var="dt">
<tr>
<td> <apex:outputText value="{!dt.Language}"/></td>
<td> <apex:outputText value="{!dt.DateCreated}"/></td>
</tr>
</apex:repeat>
</table>
<apex:commandButton id="btnClose" immediate="true" value="Close" onClick="ClosePopUpWindow();"/>
</apex:form>
</apex:page>