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: 39
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: 298
Joined: Mon Sep 28, 2009 1:56 pm

Re: Return values from popup window

Postby lucdep » Mon Jun 17, 2019 8:49 am

Hi,

This solutions seems to work in the JavaFX environment, but in Vaadin/HTML, when the popup window is closed the opening screen seems to have lost it's DataBook context and is not showing any record anymore, all fields are gray and ID field is empty. I've tried to store selection before opening the popup and restoring on closing the popup, but this doesn't help.

What could be going wrong in VAADIN?

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

Re: Return values from popup window

Postby Support@SIB » Mon Jun 17, 2019 1:54 pm

The above solution works in our environment and our screens. Not sure what you code does, but to try to find the problem, we need an example.
User avatar
Support@SIB
 
Posts: 298
Joined: Mon Sep 28, 2009 1:56 pm

Re: Return values from popup window

Postby lucdep » Tue Jun 18, 2019 9:47 am

Hi,

Here the code I have used:
The opener screen is the workscreen for the table Book, the edit button opens a popup Author workscreen on the table Author. When the combobox Auth_ID is null a new Author is created in the popup, after which the new Auth_ID must be returned to the master Book workscreen and inserted in the field Auth_ID. When Auth_ID is not null when clicking the edit button, the popup goes in edit mode for the selected Author.

In VAADIN the popup returns to a blank Book record, in JavaFX the original Book record remains.

This is de code for the edit button in the opener (master) Book workscreen:
Code: Select all
public void doButtoneditauthor(UIActionEvent pEvent) throws Throwable
   {
      rdbBook.saveAllRows();
      HashMap<String, Object> htParam = new HashMap<String, Object>();
      if (!Logical.equals(rdbBook.getValue("AUTH_ID"), (Object)null))
      {
         htParam.put("lookupid", rdbBook.getValue("AUTH_ID"));
      }
      else
      {
         htParam.put("lookupid", (Object)null);
      }
      IWorkScreen wosc = getApplication().openWorkScreen("be.moonfox.apps.bookshelf.screens.AuthorEditWorkScreen", htParam);
      wosc.setParameter("master", this);
      eventParameterChanged("closereturn").addListener(new IParameterChangedListener()
      {
         public void parameterChanged(WorkScreen pScreen, String pName, Object pOld, Object pNew) throws Throwable
         {
            rdbBook.setValue("AUTH_ID", pNew);
            rdbBook.saveAllRows();
         }
      });
   }


In the popup Author workscreen I have following code:

Code: Select all
public void onActivate() throws Throwable
   {
      Object pID = getParameter("lookupid");
      if (!Logical.equals(pID, (Object)null))
      {
         labelHeader.setText("Edit author");
         rdbAuthor.setFilter(new Equals("ID", pID));
      }
      else
      {
         deleteButton.setEnabled(false);
         labelHeader.setText("New author");
         rdbAuthor.insert(false);
      }
   }


        @Override
   public void onClose() throws Throwable
   {
      super.onClose();
      ((IWorkScreen)getParameter("master")).setParameter("closereturn", rdbAuthor.getValue("ID"));
   }
lucdep
 
Posts: 39
Joined: Wed Oct 10, 2018 12:01 pm

Re: Return values from popup window

Postby Support@SIB » Tue Jun 18, 2019 1:55 pm

We'll check this.
User avatar
Support@SIB
 
Posts: 298
Joined: Mon Sep 28, 2009 1:56 pm

Re: Return values from popup window

Postby Support@SIB » Fri Jun 21, 2019 10:28 am

Your opened work-screen is not modal, so in desktop mode we use MDI and the master workscreen remains open. In web UI, we use SDI and the "popup" replaces the master screen.

It's unclear how your screen works, because if you open the "popup", the master will be closed and you don't open the master-screen in your code?

In our example code, we use: Modality.Modal

Your code doesn't use this and that's the big difference!


We have different options for you:

* Test your code with Legacy application mode (see web settings) - only for test purposes.
* Use modality as we do in our example code
* Use MorphPanel instead of your solution.

The MorphPanel is able to show a table and if you click on a record, e.g. a popup will be opened or the detail view will be shown instead of the table...

The web application also has different modes where it doesn't close the screens (only hides/shows), but this needs commercial support.
User avatar
Support@SIB
 
Posts: 298
Joined: Mon Sep 28, 2009 1:56 pm

Re: Return values from popup window

Postby lucdep » Mon Jun 24, 2019 11:18 am

Hi,

Back/Forward navigation in Web Application Settings was the problem. After unchecking the boxes, the code works in VAADIN as well.

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

Re: Return values from popup window

Postby Support@SIB » Mon Jun 24, 2019 12:36 pm

Back/Forward is the browser navigation. This shouldn't change your screen handling.
User avatar
Support@SIB
 
Posts: 298
Joined: Mon Sep 28, 2009 1:56 pm


Return to Development