You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/01/24 17:31:59 UTC

svn commit: r1235336 - in /myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main: java/org/apache/myfaces/tobago/example/demo/Navigation.java webapp/footer.xhtml

Author: lofwyr
Date: Tue Jan 24 16:31:58 2012
New Revision: 1235336

URL: http://svn.apache.org/viewvc?rev=1235336&view=rev
Log:
demo: better feedback in the navi-menu when using next- and previous-buttons

Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java?rev=1235336&r1=1235335&r2=1235336&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java Tue Jan 24 16:31:58 2012
@@ -129,7 +129,7 @@ public class Navigation implements Seria
     while (enumeration.hasMoreElements()) {
       Node node = ((Node) enumeration.nextElement());
       if (node.getOutcome() != null && viewId.contains(node.getOutcome())) {
-        currentNode = node;
+        gotoNode(node);
         break;
       }
     }
@@ -144,15 +144,13 @@ public class Navigation implements Seria
   }
 
   public String gotoFirst() {
-    currentNode = tree.getNextNode();
-    return currentNode.getOutcome();
+    return gotoNode(tree.getNextNode());
   }
 
   public String gotoPrevious() {
     final Node previousNode = currentNode.getPreviousNode();
     if (previousNode != null) {
-      currentNode = previousNode;
-      return currentNode.getOutcome();
+      return gotoNode(previousNode);
     } else {
       LOG.warn("Strange navigation behavior");
       return null;
@@ -162,14 +160,22 @@ public class Navigation implements Seria
   public String gotoNext() {
     final Node nextNode = currentNode.getNextNode();
     if (nextNode != null) {
-      currentNode = nextNode;
-      return currentNode.getOutcome();
+      return gotoNode(nextNode);
     } else {
       LOG.warn("Strange navigation behavior");
       return null;
     }
   }
 
+  protected String gotoNode(Node node) {
+    currentNode.setMarked(false);
+    currentNode = node;
+    currentNode.setMarked(true);
+    currentNode.setExpanded(true);
+    LOG.info("Navigate to '" + currentNode.outcome + "'");
+    return currentNode.getOutcome();
+  }
+
   public boolean isFirst() {
     final Node previousNode = currentNode.getPreviousNode();
     return previousNode == null || previousNode.isRoot();
@@ -233,10 +239,7 @@ public class Navigation implements Seria
     }
 
     public String action() {
-      LOG.info("Navigate to '" + outcome + "'");
-      currentNode = this;
-      expanded = true;
-      return outcome;
+      return gotoNode(this);
     }
 
     public String getMarkup() {

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml?rev=1235336&r1=1235335&r2=1235336&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/footer.xhtml Tue Jan 24 16:31:58 2012
@@ -32,13 +32,13 @@
       <tc:gridLayoutConstraint columnSpan="6"/>
     </tc:separator>
 
-    <tc:button immediate="true"
+    <tc:button immediate="true" id="previous"
                image="image/prev.gif"
                action="#{navigation.gotoPrevious}"
                disabled="#{navigation.first}"
                label="#{overviewBundle.footer_previous}"/>
 
-    <tc:button immediate="true"
+    <tc:button immediate="true" id="next"
                image="image/next.gif"
                action="#{navigation.gotoNext}"
                disabled="#{navigation.last}"