Permalink
Browse files

Initial commit of the click version for the books interface.

This version used v2.2.0 of click as the web framework.

The added JOURNAL text file contains my thoughts and updates that have been made to this project.
  • Loading branch information...
1 parent 23c4fb6 commit d90a083ee0455cb71c1e9be1ec507efaef855830 @ccorsi committed Sep 20, 2010
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/18">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.web"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/BooksPersistenceBase"/>
+ <classpathentry kind="output" path="build/classes"/>
+</classpath>
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>BooksClick</name>
+ <comment></comment>
+ <projects>
+ <project>BooksXML</project>
+ <project>BooksPersistenceBase</project>
+ <project>BooksCommonWeb</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,127 @@
+
+This file will contain my thoughts on changes that I make during the process of building a web application
+using the Click web framework for the Books persistent layer.
+
+2010-09-17:
+===========
+
+Created a dynamic web project that will be using the Apache Click web framework.
+
+The Eclipse IDE plugin for Click 2.2.0 has as of this date not been released. There is a version for the
+Click 2.1.0 release but that is not what I using. By forcing me to look at how to configure click.xml and
+web.xml files. It provides will a unique advantage of understanding better how these configuration files are
+setup and why that are setup this way.
+
+After initially creating the click.xml file, I read the Apache Click User Guide. Click uses Velocity as a
+expression engine but it does not force a developer to use Velocity and is configurable within the click.xml
+configuration file.
+
+The first step that I needed to do was to configure the web.xml to be able to use the Click framework. The
+required that I set the servlet and servlet-mapping elements. The servlet element servlet-class child element
+to org.apache.click.ClickServlet. The servlet-mapping then just references the servlet element while processing
+requests.
+
+Click has the concept of a page. The page concept is realized by having a developer sub-classes the Page class.
+The developer then needs to associate this Page class to a path that the ClickServlet will map when processing
+requests. The initialize page classes that I created where different for each of the different actions that
+are required for the web container. The initial configuration resulted in differnt page instances for the
+different Persons, (Author, Editor, Illustrator and Translator), and the different actions, (New and Edit). The
+generated a total of 12 different Page sub-classes for the processing of the books persistent layer. This does
+not include the initial welcoming page.
+
+Upon more consideration, it seems that I can use a single Book, Person and Gender page to perform the same
+number of processing that did my initial implementation. Going from 12 classes to 3 makes my life much
+easier thank you. This only needs to be implemented and tested before considering this option a success.
+
+The next issue that I needed to resolve is the concept of initialize and shutdown process of the underlying book
+persistent layer during the web container init and destroy callbacks. My initial understanding was that I needed
+to create a Control instance that is associated with the click framework. Upon further investigation, this
+controled onInit and onDestroy methods are not called during the ClickServlet init and destroy callbacks but
+during every instantiated Page instance. This would not do since the initialization and shutdown process can
+cause inconsistency of data because of the concurrent processing of servlet requests.
+
+After further investigation, it became apparent that a class that implements the ConfigService interface will
+be called during the ClickServlet init and destroy callbacks. There is a default implementation, XmlConfigService,
+that I sub-classes so that I do not need to worry about being without some features that are provided by this
+implementation. To be able to associate this ConfigService implementation within the Click framework. I needed
+to update the web.xml by adding the following:
+
+ <context-param>
+ <param-name>config-service-class</param-name>
+ <param-value>org.books.service.BooksConfigService</param-value>
+ </context-param>
+
+The ClickServlet will look for the config-service-class and use the associated class name for the container else
+it will default to the XmlConfigService class.
+
+Finally, I copied most of the no-ZK specific classes from the BooksZK project to the book click project. It becomes
+apparent that these classes should be moved into a books common web project that is then referenced by the BooksZK
+and BooksClick projects.
+
+2010-09-18:
+===========
+
+While trying to add logging statements within the different Click specific implementations. I noticed that the
+ServletContext associated to the ConfigService class was not initialized during the onInit callback but that it
+was initialized during the onDestroy callback. When I have time, I will try to determine why this is the case.
+It could be possible that this is a click or tomcat bug. The logging mechanism should already be enabled during
+this callback.
+
+2010-09-19:
+===========
+
+I started to look at the way that you can create a web page using click. My objective is to try
+and recreate what I've produced using the ZK framework. My initial impression is that this is not
+going to be a simple task since both frameworks are different. The ZK framework provides you with
+expression language that contains many features that in click I need to develop. My lack of HTML
+experience makes this option a little more difficult to create. This has lead me to read up on
+HTML different features. Using the www.w3schools.com website has offered me more insight into
+what I am trying to accomplish. At the end of the day, the initial web page will not finished
+today. I was able to see how to define a form using click but I still need to enhance it to be
+able to submit the select book to edit.
+
+2010-09-20:
+===========
+
+In the process of trying to create a simple table with a hypelink to the book that a user would
+like to edit, I noticed a few things that required my changes. Some of these hacks can be
+wrong but at this time that is what I was able to do to get my page up and running. I hope to
+correct this hack and replace it with the correct approach to generate a table to contains page
+link.
+
+My initial attempt to create a selectable list has been replaced with my original idea of creating
+a table with a link to the page that you can click to update/edit the selected book. I was
+trying to determine how to add a link to the table. I initially tried to create my link using
+the ActionLink object but everytime that the table was rendered. The a tag < and > delimiters
+were replaced with &lt; and &gt;. After looking through the documentation and code I noticed
+that you need to create my own Decorator for the column that will contain the link within the
+table object.
+
+That current solution was partly resolving the issue but alas one more problem was still
+appearing. This is the case that the link in the link was not correct. It was correctly
+defining the root of the web application as BooksClick but it was not correctly defining the
+book page. Initially, it was setting this to "null" instead of /book.htm.
+
+Further digging resulted in my finding that the BooksConfigService class which sub-classes the
+XmlConfigService class. The ConfigService instance is used by the table rendering process to
+determine the path of the passed Page, (BookPage), but this would return a null path which is
+wrong. I tried to determine how to get it to return the correct mapping but alas I was not
+able at this time. I then went and implemented the getPagePath method to return the correct
+path for the BookPage class. This produces the expected generated web page but I still need
+to test this for completeness. Ultimately, I need to replace this hack with something more
+implicit. Maybe, I need to update my click.xml configuration file to map the different page
+classes to their respective template page. After making those changes to the click.xml
+configuration file. I tested this and hold and behold that it did work. I needed to create
+a page element for each of my Page classes. Upon doing this, I was able to comment out the
+getPagePath method from the BooksConfigService class and it worked! The terrible hack has
+been remove which is good.
+
+I've completed the initial book page but currently it only displays information about the
+type of book page we are displaying, a new or edit book page. The home page needs to updating
+such that it will contain the ability to create a new book and edit a new book. The BookPage
+instane will then be used to populate both types of requests depending on the parameters passed
+to the BookPage. The parameter "action" will determine the type of page. The paramerer "bookId"
+will be defined a request to edit a book. This will contain the identification of the book that
+we are going to be updating.
+
+
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE click-app PUBLIC
+ "-//Apache Software Foundation//DTD Click Configuration 2.2//EN"
+ "http://click.apache.org/dtds/click-2.2.dtd">
+
+<click-app charset="UTF-8" locale="en">
+
+ <!-- Specify the Java package where Page classes can be found--><!--
+ <pages package="org.books.page" autobinding="annotation">
+ <page classname="HomePage" path="welcome-page.html" />
+ <page classname="BookPage" path="create_book.html" />
+ <page classname="BookPage" path="edit_book.html" />
+ <page classname="PersonPage" path="create_author.html" />
+ <page classname="PersonPage" path="create_editor.html" />
+ <page classname="PersonPage" path="create_illustrator.html" />
+ <page classname="PersonPage" path="create_translator.html" />
+ <page classname="PersonPage" path="edit_author.html" />
+ <page classname="PersonPage" path="edit_editor.html" />
+ <page classname="PersonPage" path="edit_illustrator.html" />
+ <page classname="PersonPage" path="edit_translator.html" />
+ <page classname="GenderPage" path="create_gender.html" />
+ <page classname="GenderPage" path="edit_gender.html" />
+ </pages>
+
+ -->
+ <pages package="org.books.page" autobinding="annotation" >
+ <page classname="BookPage" path="book.htm"/>
+ <page classname="PersonPage" path="person.htm"/>
+ <page classname="GenderPage" path="gender.htm"/>
+ </pages>
+
+ <mode value="debug" />
+ <!--
+
+ At this time, this is no longer required but it is still possible
+ that in future updates I might need this implementation for other
+ processing procedures that are only part of the Control interface
+ of the click framework.
+
+ <controls>
+ <control classname="org.books.control.BookManagerControl"/>
+ </controls>
+
+ -->
+</click-app>
+
+
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
+ <display-name>BooksClick</display-name>
+ <welcome-file-list>
+ <welcome-file>redirect.html</welcome-file>
+ </welcome-file-list>
+ <servlet>
+ <servlet-name>ClickServlet</servlet-name>
+ <servlet-class>org.apache.click.ClickServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>ClickServlet</servlet-name>
+ <url-pattern>*.htm</url-pattern>
+ </servlet-mapping>
+ <context-param>
+ <param-name>config-service-class</param-name>
+ <param-value>org.books.service.BooksConfigService</param-value>
+ </context-param>
+</web-app>
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>$title</title>
+</head>
+<body>
+ $title
+</body>
+</html>
@@ -0,0 +1,26 @@
+<html>
+<head>
+ <title>$title</title>
+ <link rel="stylesheet" type="text/css" href="style.css" style="Style" />
+</head>
+<body>
+ <div id="header">
+ <span id="title">$title</span>
+ </div>
+
+ <div id="container">
+ <b>Welcome</b> to Home page for your application starting point.
+ </div>
+
+ <div id="container">
+ <b>Welcome</b> to Home page for your application starting point.
+ </div>
+
+ <div id="container">msg="$msg"</div>
+
+ <p>
+ <b>Hello,World!!!!</b>
+ </p>
+
+</body>
+</html>
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Refresh" content="0;URL=home.htm" />
+<title>Simple Redirect to the HomePage class</title>
+</head>
+<body>
+
+</body>
+</html>
@@ -0,0 +1,31 @@
+@CHARSET "ISO-8859-1";
+
+body {
+ font-family: Arial;
+}
+
+#header {
+ background-color: navy;
+}
+
+#title {
+ color: white;
+ font-size: 18px;
+ font-weight: bolder;
+}
+
+#container {
+ padding-top: 1em;
+ padding-left: 1.5em;
+ position: relative;
+ z-index: 0;
+}
+
+h3.title {
+ margin-top: 0em;
+ margin-bottom: 1em;
+}
+
+table.books {
+ width: 150px;
+}
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>$title</title>
+ <link rel="stylesheet" type="text/css" href="style.css" style="Style" />
+</head>
+<body>
+
+ #if ($msg)
+ <div id="header"> <span id="title">$msg</span></div>
+ #end
+
+ $table
+
+ $form
+
+ $create_book
+
+</body>
+</html>
Oops, something went wrong.

0 comments on commit d90a083

Please sign in to comment.