This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Return values from popup window

General questions regarding the development with ProjX.

Return values from popup window

Postby lucdep » Tue May 21, 2019 2:22 pm

Hi,

When I open a popup workscreen I know I kan send parameters through a HashMap; but how can I return values from the popup to the calling workscreen, eg. on closing the popup?

Thanks

Luc
lucdep
 
Posts: 32
Joined: Wed Oct 10, 2018 12:01 pm

Re: Return values from popup window

Postby rjahn » Tue May 21, 2019 6:17 pm

There's no specific API for that. You have different options:

1) put/set the "start" work-screen as parameter
2) open the work-screen and call a method from the new work-screen to "add a listener"
3) iterate all open work-screens, on close, and call specific methods, e.g. implement a IParameterHandler interface in your "start" work-screen
rjahn
 
Posts: 41
Joined: Sun Sep 13, 2009 1:54 pm

Re: Return values from popup window

Postby Support@SIB » Tue May 21, 2019 6:41 pm

This is a simple solution:

In your opener screen, write:

Code: Select all
IWorkScreen wosc = getApplication().openWorkScreen("com.sibvisions.apps.demo.screens.SubWorkScreen", Modality.Modal);
wosc.setParameter("master", this);

eventParameterChanged("closereturn").addListener(new IParameterChangedListener()
{
   public void parameterChanged(WorkScreen pScreen, String pName, Object pOld, Object pNew) throws Throwable
        {
      setTitle("Closed: " + pNew);
   }
});

In your sub screen, write e.g.:

Code: Select all
@Override
public void onClose() throws Throwable
{
   super.onClose();
   
   ((IWorkScreen)getParameter("master")).setParameter("closereturn", "Yuhu");
}


It's also possible to detect the opener automatically:

Code: Select all
@Override
public void onShow() throws Throwable
{
   super.onShow();

   if (!Beans.isDesignTime())
   {
      IComponent[] comps = getApplication().getDesktopPane().getComponents();

      if (comps != null)
      {
         for (IComponent comp : comps)
         {
            if (comp instanceof IFrame)
            {
               if (((IFrame) comp).isActive())
               {
                  IContent cont = getApplication().getContent((IFrame) comp);
                  
                  if (cont != this && cont instanceof IWorkScreen)
                  {
                     // cache opener
                     return;
                  }
               }
            }
         }
      }
   }
}
User avatar
Support@SIB
 
Posts: 288
Joined: Mon Sep 28, 2009 1:56 pm


Return to Development