You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2005/02/22 18:57:50 UTC

cvs commit: incubator-myfaces/webapps/blank/src/org/apache/myfaces/blank HelloWorldBacking.java

matzew      2005/02/22 09:57:50

  Modified:    build    build.xml
  Added:       webapps/blank/web/WEB-INF .cvsignore blank-faces-config.xml
               conf/blank web.xml
               webapps/blank/web page2.jsp index.jsp helloWorld.jsp
               build/blank-webapp build.xml
               webapps/blank/web/css tiles.css
               webapps/blank/src/org/apache/myfaces/blank
                        HelloWorldBacking.java
  Log:
  added a simple app (similar to struts blank)
  
  Revision  Changes    Path
  1.1                  incubator-myfaces/webapps/blank/web/WEB-INF/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  web.xml
  classes
  
  
  
  1.1                  incubator-myfaces/webapps/blank/web/WEB-INF/blank-faces-config.xml
  
  Index: blank-faces-config.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!DOCTYPE faces-config PUBLIC
    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
    "http://java.sun.com/dtd/web-facesconfig_1_0.dtd" >
  
  <faces-config>
  	
  	<!-- managed beans of the simple hello world app -->
  	<managed-bean>
  		<managed-bean-name>helloWorldBacking</managed-bean-name>
  		<managed-bean-class>org.apache.myfaces.blank.HelloWorldBacking</managed-bean-class>
  		<managed-bean-scope>request</managed-bean-scope>
  	</managed-bean>
  	
  	<!-- navigation rules for helloWorld.jsp -->
  	<navigation-rule>
  		<from-view-id>/helloWorld.jsp</from-view-id>
  		<navigation-case>
  			<from-outcome>success</from-outcome>
  			<to-view-id>/page2.jsp</to-view-id>
  		</navigation-case>
  	</navigation-rule>
  	
  	<!-- navigation rules for page2.jsp -->
  	<navigation-rule>
  		<from-view-id>/page2.jsp</from-view-id>
  		<navigation-case>
  			<from-outcome>back</from-outcome>
  			<to-view-id>/helloWorld.jsp</to-view-id>
  		</navigation-case>
  	</navigation-rule>
  </faces-config>
  
  
  1.1                  incubator-myfaces/conf/blank/web.xml
  
  Index: web.xml
  ===================================================================
  <?xml version="1.0"?>
  <!--
   * Copyright 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.
  -->
  
  <!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
  
  <web-app>
  
      <!-- This web.xml can be used during debugging, when there is no myfaces.jar
          library available.
  
          The faces-config.xml file (that is normally in the myfaces.jar) must be
          copied to the /WEB-INF directory of the web context.
  
          The TLDs (that are normally in the myfaces.jar) must be
          copied to the /WEB-INF/lib directory of the web context.-->
  
  
      <context-param>
          <param-name>javax.faces.CONFIG_FILES</param-name>
          <param-value>
              /WEB-INF/blank-faces-config.xml
          </param-value>
          <description>
              Comma separated list of URIs of (additional) faces config files.
              (e.g. /WEB-INF/my-config.xml)
              See JSF 1.0 PRD2, 10.3.2
          </description>
      </context-param>
  
      <context-param>
          <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
          <param-value>client</param-value>
          <description>
              State saving method: "client" or "server" (= default)
              See JSF Specification 2.5.2
          </description>
      </context-param>
  
      <context-param>
          <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
          <param-value>true</param-value>
          <description>
              This parameter tells MyFaces if javascript code should be allowed in the
              rendered HTML output.
              If javascript is allowed, command_link anchors will have javascript code
              that submits the corresponding form.
              If javascript is not allowed, the state saving info and nested parameters
              will be added as url parameters.
              Default: "true"
          </description>
      </context-param>
  
      <context-param>
          <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
          <param-value>true</param-value>
          <description>
              If true, rendered HTML code will be formatted, so that it is "human readable".
              i.e. additional line separators and whitespace will be written, that do not
              influence the HTML code.
              Default: "true"
          </description>
      </context-param>
  
      <!-- Listener, that does all the startup work (configuration, init). -->
      <listener>
          <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
      </listener>
  
      <!-- Faces Servlet -->
      <servlet>
          <servlet-name>Faces Servlet</servlet-name>
          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
      </servlet>
  
      <servlet-mapping>
          <servlet-name>Faces Servlet</servlet-name>
          <url-pattern>*.jsf</url-pattern>
      </servlet-mapping>
  
      <!-- Welcome files -->
      <welcome-file-list>
          <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
  
  </web-app>
  
  
  1.1                  incubator-myfaces/webapps/blank/web/page2.jsp
  
  Index: page2.jsp
  ===================================================================
  <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
  <f:view>
  
  <f:verbatim><h2></f:verbatim>
  <h:outputText value="Hello #{helloWorldBacking.name}. We hope you enjoy Apache MyFaces"/>
  <f:verbatim></h2></f:verbatim>
  
  
  <h:form id="form2">
    <h:commandLink id="link1" action="back">
      <h:outputText id="linkText" value="GO HOME"/>
    </h:commandLink>
  </h:form>
  
  </f:view>
  
  
  1.1                  incubator-myfaces/webapps/blank/web/index.jsp
  
  Index: index.jsp
  ===================================================================
  <%@ page session="false"%>
  <%
  response.sendRedirect("helloWorld.jsf");
  %>
  
  
  1.1                  incubator-myfaces/webapps/blank/web/helloWorld.jsp
  
  Index: helloWorld.jsp
  ===================================================================
  <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
  <f:view>
  
  <h:form id="form">
    <h:panelGrid id="grid" columns="2">
      <h:outputText id="output1" value="Please enter your name"/>
      <h:inputText id="input1" value="#{helloWorldBacking.name}" required="true"/>
      <h:commandButton id="button1" value="press me" action="#{helloWorldBacking.send}"/>
      <h:message id="message1" for="input1"/>
    </h:panelGrid>
  </h:form>
  
  </f:view>
  
  
  1.1                  incubator-myfaces/build/blank-webapp/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <!DOCTYPE project [
      <!ENTITY tomcat-build SYSTEM "file:../tomcat/tomcat-build.xmlf">
  ]>
  <project name="myfaces-blank-example" default="run-blank">
  
      <property environment="env"/>
  
      <!-- Constants -->
      <property name="project.dir" location="${basedir}/../.."/>
      <property name="blank.dir" location="${project.dir}/webapps/blank"/>
      <property name="blank.src" location="${blank.dir}/src"/>
      <property name="blank.web" location="${blank.dir}/web"/>
      <property name="web-inf.classes.dir" location="${blank.web}/WEB-INF/classes"/>
      <property name="web-inf.lib.dir" location="${blank.web}/WEB-INF/lib"/>
      <property name="myfaces.doc" location="${project.dir}/doc"/>
  
      <!-- Properties -->
      <property file="../build.local.properties"/>
      <property file="../build.default.properties"/>
      <property file="../manifest.properties"/>
  
      <!-- Temporary dir. May be overridden in build.local.properties -->
      <property name="temp.dir" location="${env.TEMP}/blank-example"/>
  
      <!-- Tomcat -->
      <property name="tomcat.war.file" location="${temp.dir}/myfaces-blank.war"/>
      <property name="tomcat.context.path" value="/myfaces"/>
  
  
      <!-- classpath for compiling -->
      <path id="blank.class.path">
          <pathelement location="${servlet-jsp.jar}"/>
          <pathelement location="${jsp-2.0.jar}"/>
          <pathelement location="${jstl.jar}"/>
          <pathelement location="${myfaces.jar}"/>
          <pathelement location="${myfaces-jsf-api.jar}"/>
          <pathelement location="${commons-logging.jar}"/>
      </path>
  
  
      <target name="run-blank"
              description="creates blank war and deploys it" >
          <ant dir="${project.dir}/build/blank-webapp" antfile="build.xml" target="-war" inheritall="false"/>
          <antcall target="tomcat-deploy-app"/>
          <echo message="browse to http://${tomcat.server}:${tomcat.port}${tomcat.context.path}"/>
      </target>
  
      <target name="clean"
              description="deletes all files that were built">
          <delete quiet="true" failonerror="false" includeEmptyDirs="true">
              <fileset dir="${web-inf.classes.dir}"/>
              <fileset dir="${web-inf.lib.dir}"/>
              <fileset file="${project.dir}/myfaces-*-blank.tgz"/>
              <fileset file="${blank.web}/WEB-INF/web.xml"/>
              <fileset file="${blank.web}/WEB-INF/faces-config.xml"/>
              <fileset file="${temp.dir}/myfaces-blank-example.war" />
          </delete>
      </target>
  
  
      <target name="-compile-and-copy-libs"
              depends="-myfaces-jar"
              description="compiles the blank java classes to WEB-INF/classes and copies all needed libs to WEB-INF/lib">
          <mkdir dir="${web-inf.classes.dir}" />
          <javac srcdir="${blank.src}"
                 destdir="${web-inf.classes.dir}"
                 optimize="${javac.optimize}"
                 debug="${javac.debug}"
                 classpathref="blank.class.path">
          </javac>
          <copy todir="${web-inf.classes.dir}">
              <fileset dir="${blank.src}"
                       includes="**"
                       excludes="**/*.java
                                 **/package.html"/>
          </copy>
  
      </target>
  
  
     	<target name="-set-tomcat-includes-init">
  		<condition property="tomcat.pre.5.5">
  			<istrue value="${tomcat.pre.5.5.version}"/>
  		</condition>
  	</target>
  	<target name="-set-tomcat-pre-5.5-includes" if="tomcat.pre.5.5">
  		<echo message="Setting war libraries for tomcat version &lt; to 5.5."/>
      	<property name="tomcat.special.include" value="commons-el.jar,jsp-2.0.jar"/>
  	</target>
     	<target name="-set-tomcat-post-5.5-includes" unless="tomcat.pre.5.5">
  		<echo message="Setting war libraries for tomcat version &gt; to 5.5."/>
      	<property name="tomcat.special.include" value="nothingToInclude"/>
  	</target>
     	<target name="-set-tomcat-compatibility-includes" depends="-set-tomcat-includes-init,-set-tomcat-pre-5.5-includes,-set-tomcat-post-5.5-includes">
  	</target>
  
  
      <target name="-war" depends="-compile-and-copy-libs">
          <mkdir dir="${temp.dir}" /> 
          <tstamp>
              <format property="TODAY" pattern="yyyy-MM-dd HH:mm" locale="en"/>
          </tstamp>
          <war destfile="${temp.dir}/myfaces-blank-example.war"
               webxml="${project.dir}/conf/blank/web.xml">
              <manifest>
                  <section name="${manifest.section}">
                      <attribute name="Implementation-Title" value="${manifest.impl.title}"/>
                      <attribute name="Implementation-Version" value="${manifest.impl.version} (${TODAY})"/>
                      <attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
                  </section>
              </manifest>
          	<lib dir="${project.dir}/lib" includes="${tomcat.special.include}"/>
              <lib file="${commons-codec.jar}"/>
              <lib file="${commons-logging.jar}"/>
              <lib file="${commons-beanutils.jar}"/>
              <lib file="${commons-collections.jar}"/>
              <lib file="${commons-digester.jar}"/>            
              <lib file="${jstl.jar}"/>
              <lib file="${myfaces.jar}"/>
              <!--lib file="${myfaces-jsf-api.jar}"/-->
              <classes dir="${web-inf.classes.dir}" />
              <fileset dir="${blank.web}"
                       excludes="WEB-INF/classes/**,
                                 WEB-INF/lib/**,
                                 WEB-INF/web.xml " />
          </war>
      </target>
  
      <target name="release"
              depends="-compile-and-copy-libs, -war"
              description="creates the blank-webapp release file myfaces-x.x.x-blank.tgz (don't forget to adjust manifest.properties!)">
  
          <tar destfile="${project.dir}/myfaces-${manifest.impl.version}-blank-example.tgz"
               compression="gzip">
              <tarfileset dir="${myfaces.doc}"
                          excludes="javadoc/**/*
                                    tlddoc/**/*"
                          prefix="myfaces-${manifest.impl.version}/doc"/>
              <tarfileset dir="${blank.web}"
                          excludes="WEB-INF/classes/**/*,
                                    WEB-INF/lib/**/*"
                          prefix="myfaces-${manifest.impl.version}/webapps/blank/web"/>
              <tarfileset dir="${temp.dir}"
                          includes="myfaces-blank-example.war"
                          prefix="myfaces-${manifest.impl.version}"/>
          </tar>
      </target>
  
      <target name="-myfaces-jar" description="create myfaces.jar if necessary" >
          <available file="${myfaces.jar}" property="myfaces.jar.available"/>
          <antcall target="-create-myfaces-jar"/>
      </target>
      
      <target name="-create-myfaces-jar" unless="myfaces.jar.available"
              description="creates myfaces.jar via main buildfile" >
          <ant dir="${project.dir}/build" antfile="build.xml" target="myfaces-jar" inheritall="false"/>
      </target>
  
      <target name="-myfaces-jsf-api-jar" description="create myfaces.jar if necessary" >
          <available file="${myfaces-jsf-api.jar}" property="myfaces.jar.available"/>
          <antcall target="-create-myfaces-jsf-api-jar"/>
      </target>
  
      <target name="-create-myfaces-jsf-api-jar" unless="myfaces.jar.available"
              description="creates myfaces-jsf-api.jar via main buildfile" >
          <ant dir="${project.dir}/build" antfile="build.xml" target="myfaces-jsf-api-jar" inheritall="false"/>
      </target>
  
  </project>
  
  
  
  1.76      +9 -1      incubator-myfaces/build/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/build/build.xml,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- build.xml	26 Jan 2005 17:03:10 -0000	1.75
  +++ build.xml	22 Feb 2005 17:57:50 -0000	1.76
  @@ -442,6 +442,14 @@
                target="release"/>
       </target>
   
  +    <target name="blank-release"
  +            description="creates the tiles examples release file myfaces-x.x.x-tiles-example.tgz (don't forget to adjust manifest.properties!)">
  +        <ant dir="${project.dir}/build/blank-webapp"
  +             antfile="build.xml"
  +             inheritall="false"
  +             target="release"/>
  +    </target>
  +
       <target name="wap-release"
               description="creates the wap examples release file myfaces-x.x.x-tiles-example.tgz (don't forget to adjust manifest.properties!)">
           <ant dir="${project.dir}/build/wap-webapp"
  @@ -450,7 +458,7 @@
                target="release"/>
       </target>	
   	<target name="all"
  -            depends="bin-release, src-release, examples-release, tiles-release, wap-release"
  +            depends="bin-release, src-release, examples-release, tiles-release, blank-release, wap-release"
               description="builds all release files">
       </target>
   
  
  
  
  1.1                  incubator-myfaces/webapps/blank/web/css/tiles.css
  
  Index: tiles.css
  ===================================================================
  body {
      margin:12px 12px 0 9px;
      padding:0;
      background:#FFFFFF;
  }
  #level0 {
  }
  #level1 {
  }
  #level2 {
      margin-left:150px;
      padding:15px;
  }
  #topBar {
      background:#B1D2EB;
      padding:4px;
  }
  #lftBar {
      background:#FC0;
      position:absolute;
      width:120px;
      top:145px;
  }
  
  
  
  1.1                  incubator-myfaces/webapps/blank/src/org/apache/myfaces/blank/HelloWorldBacking.java
  
  Index: HelloWorldBacking.java
  ===================================================================
  /*
   * Copyright 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.myfaces.blank;
  
  /**
   * A typical simple backing bean, that is backed to <code>helloworld.jsp</code>
   * 
   * @author <a href="mailto:matzew@apache.org">Matthias We�endorf</a> 
   */
  public class HelloWorldBacking {
  
      
      //properties
      private String name;
      
      /**
       * default empty constructor
       */
      public HelloWorldBacking(){   
      }
      
      //-------------------getter & setter
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      
      /**
       * Method that is backed to a submit button of a form.
       */
      public String send(){
          //do real logic
          return ("success");
      }
  }