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 2007/01/26 17:26:08 UTC
svn commit: r500277 - in /myfaces/tobago/trunk/example/demo/src/main:
java/org/apache/myfaces/tobago/example/demo/
java/org/apache/myfaces/tobago/example/demo/overview/ webapp/
webapp/WEB-INF/ webapp/WEB-INF/tags/layout/
Author: lofwyr
Date: Fri Jan 26 08:26:07 2007
New Revision: 500277
URL: http://svn.apache.org/viewvc?view=rev&rev=500277
Log:
implement the Next/Previous Button with the "Navigation.java" Class. The old PresentationController and SychronizeNavigationPhaseListener are no longer needed.
Added:
myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.jsp
- copied, changed from r500269, myfaces/tobago/trunk/example/demo/src/main/webapp/navigator.jsp
Removed:
myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/PresentationController.java
myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/SynchronizeNavigationPhaseListener.java
myfaces/tobago/trunk/example/demo/src/main/webapp/navigator.jsp
Modified:
myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java
myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml
myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/tags/layout/overview.tag
myfaces/tobago/trunk/example/demo/src/main/webapp/footer.jsp
myfaces/tobago/trunk/example/demo/src/main/webapp/header.jsp
Modified: myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java?view=diff&rev=500277&r1=500276&r2=500277
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java (original)
+++ myfaces/tobago/trunk/example/demo/src/main/java/org/apache/myfaces/tobago/example/demo/Navigation.java Fri Jan 26 08:26:07 2007
@@ -19,9 +19,18 @@
import org.apache.myfaces.tobago.model.TreeState;
import org.apache.myfaces.tobago.context.ResourceManagerUtil;
+import org.apache.myfaces.tobago.example.demo.jsp.JspFormatter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.faces.context.FacesContext;
+import javax.faces.context.ExternalContext;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.IOException;
/**
* User: lofwyr
@@ -30,6 +39,8 @@
*/
public class Navigation {
+ private static final Log LOG = LogFactory.getLog(Navigation.class);
+
private DefaultMutableTreeNode tree;
private TreeState state;
@@ -61,6 +72,7 @@
state = new TreeState();
state.expand(tree, 2);
+ state.setMarker(overview);
}
public String navigate() {
@@ -82,6 +94,58 @@
public void setState(TreeState state) {
this.state = state;
+ }
+
+ public String gotoFirst() {
+ DefaultMutableTreeNode first = tree.getNextNode();
+ state.setMarker(first);
+ return ((Node)first.getUserObject()).getOutcome();
+ }
+
+ public String gotoPrevious() {
+ DefaultMutableTreeNode previousNode = state.getMarker().getPreviousNode();
+ if (previousNode != null) {
+ state.setMarker(previousNode);
+ return ((Node)previousNode.getUserObject()).getOutcome();
+ }
+ return null;
+ }
+
+ public String gotoNext() {
+ DefaultMutableTreeNode nextNode = state.getMarker().getNextNode();
+ if (nextNode != null) {
+ state.setMarker(nextNode);
+ return ((Node)nextNode.getUserObject()).getOutcome();
+ }
+ return null;
+ }
+
+ public boolean isFirst() {
+ return state.getMarker().getPreviousNode().isRoot();
+ }
+
+ public boolean isLast() {
+ return state.getMarker().getNextNode() == null;
+ }
+
+ public String viewSource() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ String viewId = facesContext.getViewRoot().getViewId();
+ HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
+ response.setContentType("text/html;charset=UTF-8");
+
+ try {
+ InputStream resourceAsStream = externalContext.getResourceAsStream(viewId);
+ InputStreamReader reader = new InputStreamReader(resourceAsStream);
+ JspFormatter.writeJsp(reader, new PrintWriter(response.getOutputStream()));
+ } catch (IOException e) {
+ LOG.error("", e);
+ return "error";
+ }
+
+ facesContext.responseComplete();
+ return null;
}
public static class Node {
Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml?view=diff&rev=500277&r1=500276&r2=500277
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/faces-config.xml Fri Jan 26 08:26:07 2007
@@ -56,9 +56,6 @@
<lifecycle>
<phase-listener>
- org.apache.myfaces.tobago.example.demo.overview.SynchronizeNavigationPhaseListener
- </phase-listener>
- <phase-listener>
org.apache.myfaces.tobago.util.DebugPhaseListener
</phase-listener>
</lifecycle>
@@ -71,29 +68,6 @@
</managed-bean>
<!-- overview -->
-
- <managed-bean>
- <managed-bean-name>overviewNavigation</managed-bean-name>
- <managed-bean-class>org.apache.myfaces.tobago.example.demo.overview.PresentationController</managed-bean-class>
- <managed-bean-scope>session</managed-bean-scope>
- <managed-property>
- <property-name>pages</property-name>
- <list-entries>
- <value>overview/intro</value>
- <value>overview/basicControls</value>
- <value>overview/sheetControl</value>
- <value>overview/treeControl</value>
- <value>overview/tabControl</value>
- <value>overview/toolbar</value>
- <value>overview/validation</value>
- <value>overview/form</value>
- <value>overview/themes</value>
- <value>overview/browser</value>
- <value>overview/locale</value>
- <value>overview/layout</value>
- </list-entries>
- </managed-property>
- </managed-bean>
<managed-bean>
<managed-bean-name>overviewController</managed-bean-name>
Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/tags/layout/overview.tag
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/tags/layout/overview.tag?view=diff&rev=500277&r1=500276&r2=500277
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/tags/layout/overview.tag (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/WEB-INF/tags/layout/overview.tag Fri Jan 26 08:26:07 2007
@@ -38,7 +38,7 @@
</tc:cell>
<tc:cell spanY="2" >
- <jsp:include page="/navigator.jsp"/>
+ <jsp:include page="/navigation.jsp"/>
</tc:cell>
<tc:cell>
Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/footer.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/footer.jsp?view=diff&rev=500277&r1=500276&r2=500277
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/footer.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/footer.jsp Fri Jan 26 08:26:07 2007
@@ -29,20 +29,20 @@
</tc:cell>
<%-- fixme: next and previous button are not working in them moment (rendered="false") --%>
- <tc:button immediate="true" rendered="false"
+ <tc:button immediate="true"
image="image/prev.gif"
- action="#{overviewNavigation.gotoPrevious}"
- disabled="#{overviewNavigation.first}"
+ action="#{navigation.gotoPrevious}"
+ disabled="#{navigation.first}"
label="#{overviewBundle.footer_previous}"/>
<%-- fixme: next and previous button are not working in them moment (rendered="false") --%>
- <tc:button immediate="true" rendered="false"
+ <tc:button immediate="true"
image="image/next.gif"
- action="#{overviewNavigation.gotoNext}"
- disabled="#{overviewNavigation.last}"
+ action="#{navigation.gotoNext}"
+ disabled="#{navigation.last}"
label="#{overviewBundle.footer_next}"/>
- <tc:button action="#{overviewNavigation.viewSource}"
+ <tc:button action="#{navigation.viewSource}"
immediate="true" label="#{overviewBundle.footer_viewSource}"
target="Source Viewer" transition="false"/>
Modified: myfaces/tobago/trunk/example/demo/src/main/webapp/header.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/header.jsp?view=diff&rev=500277&r1=500276&r2=500277
==============================================================================
--- myfaces/tobago/trunk/example/demo/src/main/webapp/header.jsp (original)
+++ myfaces/tobago/trunk/example/demo/src/main/webapp/header.jsp Fri Jan 26 08:26:07 2007
@@ -23,9 +23,7 @@
<tc:gridLayout columns="150px;*;200px" />
</f:facet>
- <tc:link action="overview/intro" immediate="true"
- actionListener="#{overviewNavigation.navigate}"
- image="image/tobago_head.gif" />
+ <tc:link action="#{navigation.gotoFirst}" immediate="true" image="image/tobago_head.gif" />
<tc:cell />
Copied: myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.jsp (from r500269, myfaces/tobago/trunk/example/demo/src/main/webapp/navigator.jsp)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.jsp?view=diff&rev=500277&p1=myfaces/tobago/trunk/example/demo/src/main/webapp/navigator.jsp&r1=500269&p2=myfaces/tobago/trunk/example/demo/src/main/webapp/navigation.jsp&r2=500277
==============================================================================
(empty)