I have one parent page with a parentManagedBean开发者_StackOverflow社区
(attached to Session Scope). On click of a button on this parent page, one popup comes which has a childManagedBean
(attached to Request scope).
Now ChildManagedBean
holds a reference to parentManaged
bean through JSF's managed property facility. On this popup window, user selects some option which populates a large value object. I use the managed property of childManagedBean
to set the values from this large object to that of parentManagedBean
.
Problem is - The parent page shows a link, on click of which a popup comes, on selection of the popup, the popup disappears and set the values to the parentManaged
bean. So far so good, but the newly set values need to appear on the parent page. This is where I am stuck. How to programmatically render the master page/render page when I am at the child managed bean? Is there a way I can get handle of the parent page and refresh it?
Note: I'm using JSF 1.1
EDIT-
After following the solution of "resubmit-ing the form" from javascript, I am seeing that the old form is getting resubmitting which overwrites all of my changed values.
EDIT-- What I find now is - if I issue a GET request, meaning, after the child window is closed, if I go to the main window and just press enter on the address again (which issues an GET request I believe), the newer values - updated values are coming back. So the point here is - how to issue a get request using javascript or is there any better way of doing this through JSF ?
I had some similar case, and I triggered a refresh of the parent page with javascript.
Child
When the user clicked "save" in the popup, the action is submitted to the child with POST, which updates the parent bean, and then redisplay the child page with some javascript:
window.opener.doRefresh();
window.close();
This gave the illusion that when the user click on "save", the popup is closed directly. You can maybe use a similar trick in your case.
Parent
function doRefresh()
{
if(document.forms[0].onsubmit)
{
document.forms[0].submit();
}
}
function openChild()
{
window.open("path_to_child.jsf","_blank","");
return false;
}
If I remember well, I couldn't use location.reload
to refresh the page. Either because reload
may resubmit an old form, or because it issues a GET request which JSF doesn't like that much. So I was submitting the form programmaticaly. This essentially achieves the same.
This solution was not a masterpiece of elegance, but well, it worked for me :)
精彩评论