Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-1346

MessageBox inside MVVM command method blocks NotifyChange updates


      I have a MVVM class method handling a user action to delete an entry. The code inside the MVVM class method displays a messagebox to prompt a confirmation from the user.

      The use of this messagebox seems to interfere with the 'NotifyChange' related updates.


      { "rawtypes", "unchecked" })
      public void deleteSelected() {
      if (getSelectedLocation() != null) {
      try {
      if (geoLocationManager.isUsed(getSelectedLocation().getData().getID())) { Messagebox.show("This Location cannot be deleted as it is being used by requirements or available resources","Delete", Messagebox.OK, Messagebox.INFORMATION); }
      else {
      Messagebox.show("Confirm deletion of ["+getSelectedLocation().getData().getTitle()+"]?", "Confirm Dialog", Messagebox.OK | Messagebox.CANCEL,
      Messagebox.QUESTION, new org.zkoss.zk.ui.event.EventListener() {
      public void onEvent(Event evt) throws InterruptedException {
      if (evt.getName().equals("onOK")) {
      try { geoLocationManager.delete(getSelectedLocation().getData().getID()); buildModel(); setSelectedLocation(null); BindUtils.postNotifyChange(DataAreaIDs.QUEUE_NAME,DataAreaIDs.QUEUE_SCOPE,this,"showEdit"); BindUtils.postNotifyChange(DataAreaIDs.QUEUE_NAME,DataAreaIDs.QUEUE_SCOPE,this,"locationModel"); }
      catch (PersistenceException e) { showErrorView(getCommand(), e); }
      catch (UnknownGeoLocationException e) {
      catch (PersistenceException e) { showErrorView(getCommand(), e); } }

      I've even tried forcing the refresh using the 'bindUtils' calls, but the view remains unaffected.

      If I take out the 'Messagebox.show' code, like:

      @SuppressWarnings({ "rawtypes", "unchecked" }



      public void deleteSelected() {

      { geoLocationManager.delete(getSelectedLocation().getData().getID()); buildModel(); setSelectedLocation(null); }

      catch (UnknownGeoLocationException e)

      { // TODO Auto-generated catch block e.printStackTrace(); }
      catch (PersistenceException e) { // TODO Auto-generated catch block e.printStackTrace(); }

      ... the @NotifyChange updates refresh the page correctly.

      A bug I presume

            Unassigned Unassigned
            davout davout
            2 Vote for this issue
            2 Start watching this issue