[jboss-cvs] jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node ...

Christian Bauer christian.bauer at jboss.com
Tue Feb 27 08:21:45 EST 2007


  User: cbauer  
  Date: 07/02/27 08:21:45

  Modified:    examples/wiki/src/org/jboss/seam/wiki/core/node      
                        DocumentHome.java Menu.java Document.java
                        DirectoryHome.java NodeBrowser.java Directory.java
  Log:
  Implemented conversational navigation (not perfect, open JIRA issues)
  
  Revision  Changes    Path
  1.5       +25 -1     jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/DocumentHome.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DocumentHome.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/DocumentHome.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- DocumentHome.java	26 Feb 2007 20:59:48 -0000	1.4
  +++ DocumentHome.java	27 Feb 2007 13:21:45 -0000	1.5
  @@ -9,6 +9,7 @@
   import org.jboss.seam.wiki.core.dao.NodeDAO;
   import org.jboss.seam.core.FacesMessages;
   import org.jboss.seam.core.Events;
  +import org.jboss.seam.core.Conversation;
   import org.jboss.seam.ScopeType;
   
   import java.util.List;
  @@ -29,6 +30,9 @@
       @In
       private FacesMessages facesMessages;
   
  +    @In(create = true)
  +    private NodeBrowser browser;
  +
       @In(create=true)
       private WikiLinkResolver wikiLinkResolver;
   
  @@ -48,7 +52,7 @@
           }
       }
   
  -    @Begin(flushMode = FlushModeType.MANUAL, join = true)
  +    @Override
       @Transactional
       public void create() {
           super.create();
  @@ -58,6 +62,24 @@
           parentDirectory = getEntityManager().find(Directory.class, parentDirId);
       }
   
  +    // TODO: Typical exit method to get out of a root or nested conversation, JBSEAM-906
  +    public void exitConversation(Boolean endBeforeRedirect) {
  +        Conversation currentConversation = Conversation.instance();
  +        if (currentConversation.isNested()) {
  +            // End this nested conversation and return to last rendered view-id of parent
  +            currentConversation.endAndRedirect(endBeforeRedirect);
  +        } else {
  +            // End this root conversation
  +            currentConversation.end();
  +            // Return to the view-id that was captured when this conversation started
  +            if (endBeforeRedirect)
  +                browser.redirectToLastBrowsedPage();
  +            else
  +                browser.redirectToLastBrowsedPage();
  +        }
  +    }
  +
  +    @Override
       public String persist() {
   
           // Validate
  @@ -79,6 +101,7 @@
       }
   
   
  +    @Override
       public String update() {
   
           // Validate
  @@ -95,6 +118,7 @@
           return super.update();
       }
   
  +    @Override
       public String remove() {
   
           // Unlink the document from its directory
  
  
  
  1.4       +0 -1      jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/Menu.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Menu.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/Menu.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- Menu.java	21 Feb 2007 16:24:09 -0000	1.3
  +++ Menu.java	27 Feb 2007 13:21:45 -0000	1.4
  @@ -4,7 +4,6 @@
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.wiki.core.links.WikiLinkResolver;
   
  -import javax.persistence.EntityManager;
   import java.util.List;
   import java.util.ArrayList;
   
  
  
  
  1.2       +1 -1      jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/Document.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Document.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/Document.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- Document.java	1 Feb 2007 07:08:26 -0000	1.1
  +++ Document.java	27 Feb 2007 13:21:45 -0000	1.2
  @@ -12,7 +12,7 @@
       @Length(min = 1, max = 32768)
       private String content;
   
  -    public Document() { super(); }
  +    public Document() { super("New Document"); }
   
       public Document(String name) {
           super(name);
  
  
  
  1.5       +35 -10    jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/DirectoryHome.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DirectoryHome.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/DirectoryHome.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- DirectoryHome.java	26 Feb 2007 20:59:48 -0000	1.4
  +++ DirectoryHome.java	27 Feb 2007 13:21:45 -0000	1.5
  @@ -10,6 +10,7 @@
   import org.jboss.seam.wiki.core.dao.NodeDAO;
   import org.jboss.seam.core.FacesMessages;
   import org.jboss.seam.core.Events;
  +import org.jboss.seam.core.Conversation;
   
   import javax.persistence.Query;
   import java.util.List;
  @@ -33,6 +34,9 @@
       @In
       private FacesMessages facesMessages;
   
  +    @In(create = true)
  +    private NodeBrowser browser;
  +
       @In(create=true)
       private NodeDAO nodeDAO;
   
  @@ -47,7 +51,6 @@
       }
   
       @Override
  -    @Begin(flushMode = FlushModeType.MANUAL)
       @Transactional
       public void create() {
           super.create();
  @@ -65,6 +68,24 @@
           refreshChildNodes();
       }
   
  +    // TODO: Typical exit method to get out of a root or nested conversation, JBSEAM-906
  +    public void exitConversation(Boolean endBeforeRedirect) {
  +        Conversation currentConversation = Conversation.instance();
  +        if (currentConversation.isNested()) {
  +            // End this nested conversation and return to last rendered view-id of parent
  +            currentConversation.endAndRedirect(endBeforeRedirect);
  +        } else {
  +            // End this root conversation
  +            currentConversation.end();
  +            // Return to the view-id that was captured when this conversation started
  +            if (endBeforeRedirect)
  +                browser.redirectToLastBrowsedPage();
  +            else
  +                browser.redirectToLastBrowsedPage();
  +        }
  +    }
  +
  +    @Override
       public String persist() {
   
           // Validate
  @@ -96,6 +117,7 @@
       }
   
   
  +    @Override
       public String update() {
   
           // Validate
  @@ -107,6 +129,7 @@
           return super.update();
       }
   
  +    @Override
       public String remove() {
   
           // Unlink the document from its parent directory
  @@ -120,28 +143,30 @@
           return super.remove();
       }
   
  -    public Directory getParentDirectory() {
  -        return parentDirectory;
  -    }
  -
  -    public void setParentDirectory(Directory parentDirectory) {
  -        this.parentDirectory = parentDirectory;
  -    }
  -
  -
  +    @Override
       public String getUpdatedMessage() {
           return super.getUpdatedMessage() + ": '" + getInstance().getName() + "'";
       }
   
   
  +    @Override
       public String getDeletedMessage() {
           return super.getDeletedMessage() + ": '" + getInstance().getName() + "'";
       }
   
  +    @Override
       public String getCreatedMessage() {
           return super.getCreatedMessage() + ": '" + getInstance().getName() + "'";
       }
   
  +    public Directory getParentDirectory() {
  +        return parentDirectory;
  +    }
  +
  +    public void setParentDirectory(Directory parentDirectory) {
  +        this.parentDirectory = parentDirectory;
  +    }
  +
       @DataModel
       List<Node> childNodes;
   
  
  
  
  1.4       +6 -2      jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/NodeBrowser.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NodeBrowser.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/NodeBrowser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- NodeBrowser.java	21 Feb 2007 16:24:09 -0000	1.3
  +++ NodeBrowser.java	27 Feb 2007 13:21:45 -0000	1.4
  @@ -2,6 +2,7 @@
   
   import org.jboss.seam.annotations.*;
   import org.jboss.seam.ScopeType;
  +import org.jboss.seam.Component;
   import org.jboss.seam.wiki.core.dao.NodeDAO;
   
   import java.util.*;
  @@ -71,6 +72,8 @@
        * a prepare()ed page that was in a long-running conversation (temporary doesn't matter) or that was last
        * called with an action (that action would probably send us straight back into the conversation we are trying
        * to redirect out of).
  +     *
  +     * TODO: These methods and the whole navigation strategy can be simplified with http://jira.jboss.com/jira/browse/JBSEAM-906
        */
       public void redirectToLastBrowsedPage() {
   
  @@ -98,7 +101,6 @@
           redirect.returnToCapturedView();
       }
   
  -
       // Just a convenience method for recursive calling
       protected void addDirectoryToPath(List<Node> path, Node directory) {
           path.add(directory);
  @@ -106,12 +108,13 @@
               addDirectoryToPath(path, directory.getParent());
       }
   
  +
       @Transactional
       public String prepare() {
   
           // Store the view-id that called this method (as a page action) for return (exit of a later conversation)
           redirect.captureCurrentRequest();
  -        // TODO: I'm not using captureCurrentView() because it starts a conversation
  +        // TODO: I'm not using captureCurrentView() because it starts a conversation (and it doesn't capture all request parameters)
   
           // Have we been called with a nodeId request parameter, could be document or directory
           if (nodeId != null && !nodeId.equals(wikiRoot.getId())) {
  @@ -160,6 +163,7 @@
           nodeId = currentDocument != null ? currentDocument.getId() : currentDirectory.getId();
   
           // Prepare directory path for breadcrumb
  +        currentDirectoryPath.clear();
           addDirectoryToPath(currentDirectoryPath, currentDirectory);
           Collections.reverse(currentDirectoryPath);
   
  
  
  
  1.3       +1 -1      jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/Directory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Directory.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/org/jboss/seam/wiki/core/node/Directory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- Directory.java	16 Feb 2007 16:26:44 -0000	1.2
  +++ Directory.java	27 Feb 2007 13:21:45 -0000	1.3
  @@ -11,7 +11,7 @@
       @JoinColumn(name = "DEFAULT_DOCUMENT_ID", nullable = true)
       private Document defaultDocument;
   
  -    public Directory() { super(); }
  +    public Directory() { super("New Directory"); }
   
       public Directory(String name) {
           super(name);
  
  
  



More information about the jboss-cvs-commits mailing list