Hi,
I was astonished that I could not directly point you to an example of the demo workplace... - so we added one (available with this week's update, which will roll out somewhere today...).
Here is the code:
Calling Pagebean:
Code:
package workplace;
import java.io.Serializable;
import org.eclnt.editor.annotations.CCGenClass;
import org.eclnt.jsfserver.defaultscreens.ModalPopup;
import org.eclnt.workplace.IWorkpageDispatcher;
import org.eclnt.workplace.WorkpageDispatchedPageBean;
@CCGenClass (expressionBase="#{d.DemoPageBeanPopupOpeningClosing}")
public class DemoPageBeanPopupOpeningClosing
extends DemoBasePageBean
implements Serializable
{
// ------------------------------------------------------------------------
// constructors & initialization
// ------------------------------------------------------------------------
public DemoPageBeanPopupOpeningClosing(IWorkpageDispatcher workpageDispatcher)
{
super(workpageDispatcher);
}
public String getPageName() { return "/workplace/demopagebeanpopupopeningclosing.jsp"; }
public String getRootExpressionUsedInPage() { return "#{d.DemoPageBeanPopupOpeningClosing}"; }
// ------------------------------------------------------------------------
// public usage
// ------------------------------------------------------------------------
public void onOpenPopupAction(javax.faces.event.ActionEvent event)
{
final DemoPageBeanPopupOpeningClosingPopup popupUI = new DemoPageBeanPopupOpeningClosingPopup();
openModalPopup(popupUI,"A nice popup",0,0,new ModalPopup.IModalPopupListener()
{
public void reactOnPopupClosedByUser()
{
closePopup(popupUI);
}
});
popupUI.prepare(new DemoPageBeanPopupOpeningClosingPopup.IListener()
{
public void reactOnClosed()
{
closePopup(popupUI);
}
});
}
// ------------------------------------------------------------------------
// private usage
// ------------------------------------------------------------------------
}
Called PageBean:
Code:
package workplace;
import java.io.Serializable;
import org.eclnt.editor.annotations.CCGenClass;
import org.eclnt.jsfserver.pagebean.PageBean;
@CCGenClass (expressionBase="#{d.DemoPageBeanPopupOpeningClosingPopup}")
public class DemoPageBeanPopupOpeningClosingPopup
extends PageBean
implements Serializable
{
// ------------------------------------------------------------------------
// inner classes
// ------------------------------------------------------------------------
public interface IListener
{
public void reactOnClosed();
}
// ------------------------------------------------------------------------
// members
// ------------------------------------------------------------------------
private IListener m_listener;
// ------------------------------------------------------------------------
// constructors & initialization
// ------------------------------------------------------------------------
public DemoPageBeanPopupOpeningClosingPopup()
{
}
public String getPageName() { return "/workplace/demopagebeanpopupopeningclosingpopup.jsp"; }
public String getRootExpressionUsedInPage() { return "#{d.DemoPageBeanPopupOpeningClosingPopup}"; }
// ------------------------------------------------------------------------
// public usage
// ------------------------------------------------------------------------
public void prepare(IListener listener)
{
m_listener = listener;
}
public void onCloseAction(javax.faces.event.ActionEvent event)
{
if (m_listener != null)
m_listener.reactOnClosed();
}
}
This demo shows the basic code to open - and to close a popup.
In principal it is very simple: a page bean is opened as popup, there is a corresponding openModalPopup-method and a closePopup-method. So it's just an issue to call these methods the right point of time.
The pattern used here is some kind of event-pattern. The page bean that is called as popup sends an event via its IListener-interface that something happened in the bean. In the example the page bean sends an event if the user pressed the Close-button. The calling bean registers for the event and closes the popup.
Regards, Björn