Announcement Announcement Module
Collapse
No announcement yet.
refreshing the view Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • refreshing the view

    How can I notify a view that it needs to be refreshed. I am calling Application.instance().getAciveWindow().getPage(). showView("myView") it constructs the view object on the first call, is there a way for a view to recognise that Application.instance().getAciveWindow().getPage(). showView("myView") has been called when view object is already created? Or should I implement a view as ActionCommandExecutor?
    Thanks.

  • #2
    On a related note, I'm beginning to run into a need to rebuild a currently displayed view. In other words, destroy the current instance of the view and use the view descriptor to rebuild the view. This could also be considered a form of "refresh". Anyone else see a need for such a thing?

    - Andy

    Comment


    • #3
      RefreshView

      We want the latest data to be shown in a view everytime the user calls the view.

      In our typical View (extends AbstractView implements
      ApplicationListener) we have a

      Code:
          private RefreshViewCommand refreshViewCommand = new RefreshViewCommand();
      Then we implement a method to be called when the View gained foucs
      Code:
          public void componentFocusGained() {
              refreshViewCommand.doExecuteCommand();
          }
      and finally a sample RefreshViewCommand implementation to "refresh" the view (write your own implementation here):
      Code:
          private class RefreshViewCommand extends ActionCommand {
              public RefreshViewCommand() {
                  super("refreshViewCommand");
              }
              protected void doExecuteCommand() {
                  if (psrTree != null) {
                      DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode)
                                                        psrTreeModel.getRoot();
      //delete allChilcred
                      rootNode.removeAllChildren();
      //getSomeData from the ORM subsystem
                      Collection pendingSR = getViewData();
      //render the tree component with refreshed data
                      for (Iterator i = pendingSR.iterator(); i.hasNext(); ) {
                          rootNode.add(new DefaultMutableTreeNode(i.next()));
                      }
                      psrTreeModel.nodeStructureChanged(rootNode);
      
                  }
              }
      Within the view, if UseCase requires the user to refresh the view manually, we build a JPopupMenu with a call to the refreshViewCommand

      Comment

      Working...
      X