Hi Adrian,

Thanks a lot for your help. I could make the Click Examples work in my Web 
Application. Here the steps I did.
I think can be useful to beginners like me

Mini Tutorial How to Include the Cayenne Spring Example (2.1.0 Version) in 
your Web Application.  

I considered your Web Application have already support Click Apache. If you 
don't know how to do, I suggest start using the
The Quick Start Project Builder 

1) Download and extract the click-2.1.0.zip from the Apache Click Downloads 


1) Add the following line in click.xml file to include the pages from Click 
Examples 

<click-app>
   <pages package="org.apache.click.examples.page" 
autobinding="annotation"/>
</click-app> 

2) Copy the click-2.1.0/examples/webapp/cayenne/ directory to your 
WebContent directory 

3) Copy the click-2.1.0/examples/src/org to your src directory 

4) Change the Servlet from ClickServlet to SpringClickServlet. 
   Make the Cayenne and Quartz Initialization
   To do that, add the following lines in /WEB-INF/web.xml file
   Obs. I didn't use Spring Security (Acegi) Filter 

 <!--
        Spring configuration location.
        -->
        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>WEB-INF/spring-beans.xml</param-value>
        </context-param> 

        <!-- Filters --> 

        <!--
        Provides a thread local Cayenne DataContext filter.
        -->
        <filter>
                <filter-name>DataContextFilter</filter-name>
                
<filter-class>org.apache.click.extras.cayenne.DataContextFilter</filter-clas
s>
                <init-param>
                        <param-name>oscache-enabled</param-name>
                        <param-value>true</param-value>
                </init-param>
        </filter> 

        <filter-mapping>
                <filter-name>DataContextFilter</filter-name>
    <url-pattern>*.htm</url-pattern>
        </filter-mapping> 

<!-- Listeners --> 

        <!--
        The Quartz initialization listenger which loads the Quartz 
scheduler.
        -->
        <listener>
                
<listener-class>org.quartz.ee.servlet.QuartzInitializerListener</listener-cl
ass>
        </listener> 

        <!--
        The Spring Context Loader which initializes the Spring runtime.
        -->
        <listener>
                
<listener-class>org.springframework.web.context.ContextLoaderListener</liste
ner-class>
        </listener> 

        <!--
        Provides an in memory databae initialization listener. In a 
production
        application a separate database would be used, and this listener 
would not
        be needed.
        -->
        <listener>
                
<listener-class>org.apache.click.examples.util.DatabaseInitListener</listene
r-class>
        </listener> 

 <!-- Servlets --> 

        <!--
        The Spring Click Servlet which handles *.htm requests.
        -->
        <servlet>
                <servlet-name>ClickServlet</servlet-name>
                
<servlet-class>org.apache.click.extras.spring.SpringClickServlet</servlet-cl
ass>
                <load-on-startup>0</load-on-startup>
        </servlet> 

5) Copy the /click-2.1.0/examples/webapp/WEB-INF/spring-beans.xml file to 
your /WebContent/WEB-INF 

6) Copy the above files to your /src/ directory 

/click-2.1.0/examples/src/cayenne.xml
/click-2.1.0/examples/src/cayenneNode.driver.xml
/click-2.1.0/examples/src/cayenneMap.map.xml
/click-2.1.0/examples/src/oscache.properties
/click-2.1.0/examples/src/log4j.xml 
/click-2.1.0/examples/src/quartz.properties 

7) Copy the click and assets directories to your WebContent directory 

 /click-2.1.0/examples/webapp/click/ 
 /click-2.1.0/examples/webapp/assets/ 

8) Add the following lines in your menu.xml. In my case I'm using the roles 
from tomcat-users.xml file (Quick Start Project Builder) 

   <menu label=" Integration" path="#" roles="user, admin" 
imageSrc="/assets/images/cayenne.png">
     <menu label="Apache Cayenne Form" path="cayenne/cayenne-form-page.htm" 
roles="user, admin"/>
     <menu label="Cayenne Tabbed Form" 
path="cayenne/tabbed-cayenne-form-page.htm" roles="user, admin"/>
     <menu label="PropertySelect Demo (1-to-*)" 
path="cayenne/accommodation-demo.htm" roles="user, admin"/>
     <menu label="PickList Demo (*-to-*)" 
path="cayenne/enrollment-demo.htm" roles="user, admin"/>
   </menu> 

9) If you wanna you can restrict the access to the /cayenne directory using 
the following diretives in web.xml 

 <security-constraint>
        <web-resource-collection>
            <web-resource-name>cayenne</web-resource-name>
            <url-pattern>/cayenne/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>user</role-name>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint> 

10) The following libraries must be in the /WEB-INF/lib directory 

ashwood-2.0.jar
cayenne-server-3.0M6.jar
commons-logging-1.1.1.jar
geronimo-annotation_1.0_spec-1.1.1.jar
hsqldb-1.8.0.1.jar
jstl-1.1.2.jar
log4j-1.2.14.jar
oscache-2.4.jar
poi-3.5-FINAL.jar
quartz-all-1.6.3.jar
spring-2.5.6.jar
spring-security-core-2.0.4.jar
standard-1.1.2.jar
click-2.1.0.jar
click-extras-2.1.0.jar
oscache-2.4.jar

Reply via email to