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 2014/07/09 11:07:51 UTC

svn commit: r1609060 - in /myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main: java/org/apache/myfaces/tobago/example/demo/ webapp/WEB-INF/

Author: lofwyr
Date: Wed Jul  9 09:07:50 2014
New Revision: 1609060

URL: http://svn.apache.org/r1609060
Log:
Demo: get navigation state working...

Removed:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationEvent.java
Modified:
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationNode.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationState.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationNode.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationNode.java?rev=1609060&r1=1609059&r2=1609060&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationNode.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationNode.java Wed Jul  9 09:07:50 2014
@@ -64,12 +64,6 @@ public class NavigationNode extends Defa
     return outcome;
   }
 
-/* TODO
- XXX  public String getMarkup() {
-    return currentNode == this ? "marked" : null;
-  }
-*/
-
   public void evaluateTreePath() {
     treePath = new TreePath(this);
   }

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationState.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationState.java?rev=1609060&r1=1609059&r2=1609060&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationState.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationState.java Wed Jul  9 09:07:50 2014
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.annotation.PostConstruct;
+import javax.enterprise.event.Observes;
 import javax.faces.context.FacesContext;
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -94,7 +95,7 @@ public class NavigationState implements 
     }
   }
 
-  public String gotoNode(final NavigationNode node) {
+  public String gotoNode(@Observes final NavigationNode node) {
     if (node == null) {
       return gotoFirst();
     } else {

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java?rev=1609060&r1=1609059&r2=1609060&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/NavigationTree.java Wed Jul  9 09:07:50 2014
@@ -23,6 +23,7 @@ import org.apache.myfaces.tobago.example
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.PostConstruct;
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.event.Event;
 import javax.faces.context.ExternalContext;
@@ -50,23 +51,27 @@ public class NavigationTree implements S
 
   private static final Logger LOG = LoggerFactory.getLogger(NavigationTree.class);
 
-  private NavigationNode tree;
+  private NavigationNode root;
 
   @Inject
-  private Event<NavigationEvent> events;
+  private Event<NavigationNode> events;
 
-  public NavigationTree() {
-      final ServletContext servletContext
-          = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
-      final List<String> list = locateResourcesInWar(servletContext, "/content", new ArrayList<String>());
-      init(list);
-  }
+  /**
+   * todo: Seems not working with Java EE 6, needs Java EE 7?
+   */
+//  @Inject
+//  private ServletContext servletContext;
 
-  protected NavigationTree(final List<String> list) {
-    init(list);
+  public NavigationTree() {
+    LOG.info("<init>");
   }
 
-  protected void init(final List<String> list) {
+  @PostConstruct
+  private void postConstruct() {
+    // todo: refactor with Java EE 7
+    final ServletContext servletContext;
+    servletContext = ((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext());
+    final List<String> list = locateResourcesInWar(servletContext, "/content", new ArrayList<String>());
     list.add("/content/root-dummy.xhtml"); // helps to build the tree, this is not an existing file
     final List<NavigationNode> nodes = new ArrayList<NavigationNode>();
     for (final String path : list) {
@@ -80,7 +85,7 @@ public class NavigationTree implements S
     Collections.sort(nodes);
 
     // after sorting the first node is the root node.
-    tree = nodes.get(0);
+    root = nodes.get(0);
 
     final Map<String, NavigationNode> map = new HashMap<String, NavigationNode>();
 //    map.put(tree.getBranch(), tree);
@@ -133,7 +138,7 @@ public class NavigationTree implements S
     if (viewId.endsWith(".jspx")) {
       viewId = viewId.substring(0, viewId.lastIndexOf(".jspx")) + ".xhtml";
     }
-    final Enumeration enumeration = tree.depthFirstEnumeration();
+    final Enumeration enumeration = root.depthFirstEnumeration();
     while (enumeration.hasMoreElements()) {
       final NavigationNode node = ((NavigationNode) enumeration.nextElement());
       if (node.getOutcome() != null && viewId.contains(node.getOutcome())) {
@@ -144,11 +149,11 @@ public class NavigationTree implements S
   }
 
   public NavigationNode getTree() {
-    return tree;
+    return root;
   }
 
   public void gotoNode(final NavigationNode node) {
-    events.fire(new NavigationEvent(node));
+    events.fire(node);
   }
 
   public String viewSource() {

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml?rev=1609060&r1=1609059&r2=1609060&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml Wed Jul  9 09:07:50 2014
@@ -134,7 +134,6 @@
   <servlet>
     <servlet-name>FacesServlet</servlet-name>
     <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
-    <load-on-startup>3</load-on-startup>
   </servlet>
 
   <servlet-mapping>