Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Launch Eclipse and Create a dynamic web project as shown in the figure
  2. Give the fields for the Web Project as shown in the following figure
  3. Check the box for JavaServerFaces and under the version tab select 1.2 as the version
  4. Once done you can give default values for web module and Geronimo Deployment Plan. On the JSF capabilities window check the box and select new as shown in the figure
  5. The next window suggests to create JSF Implementation library. Give the library name as JSFCustomLibrary and add the following jars. Select Finish once done. See the figure below
    • <GERONIMO_HOME>\repository\commons-beanutils\commons-beanutils\1.6.1\commons-beanutils-1.6.1.jar
    • <GERONIMO_HOME>\repository\commons-collections\commons-collections\3.1\commons-collections-3.1.jar
    • <GERONIMO_HOME>\repository\commons-digester\commons-digester\1.8\commons-digester-1.8.jar
    • <GERONIMO_HOME>\repository\commons-logging\commons-logging\1.0.4\commons-logging-1.0.4.jar
    • <GERONIMO_HOME>\repository\org\apache\myfaces\core\myfaces-api\1.2.2\myfaces-api-1.2.2.jar
    • <GERONIMO_HOME>\repository\org\apache\myfaces\core\myfaces-impl\1.2.2\myfaces-impl-1.2.2.jar!JSFCustomLibrary.GIF!
  6. Check Deploy and modify the URL pattern to *.jsf as shown in the figure. Select Finish.

...

  1. The next few lines contains the usual html tags
    Code Block
    ActionScript
    ActionScript
    borderStylesolid
    titleCode Snippet from login.jsp
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Welcome to Apache Geronimo</title>
    </head>
    <body>
    
  2. <f:view>- This tag represents the start of JSF code.
  3. Code Block
    ActionScript
    ActionScript
    borderStylesolid
    titleCode Snippet from login.jsp
    <h:inputText id="firstName" value="#{firstName.name}" required="true">
    
    Represents the input tag. id="firstName" and value="#
    {firstName.name}
    comes from the Managed Bean. Use the Faces Configuration Editor, Select firstName bean under Managed Bean. The Managed Bean Name is firstName. See the figure below

...

  1. !View3_new.GIF|align=center!
    This completes the implementation of View(V) in the application.
    The other tags <f:validateLength> and <h:commandButton> will be explained in the next section.

Define the Validator Component

...

Right Click on the project SimpleJSF and Select Run As-> Run On Server. This will deploy the sample on Apache Geronimo Server and a Login page will be launched.

Lets give some sample inputs
Sample Input1:

First Name: Mickey

...

Both the First Name as well as Last Name fulfills the validation rules, so this form will be submitted to controller and according to the navigation rule controller will  launch a welcome.jsp page.
Sample Input2:
First Name: Mic

Last Name: Mouse

First Name should be minimum of length=4 but in this case First Name is of length=3. In this case validation will fail and an error message will be generated by controller for First Name field.
Sample Input3:
First Name: Mickey
Last Name:Mo

Last Name should be minimum of length=3 but in this case Last Name is of length=2. In this case validation will fail and an error message will be generated by controller for Last Name field.