Author: craigmcc
Date: Thu Oct 21 13:59:35 2004
New Revision: 55262

Added:
   
struts/trunk/struts-faces/example1-webapp/src/java/org/apache/struts/webapp/example/IndexBacking.java
   struts/trunk/struts-faces/example1-webapp/src/web/welcome.jsp
Modified:
   
struts/trunk/struts-faces/example1-webapp/src/java/org/apache/struts/webapp/example/AbstractBacking.java
   struts/trunk/struts-faces/example1-webapp/src/web/WEB-INF/faces-config.xml
   struts/trunk/struts-faces/example1-webapp/src/web/WEB-INF/web.xml
   struts/trunk/struts-faces/example1-webapp/src/web/index.jsp
   struts/trunk/struts-faces/example1-webapp/src/web/mainMenu.jsp
Log:
Convert the index.jsp page to use JSF components, like all the rest.  As a
side effect, this makes the "Register" link work correctly.


Modified: 
struts/trunk/struts-faces/example1-webapp/src/java/org/apache/struts/webapp/example/AbstractBacking.java
==============================================================================
--- 
struts/trunk/struts-faces/example1-webapp/src/java/org/apache/struts/webapp/example/AbstractBacking.java
    (original)
+++ 
struts/trunk/struts-faces/example1-webapp/src/java/org/apache/struts/webapp/example/AbstractBacking.java
    Thu Oct 21 13:59:35 2004
@@ -85,6 +85,19 @@
 
 
     /**
+     * <p>Return the context relative base URL for the "logon"
+     * action.</p>
+     *
+     * @param context <code>FacesContext</code> for the current request
+     */
+    protected StringBuffer logon(FacesContext context) {
+
+        return (action(context, "/logon"));
+
+    }
+
+
+    /**
      * <p>Return the context relative base URL for the "edit registration"
      * action.</p>
      *

Added: 
struts/trunk/struts-faces/example1-webapp/src/java/org/apache/struts/webapp/example/IndexBacking.java
==============================================================================
--- (empty file)
+++ 
struts/trunk/struts-faces/example1-webapp/src/java/org/apache/struts/webapp/example/IndexBacking.java
       Thu Oct 21 13:59:35 2004
@@ -0,0 +1,74 @@
+/*
+ * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.struts.webapp.example;
+
+
+import java.io.IOException;
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+/**
+ * <p>Backing bean for the <code>index.jsp</code> page.</p>
+ */
+
+public class IndexBacking extends AbstractBacking {
+
+
+    // -------------------------------------------------------- Static Variables
+
+
+    private static final Log log = LogFactory.getLog(IndexBacking.class);
+
+
+    // ----------------------------------------------------------------- Actions
+
+
+    /**
+     * <p>Forward to the <em>Create Registration</em> action.</p>
+     */
+    public String create() {
+
+        if (log.isDebugEnabled()) {
+            log.debug("create()");
+        }
+        FacesContext context = FacesContext.getCurrentInstance();
+        StringBuffer sb = registration(context);
+        sb.append("?action=Create");
+        forward(context, sb.toString());
+        return (null);
+
+    }
+
+
+    /**
+     * <p>Forward to the <em>Logon</em> page.</p>
+     */
+    public String logon() {
+
+        if (log.isDebugEnabled()) {
+            log.debug("logon()");
+        }
+        return "logon";
+
+    }
+
+
+}

Modified: struts/trunk/struts-faces/example1-webapp/src/web/WEB-INF/faces-config.xml
==============================================================================
--- struts/trunk/struts-faces/example1-webapp/src/web/WEB-INF/faces-config.xml  
(original)
+++ struts/trunk/struts-faces/example1-webapp/src/web/WEB-INF/faces-config.xml  Thu 
Oct 21 13:59:35 2004
@@ -28,6 +28,16 @@
 <faces-config>
 
 
+  <!-- Backing Bean for index.jsp -->
+  <managed-bean>
+    <managed-bean-name>indexBacking</managed-bean-name>
+    <managed-bean-class>
+      org.apache.struts.webapp.example.IndexBacking
+    </managed-bean-class>
+    <managed-bean-scope>request</managed-bean-scope>
+  </managed-bean>
+
+
   <!-- Backing Bean for mainMenu.jsp -->
   <managed-bean>
     <managed-bean-name>mainMenuBacking</managed-bean-name>
@@ -47,5 +57,13 @@
     <managed-bean-scope>request</managed-bean-scope>
   </managed-bean>
 
+  <!-- Navigation Rules for index.jsp -->
+  <navigation-rule>
+    <from-view-id>/index.jsp</from-view-id>
+    <navigation-case>
+      <from-outcome>logon</from-outcome>
+      <to-view-id>/logon.jsp</to-view-id>
+    </navigation-case>
+  </navigation-rule>
 
 </faces-config>

