Workstation Setup

Workstation Setup


Connection Pool Setup

 

Downloads

FrameWork Jars

 

Sample Default Properties Files

 

HelloWorld javascript and supporting files

 

  

 

 

Your first AsyncFW application:

What is the difference between AsyncDO and AsyncFW? 

AsyncFW is the entire framework, you can’t use AsyncDO without AsyncFW. AsyncDO is a data object based wrapper for AsyncFW. As you will see in this example, with AsyncFW you interact directly with the Request and Response DOM objects, for example;

 

fwSess.getSessionReq().getValue("sysAction").equalsIgnoreCase("Find");

 

With AsyncDO you would interact with the same ‘sysAction’ node as an object, for example;

 

uiObj.getsysAction().equalsIgnoreCase("Find");

 

We will get into the AsyncDO much more in the FWAdmin tutorials, but for now we will focus on the AsyncFW interfaces, as they are basis for all interactions.

Let’s get started!

 

Ok, here we go with the required “Hello world” application – Sorry.

 

Assumptions:

 

Ø      You have your workstation setup.

Ø      You are familiar with Eclipse

Ø      You have completed the workstation setup, and connection pool tutorials.

 

Create a new Dynamic Web Project in Eclipse.

 

 

 

Once your project has been created,  Download the FrameWork jar files

 Jar zip file, and unzip all the files into your new project’s /web-inf/lib folder.

 

 

Select your project in Eclipse, right mouse click and select “Refresh”.

 

Download the Sample Default Properties Files, and place them in your project’s /src folder.

 

 

Refresh your project.

 

Download and unzip the HelloWorld javascript and supporting files into your Webcontent folder, so that your project will have the following structure (once you refresh)

 

 

Creating your first F4J ServiceLet

 

Crate a package named com.test in your /src folder, and then create a new Servlet called “World”.

 

 

Your project should now look like this…

 

 

 

Framework-ize the Servlet

 

Open the “World” servlet in the Eclipse Editor and select all the java code, and replace it with the following code.

 

package com.test;

 

import javax.servlet.ServletConfig;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import com.FW.Exceptions.FWException;

import com.FW.servlet.utils.FWHttpServiceLet;

import com.FW.servlet.utils.FWServiceLetInt;

import com.FW.servlet.utils.FWSession;

 

/**

 * Servlet implementation class World

 */

public class World  extends FWHttpServiceLet implements FWServiceLetInt {

       private static final long serialVersionUID = 1L;

       private static String XSLT_AddField_AddField = "/html/xsl/World.xsl";

    /**

     * @see HttpServlet#HttpServlet()

     */

    public World() {

        super();

        // TODO Auto-generated constructor stub

    }

       /**

        * This method is required to be implemented for every servlet using the Framework

        * it must also set the values for Servlet Name and OutputXSL.

        *

        *

        * @param ServletConfig config

        *

        */

       public void init(ServletConfig config) throws ServletException {

              super.init(config);

              // WARNING: the below line turns off Session Validation.

              this.setRequiresValidation(false); //you almost never want this!!

              // END WARNING.

              this.setServletName("World");

              this.setArrayOfParms(new String[]{"World"});

              this.setOutputXSL(XSLT_AddField_AddField);

       }

       /**

        *

        * @param inXML

        * @return

        * @throws FWException

        */

       public String getFWService(String inXML) throws Exception{

              this.setRequiresValidation(true);

              return this.FWService(inXML);

       }

       /**

        * The execute method will be called for any POST or GET http request directed

        * at this servlet. The request, response, printwriter and incoming values are

        * available in the parent class 'FWHttpServlet'. The FWSession object contains

        * both the original response and request objects.

        *

        * @see FWHttpServiceLet

        * @see World.xsl

        */

    public void Execute(FWSession fwSess) throws FWException {

       try{

 

       }catch(Exception err){

            err.printStackTrace();

       }

      

 

    }

}

 

Granted we have short-cut the process a bit, so I will do a quick review of what changed from the original Servlet, to make it a ServiceLet.

 

First we are no longer just extending HTTPServlet, we are now FWHttpServiceLet, and implementing the FWServiceLet Interface.

 

Next we remove the doPost, and doGet methods, and replaced them with an Execute method.

 

Added code to the init method, so that the ServiceLet is initialized correctly. We have also added a reference to our XSL file “World.xsl”.

 

Note: If you use the FWAdmin to create your initial code, this will all be handled for you.

 

Modify your web.xml file

 

Lastly, we need to modify the web.xml file for every project that uses the Framework. These changes make the connection pool available, as well as the LDWR – more on that later.

 

For now, simply open your Web.xml and add the following;

 

  <resource-ref>

    <res-ref-name>jdbc/FWConPool</res-ref-name>

    <res-type>javax.sql.DataSource</res-type>

    <res-auth>Container</res-auth>

    <res-sharing-scope>Shareable</res-sharing-scope>

  </resource-ref>

  <servlet>

    <description></description>

    <display-name>FWDirect</display-name>

    <servlet-name>FWDirect</servlet-name>

    <servlet-class>com.FW.direct.FWDirect</servlet-class>

    <load-on-startup>0</load-on-startup>

  </servlet>

  <servlet-mapping>

    <servlet-name>FWDirect</servlet-name>

    <url-pattern>/FWDirect</url-pattern>

  </servlet-mapping>

 

NOTE: If your connection pool name is different, you will need to modify the above to match it. See Setting Up Connection Pools for more information

 

 

Time to say “Hello”!

 

Add the project to your server, and restart the server.

 

http://localhost:8080/Hello/html/Start.html

 

 

 

 Next Page>>>>

 

 

 

 

Copyright 2009. All rights reserved by

S. Chappell