Modified: struts/trunk/struts-faces/example1-webapp/src/web/WEB-INF/web.xml
==============================================================================
--- struts/trunk/struts-faces/example1-webapp/src/web/WEB-INF/web.xml   (original)
+++ struts/trunk/struts-faces/example1-webapp/src/web/WEB-INF/web.xml   Thu Oct 21 
13:59:35 2004
@@ -85,7 +85,7 @@
 
   <!-- The Welcome File List -->
   <welcome-file-list>
-    <welcome-file>index.jsp</welcome-file>
+    <welcome-file>welcome.jsp</welcome-file>
   </welcome-file-list>
 
   <!-- Application Tag Library Descriptor -->

Modified: struts/trunk/struts-faces/example1-webapp/src/web/index.jsp
==============================================================================
--- struts/trunk/struts-faces/example1-webapp/src/web/index.jsp (original)
+++ struts/trunk/struts-faces/example1-webapp/src/web/index.jsp Thu Oct 21 13:59:35 
2004
@@ -1,7 +1,8 @@
 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
-<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
-<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"; %>
+<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"; %>
+<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"; %>
+<%@ taglib prefix="s" uri="http://struts.apache.org/tags-faces"; %>
 
 <!--
 
@@ -22,13 +23,18 @@
 -->
 
 
-<html:html locale="true">
+<f:view>
+<s:html            locale="true">
 <head>
-<title><bean:message key="index.title"/></title>
-<html:base/>
+  <title>
+    <s:message        key="index.title"/>
+  </title>
+  <s:base/>
+  <s:stylesheet      path="/stylesheet.css"/>
 </head>
-<body bgcolor="white">
+<body>
 
+<%--
 <logic:notPresent name="database" scope="application">
   <font color="red">
     ERROR:  User database not loaded -- check servlet container logs
@@ -36,27 +42,56 @@
   </font>
   <hr>
 </logic:notPresent>
+--%>
 
+<%--
 <logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application">
   <font color="red">
     ERROR:  Application resources not loaded -- check servlet container
     logs for error messages.
   </font>
 </logic:notPresent>
+--%>
 
-<h3><bean:message key="index.heading"/></h3>
-<ul>
-<li><html:link page="/editRegistration.do?action=Create"><bean:message 
key="index.registration"/></html:link></li>
-<li><html:link page="/logon.faces"><bean:message key="index.logon"/></html:link></li>
-</ul>
+<h:form                id="indexForm">
+
+  <h:panelGrid    columns="1"
+              headerClass="list header"
+               rowClasses="list row even,list row odd"
+               styleClass="list">
+
+    <f:facet         name="header">
+      <s:message      key="index.heading"/>
+    </f:facet>
+
+    <s:commandLink     id="create"
+                   action="#{indexBacking.create}"
+                immediate="true"
+               styleClass="link">
+      <f:param       name="action"
+                    value="Create"/>
+      <s:message      key="index.registration"/>
+    </s:commandLink>
+
+    <s:commandLink     id="logon"
+                   action="#{indexBacking.logon}"
+                immediate="true"
+               styleClass="link">
+      <s:message      key="index.logon"/>
+    </s:commandLink>
+
+  </h:panelGrid>
+
+</h:form>
 
 <p>&nbsp;</p>
-<html:link page="/tour.do">
-<font size="-1"><bean:message key="index.tour"/></font>
-</html:link>
+<h:outputLink value="tour.do">
+  <font size="-1"><s:message key="index.tour"/></font>
+</h:outputLink>
 <p>&nbsp;</p>
 
-<html:img page="/struts-power.gif" alt="Powered by Struts"/>
+<h:graphicImage value="/struts-power.gif" alt="Powered by Struts"/>
 
 </body>
-</html:html>
+</s:html>
+</f:view>

Modified: struts/trunk/struts-faces/example1-webapp/src/web/mainMenu.jsp
==============================================================================
--- struts/trunk/struts-faces/example1-webapp/src/web/mainMenu.jsp      (original)
+++ struts/trunk/struts-faces/example1-webapp/src/web/mainMenu.jsp      Thu Oct 21 
13:59:35 2004
@@ -49,20 +49,6 @@
       </h:panelGroup>
     </f:facet>
 
-<%--
-    <h:outputLink   value="editRegistration.do"
-               styleClass="link">
-      <f:param       name="action"
-                    value="Edit"/>
-      <s:message      key="mainMenu.registration"/>
-    </h:outputLink>
-
-    <h:outputLink   value="logoff.do"
-               styleClass="link">
-      <s:message      key="mainMenu.logoff"/>
-    </h:outputLink>
---%>
-
     <s:commandLink     id="edit"
                    action="#{mainMenuBacking.edit}"
                 immediate="true"

Added: struts/trunk/struts-faces/example1-webapp/src/web/welcome.jsp
==============================================================================
--- (empty file)
+++ struts/trunk/struts-faces/example1-webapp/src/web/welcome.jsp       Thu Oct 21 
13:59:35 2004
@@ -0,0 +1 @@
+<jsp:forward page="/index.faces"/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to