Author: pete.muir(a)jboss.org
Date: 2008-02-04 08:32:52 -0500 (Mon, 04 Feb 2008)
New Revision: 7355
Added:
trunk/examples/wicket/
trunk/examples/wicket/build.xml
trunk/examples/wicket/resources/
trunk/examples/wicket/resources/META-INF/
trunk/examples/wicket/resources/META-INF/application.xml
trunk/examples/wicket/resources/META-INF/ejb-jar.xml
trunk/examples/wicket/resources/META-INF/jboss-app.xml
trunk/examples/wicket/resources/META-INF/persistence.xml
trunk/examples/wicket/resources/WEB-INF/
trunk/examples/wicket/resources/WEB-INF/components.xml
trunk/examples/wicket/resources/WEB-INF/pages.xml
trunk/examples/wicket/resources/WEB-INF/web.xml
trunk/examples/wicket/resources/components.properties
trunk/examples/wicket/resources/import.sql
trunk/examples/wicket/resources/jboss-seam-booking-ds.xml
trunk/examples/wicket/resources/messages.properties
trunk/examples/wicket/resources/seam.properties
trunk/examples/wicket/src/
trunk/examples/wicket/src/action/
trunk/examples/wicket/src/action/org/
trunk/examples/wicket/src/action/org/jboss/
trunk/examples/wicket/src/action/org/jboss/seam/
trunk/examples/wicket/src/action/org/jboss/seam/example/
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Authenticator.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/AuthenticatorAction.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Booking.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/BookingList.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/BookingListAction.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/ChangePassword.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/ChangePasswordAction.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Hotel.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBooking.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBookingAction.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelSearching.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelSearchingAction.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Register.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/RegisterAction.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/User.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/BookingTest.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/ChangePasswordTest.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/LoginTest.java
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/testng.xml
trunk/examples/wicket/src/web/
trunk/examples/wicket/src/web/org/
trunk/examples/wicket/src/web/org/jboss/
trunk/examples/wicket/src/web/org/jboss/seam/
trunk/examples/wicket/src/web/org/jboss/seam/example/
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/HotelViewPanel.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/HotelViewPanel.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/OutputBorder.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/OutputBorder.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Template.html
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Template.java
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/WicketBookingApplication.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/
trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedAttribute.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedField.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedMethod.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedProperty.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionInterceptor.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionSupport.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/LoggerSupport.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModel.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModelUtils.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/ModelValidator.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/OutjectionSupport.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamAuthorizationStrategy.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamLink.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamSupport.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/SimpleDataProvider.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketComponent.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketManager.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketRedirectFilter.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketSeamFilter.java
trunk/examples/wicket/src/web/org/jboss/seam/wicket/components/
trunk/examples/wicket/view/
trunk/examples/wicket/view/conversations.xhtml
trunk/examples/wicket/view/css/
trunk/examples/wicket/view/css/screen.css
trunk/examples/wicket/view/css/trailblazer_main.css
trunk/examples/wicket/view/img/
trunk/examples/wicket/view/img/bg.gif
trunk/examples/wicket/view/img/btn.bg.gif
trunk/examples/wicket/view/img/cal-next.png
trunk/examples/wicket/view/img/cal-prev.png
trunk/examples/wicket/view/img/cnt.bg.gif
trunk/examples/wicket/view/img/dtpick.gif
trunk/examples/wicket/view/img/hdr.ad.jpg
trunk/examples/wicket/view/img/hdr.bar.jpg
trunk/examples/wicket/view/img/hdr.bg.gif
trunk/examples/wicket/view/img/hdr.title.gif
trunk/examples/wicket/view/img/header_line.gif
trunk/examples/wicket/view/img/input.bg.gif
trunk/examples/wicket/view/img/sdb.bg.gif
trunk/examples/wicket/view/img/spinner.gif
trunk/examples/wicket/view/img/th.bg.gif
Log:
First pass at port of booking example to wicket
Added: trunk/examples/wicket/build.xml
===================================================================
--- trunk/examples/wicket/build.xml (rev 0)
+++ trunk/examples/wicket/build.xml 2008-02-04 13:32:52 UTC (rev 7355)
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+
+<project name="WicketBooking" default="deploy"
basedir="." xmlns:artifact="urn:maven-artifact-ant">
+
+ <!-- Naming -->
+ <property name="Name" value="Port of Seam Booking
Example to use Wicket"/>
+ <property name="example.name"
value="jboss-seam-wicket"/>
+
+ <property name="src.java.dir" value="src/action" />
+ <property name="src.web.dir" value="src/web" />
+
+ <!-- Libraries to include -->
+
+ <!-- Datasource -->
+ <property name="example.ds"
value="jboss-seam-wicket-ds.xml"/>
+
+ <property name="example.tmp.lib.dir" value="${basedir}/lib"
/>
+
+ <property name="clean.extra"
value="${example.tmp.lib.dir}"/>
+
+
+
+ <import file="../build.xml"/>
+
+ <path id="build.classpath.extras">
+ <fileset dir="${example.tmp.lib.dir}" />
+ </path>
+
+ <fileset id="ear.lib.extras" dir="${example.tmp.lib.dir}">
+ <include name="*.jar" />
+ </fileset>
+
+ <target name="compile.web" depends="compile">
+ <mkdir dir="${war.dir}/WEB-INF/classes" />
+ <javac destdir="${war.dir}/WEB-INF/classes"
debug="${javac.debug}" deprecation="${javac.deprecation}"
nowarn="on" >
+ <src path="${src.web.dir}" />
+ <classpath refid="build.classpath"/>
+ <classpath location="${jar.dir}"/>
+ </javac>
+ <copy todir="${war.dir}/WEB-INF/classes">
+ <fileset dir="${src.web.dir}">
+ <include name="**/*.component.xml" />
+ <include name="**/*.html" />
+ <include name="seam.properties" />
+ </fileset>
+ </copy>
+ </target>
+
+ <!-- Examples build hook point for running targets before creating the war -->
+ <target name="init.war" depends="compile.web" />
+
+ <target name="copyextradependencies">
+ <artifact:remoteRepository id="wicketstuff.org"
url="http://wicketstuff.org/maven/repository"/>
+
+ <artifact:dependencies filesetId="wicket.fileset"
versionsId="wicket.versions" sourcesfilesetid="wicket.sources">
+ <dependency groupId="org.apache.wicket" artifactId="wicket"
version="1.3.0-SNAPSHOT">
+ <exclusion groupId="cglib" artifactid="cglib-nodep" />
+ <exclusion groupId="asm" artifactId="asm" />
+ </dependency>
+ <dependency groupId="org.apache.wicket" artifactId="wicket-ioc"
version="1.3.0-SNAPSHOT">
+ <exclusion groupId="cglib" artifactid="cglib-nodep" />
+ <exclusion groupId="asm" artifactId="asm" />
+ </dependency>
+ <dependency groupId="org.slf4j" artifactId="slf4j-log4j12"
version="1.0.1" />
+ <dependency groupId="org.apache.wicket"
artifactId="wicket-extensions" version="1.3.0-SNAPSHOT">
+ <exclusion groupId="cglib" artifactid="cglib-nodep" />
+ <exclusion groupId="asm" artifactId="asm" />
+ <exclusion groupId="commons-collections"
artifactId="commons-collections" />
+ </dependency>
+ <dependency groupId="org.apache.wicket"
artifactId="wicket-datetime" version="1.3.0-SNAPSHOT">
+ </dependency>
+ <remoterepository refid="wicketstuff.org"/>
+ </artifact:dependencies>
+ <copy todir="${example.tmp.lib.dir}">
+ <fileset refid="wicket.fileset" />
+ <mapper classpathref="maven-ant-tasks.classpath"
classname="org.apache.maven.artifact.ant.VersionMapper"
from="${wicket.versions}" to="flatten" />
+ </copy>
+ </target>
+
+</project>
Property changes on: trunk/examples/wicket/build.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/resources/META-INF/application.xml
===================================================================
--- trunk/examples/wicket/resources/META-INF/application.xml (rev
0)
+++ trunk/examples/wicket/resources/META-INF/application.xml 2008-02-04 13:32:52 UTC (rev
7355)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/application_5.xsd"
+ version="5">
+
+ <display-name>Seam Booking</display-name>
+
+ <module>
+ <web>
+ <web-uri>jboss-seam-wicket.war</web-uri>
+ <context-root>/seam-wicket</context-root>
+ </web>
+ </module>
+
+ <module>
+ <ejb>jboss-seam-wicket.jar</ejb>
+ </module>
+
+ <module>
+ <ejb>jboss-seam.jar</ejb>
+ </module>
+
+</application>
Property changes on: trunk/examples/wicket/resources/META-INF/application.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/resources/META-INF/ejb-jar.xml
===================================================================
--- trunk/examples/wicket/resources/META-INF/ejb-jar.xml (rev 0)
+++ trunk/examples/wicket/resources/META-INF/ejb-jar.xml 2008-02-04 13:32:52 UTC (rev
7355)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ version="3.0">
+
+ <interceptors>
+ <interceptor>
+
<interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
+ </interceptor>
+ </interceptors>
+
+ <assembly-descriptor>
+ <interceptor-binding>
+ <ejb-name>*</ejb-name>
+
<interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
+ </interceptor-binding>
+ </assembly-descriptor>
+
+</ejb-jar>
Added: trunk/examples/wicket/resources/META-INF/jboss-app.xml
===================================================================
--- trunk/examples/wicket/resources/META-INF/jboss-app.xml (rev
0)
+++ trunk/examples/wicket/resources/META-INF/jboss-app.xml 2008-02-04 13:32:52 UTC (rev
7355)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!DOCTYPE jboss-app
+ PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
+
+<jboss-app>
+ <loader-repository>
+ seam.jboss.org:loader=seam-wicket
+ </loader-repository>
+</jboss-app>
\ No newline at end of file
Property changes on: trunk/examples/wicket/resources/META-INF/jboss-app.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/resources/META-INF/persistence.xml
===================================================================
--- trunk/examples/wicket/resources/META-INF/persistence.xml (rev
0)
+++ trunk/examples/wicket/resources/META-INF/persistence.xml 2008-02-04 13:32:52 UTC (rev
7355)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="bookingDatabase">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>java:/bookingDatasource</jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto"
value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <!-- These are the default for JBoss EJB3, but not for HEM: -->
+ <property name="hibernate.cache.provider_class"
value="org.hibernate.cache.HashtableCacheProvider"/>
+ <property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
Property changes on: trunk/examples/wicket/resources/META-INF/persistence.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/resources/WEB-INF/components.xml
===================================================================
--- trunk/examples/wicket/resources/WEB-INF/components.xml (rev
0)
+++ trunk/examples/wicket/resources/WEB-INF/components.xml 2008-02-04 13:32:52 UTC (rev
7355)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components
xmlns="http://jboss.com/products/seam/components"
+
xmlns:core="http://jboss.com/products/seam/core"
+
xmlns:security="http://jboss.com/products/seam/security"
+
xmlns:transaction="http://jboss.com/products/seam/transaction"
+
xmlns:web="http://jboss.com/products/seam/web"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation=
+ "http://jboss.com/products/seam/core
http://jboss.com/products/seam/core-2.0.xsd
+
http://jboss.com/products/seam/transaction
http://jboss.com/products/seam/transaction-2.0.xsd
+
http://jboss.com/products/seam/web
http://jboss.com/products/seam/web-2.0.xsd
+
http://jboss.com/products/seam/security
http://jboss.com/products/seam/security-2.0.xsd
+
http://jboss.com/products/seam/components
http://jboss.com/products/seam/components-2.0.xsd">
+
+ <core:init jndi-pattern="@jndiPattern@" debug="true"/>
+
+ <core:manager conversation-timeout="120000"
+ concurrent-request-timeout="500"
+ conversation-id-parameter="cid"/>
+
+ <transaction:ejb-transaction/>
+
+ <security:identity
authenticate-method="#{authenticator.authenticate}"/>
+
+</components>
Property changes on: trunk/examples/wicket/resources/WEB-INF/components.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/resources/WEB-INF/pages.xml
===================================================================
--- trunk/examples/wicket/resources/WEB-INF/pages.xml (rev 0)
+++ trunk/examples/wicket/resources/WEB-INF/pages.xml 2008-02-04 13:32:52 UTC (rev 7355)
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pages
xmlns="http://jboss.com/products/seam/pages"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://jboss.com/products/seam/pages
http://jboss.com/products/seam/pages-2.0.xsd"
+
+ no-conversation-view-id="/main.xhtml"
+ login-view-id="/home.xhtml">
+
+ <page view-id="/register.xhtml">
+
+ <action if="#{validation.failed}"
+ execute="#{register.invalid}"/>
+
+ <navigation>
+ <rule if="#{register.registered}">
+ <redirect view-id="/home.xhtml"/>
+ </rule>
+ </navigation>
+
+ </page>
+
+ <page view-id="/home.xhtml">
+
+ <navigation>
+ <rule if="#{identity.loggedIn}">
+ <redirect view-id="/main.xhtml"/>
+ </rule>
+ </navigation>
+
+ </page>
+
+ <page view-id="/password.xhtml"
+ login-required="true">
+
+ <navigation>
+ <rule if="#{changePassword.changed}">
+ <redirect view-id="/main.xhtml"/>
+ </rule>
+ </navigation>
+
+ </page>
+
+ <page view-id="/main.xhtml"
+ login-required="true">
+
+ <navigation from-action="#{hotelBooking.selectHotel(hot)}">
+ <redirect view-id="/hotel.xhtml"/>
+ </navigation>
+
+ <navigation from-action="#{bookingList.cancel}">
+ <redirect/>
+ </navigation>
+
+ </page>
+
+ <page view-id="/hotel.xhtml"
+ conversation-required="true"
+ login-required="true">
+
+ <description>View hotel: #{hotel.name}</description>
+
+ <navigation from-action="#{hotelBooking.bookHotel}">
+ <redirect view-id="/book.xhtml"/>
+ </navigation>
+
+ </page>
+
+ <page view-id="/book.xhtml"
+ conversation-required="true"
+ login-required="true">
+
+ <description>Book hotel: #{hotel.name}</description>
+
+ <navigation from-action="#{hotelBooking.setBookingDetails}">
+ <rule if="#{hotelBooking.bookingValid}">
+ <redirect view-id="/confirm.xhtml"/>
+ </rule>
+ </navigation>
+
+ </page>
+
+ <page view-id="/confirm.xhtml"
+ conversation-required="true"
+ login-required="true">
+
+ <description>Confirm booking: #{booking.description}</description>
+
+ <navigation from-action="#{hotelBooking.confirm}">
+ <redirect view-id="/main.xhtml"/>
+ </navigation>
+
+ </page>
+
+ <page view-id="*">
+
+ <navigation from-action="#{identity.logout}">
+ <redirect view-id="/home.xhtml"/>
+ </navigation>
+
+ <navigation from-action="#{hotelBooking.cancel}">
+ <redirect view-id="/main.xhtml"/>
+ </navigation>
+
+ </page>
+
+ <exception class="org.jboss.seam.security.NotLoggedInException">
+ <redirect view-id="/home.xhtml">
+ <message severity="warn">You must be logged in to use this
feature</message>
+ </redirect>
+ </exception>
+
+</pages>
Property changes on: trunk/examples/wicket/resources/WEB-INF/pages.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/resources/WEB-INF/web.xml
===================================================================
--- trunk/examples/wicket/resources/WEB-INF/web.xml (rev 0)
+++ trunk/examples/wicket/resources/WEB-INF/web.xml 2008-02-04 13:32:52 UTC (rev 7355)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5"
+
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <display-name>Seam Booking Example</display-name>
+
+ <!-- Seam -->
+
+ <listener>
+ <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>Seam Resource Servlet</servlet-name>
+
<servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Seam Resource Servlet</servlet-name>
+ <url-pattern>/seam/resource/*</url-pattern>
+ </servlet-mapping>
+
+ <filter>
+ <filter-name>Seam Filter</filter-name>
+ <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>Seam Filter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <filter>
+ <filter-name>wicket-booking</filter-name>
+ <filter-class>
+ org.apache.wicket.protocol.http.WicketFilter
+ </filter-class>
+ <init-param>
+ <param-name>applicationClassName</param-name>
+ <param-value>
+ org.jboss.seam.example.wicket.WicketBookingApplication
+ </param-value>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>wicket-booking</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <!-- JSF -->
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+
+</web-app>
Property changes on: trunk/examples/wicket/resources/WEB-INF/web.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/resources/components.properties
===================================================================
--- trunk/examples/wicket/resources/components.properties (rev 0)
+++ trunk/examples/wicket/resources/components.properties 2008-02-04 13:32:52 UTC (rev
7355)
@@ -0,0 +1 @@
+jndiPattern #{ejbName}/local
\ No newline at end of file
Property changes on: trunk/examples/wicket/resources/components.properties
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/resources/import.sql
===================================================================
--- trunk/examples/wicket/resources/import.sql (rev 0)
+++ trunk/examples/wicket/resources/import.sql 2008-02-04 13:32:52 UTC (rev 7355)
@@ -0,0 +1,22 @@
+insert into Customer (username, password, name) values ('gavin',
'foobar', 'Gavin King')
+insert into Customer (username, password, name) values ('demo', 'demo',
'Demo User')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (1, 120,
'Marriott Courtyard', 'Tower Place, Buckhead', 'Atlanta',
'GA', '30305', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (2, 180,
'Doubletree', 'Tower Place, Buckhead', 'Atlanta', 'GA',
'30305', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (3, 450,
'W Hotel', 'Union Square, Manhattan', 'NY', 'NY',
'10011', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (4, 450,
'W Hotel', 'Lexington Ave, Manhattan', 'NY', 'NY',
'10011', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (5, 250,
'Hotel Rouge', '1315 16th Street NW', 'Washington', 'DC',
'20036', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (6, 300,
'70 Park Avenue Hotel', '70 Park Avenue', 'NY', 'NY',
'10011', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (8, 300,
'Conrad Miami', '1395 Brickell Ave', 'Miami', 'FL',
'33131', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (9, 80,
'Sea Horse Inn', '2106 N Clairemont Ave', 'Eau Claire',
'WI', '54703', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (10, 90,
'Super 8 Eau Claire Campus Area', '1151 W Macarthur Ave', 'Eau
Claire', 'WI', '54701', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (11, 160,
'Marriot Downtown', '55 Fourth Street', 'San Francisco',
'CA', '94103', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (12, 200,
'Hilton Diagonal Mar', 'Passeig del Taulat 262-264', 'Barcelona',
'Catalunya', '08019', 'Spain')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (13, 210,
'Hilton Tel Aviv', 'Independence Park', 'Tel Aviv', '',
'63405', 'Israel')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (14, 240,
'InterContinental Tokyo Bay', 'Takeshiba Pier', 'Tokyo',
'', '105', 'Japan')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (15, 130,
'Hotel Beaulac', ' Esplanade L�opold-Robert 2', 'Neuchatel',
'', '2000', 'Switzerland')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (16, 140,
'Conrad Treasury Place', 'William & George Streets',
'Brisbane', 'QLD', '4001', 'Australia')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (17, 230,
'Ritz Carlton', '1228 Sherbrooke St', 'West Montreal',
'Quebec', 'H3G1H6', 'Canada')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (18, 460,
'Ritz Carlton', 'Peachtree Rd, Buckhead', 'Atlanta', 'GA',
'30326', 'USA')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (19, 220,
'Swissotel', '68 Market Street', 'Sydney', 'NSW',
'2000', 'Australia')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (20, 250,
'Meli� White House', 'Albany Street', 'Regents Park London',
'', 'NW13UP', 'Great Britain')
+insert into Hotel (id, price, name, address, city, state, zip, country) values (21, 210,
'Hotel Allegro', '171 West Randolph Street', 'Chicago',
'IL', '60601', 'USA')
Property changes on: trunk/examples/wicket/resources/import.sql
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/resources/jboss-seam-booking-ds.xml
===================================================================
--- trunk/examples/wicket/resources/jboss-seam-booking-ds.xml (rev
0)
+++ trunk/examples/wicket/resources/jboss-seam-booking-ds.xml 2008-02-04 13:32:52 UTC (rev
7355)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE datasources
+ PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
+
+<datasources>
+ <local-tx-datasource>
+ <jndi-name>bookingDatasource</jndi-name>
+ <connection-url>jdbc:hsqldb:.</connection-url>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+ <user-name>sa</user-name>
+ <password></password>
+ </local-tx-datasource>
+</datasources>
+
Property changes on: trunk/examples/wicket/resources/jboss-seam-booking-ds.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/resources/messages.properties
===================================================================
--- trunk/examples/wicket/resources/messages.properties (rev 0)
+++ trunk/examples/wicket/resources/messages.properties 2008-02-04 13:32:52 UTC (rev
7355)
@@ -0,0 +1,50 @@
+javax.faces.component.UIInput.CONVERSION=value could not be converted to the expected
type
+javax.faces.component.UIInput.REQUIRED=value is required
+javax.faces.component.UIInput.REQUIRED_detail=value is required
+javax.faces.component.UIInput.UPDATE=an error occurred when processing your submitted
information
+javax.faces.component.UISelectOne.INVALID=value is not valid
+javax.faces.component.UISelectMany.INVALID=value is not valid
+
+javax.faces.converter.BigDecimalConverter.DECIMAL=value must be a number
+javax.faces.converter.BigDecimalConverter.DECIMAL_detail=value must be a signed decimal
number consisting of zero or more digits, optionally followed by a decimal point and
fraction, eg. {1}
+javax.faces.converter.BigIntegerConverter.BIGINTEGER=value must be a number
+javax.faces.converter.BigIntegerConverter.BIGINTEGER_detail=value must be a signed
integer number consisting of zero or more digits
+javax.faces.converter.BooleanConverter.BOOLEAN=value must be true or false
+javax.faces.converter.BooleanConverter.BOOLEAN_detail=value must be true or false (any
value other than true will evaluate to false)
+javax.faces.converter.ByteConverter.BYTE=value must be a number between 0 and 255
+javax.faces.converter.ByteConverter.BYTE_detail=value must be a number between 0 and 255
+javax.faces.converter.CharacterConverter.CHARACTER=value must be a character
+javax.faces.converter.CharacterConverter.CHARACTER_detail=value must be a valid ASCII
character
+javax.faces.convert.DateTimeConverter.CONVERSION value must be a datetime
+javax.faces.convert.DateTimeConverter.CONVERSION_detail value must be a datetime
+javax.faces.converter.DateTimeConverter.DATE=value must be a date
+javax.faces.converter.DateTimeConverter.DATE_detail=value must be a date, eg. {1}
+javax.faces.converter.DateTimeConverter.TIME=value must be a time
+javax.faces.converter.DateTimeConverter.TIME_detail=value must be a time, eg. {1}
+javax.faces.converter.DateTimeConverter.DATETIME=value must be a date and time
+javax.faces.converter.DateTimeConverter.DATETIME_detail=value must be a date and time,
eg. {1}
+javax.faces.converter.DateTimeConverter.PATTERN_TYPE=a pattern or type attribute must be
specified to convert the value
+javax.faces.converter.DoubleConverter.DOUBLE=value must be a number
+javax.faces.converter.DoubleConverter.DOUBLE_detail=value must be a number between
4.9E-324 and 1.7976931348623157E308
+javax.faces.converter.EnumConverter.ENUM=value must be convertible to an enum
+javax.faces.converter.EnumConverter.ENUM_detail=value must be convertible to an enum or
from the enum that contains the constant {1}
+javax.faces.converter.EnumConverter.ENUM_NO_CLASS=value must be convertible to an enum or
from the enum, but no enum class provided
+javax.faces.converter.EnumConverter.ENUM_NO_CLASS_detail=value must be convertible to an
enum or from the enum, but no enum class provided
+javax.faces.converter.FloatConverter.FLOAT=value must be a number
+javax.faces.converter.FloatConverter.FLOAT_detail=value must be a number between 1.4E-45
and 3.4028235E38
+javax.faces.converter.IntegerConverter.INTEGER=value must be a number
+javax.faces.converter.IntegerConverter.INTEGER_detail=value must be a number between
-2147483648 and 2147483647
+javax.faces.converter.LongConverter.LONG=value must be a number
+javax.faces.converter.LongConverter.LONG_detail=must be a number between
-9223372036854775808 and 9223372036854775807
+javax.faces.converter.NumberConverter.CURRENCY=value must be a currency amount
+javax.faces.converter.NumberConverter.CURRENCY_detail=value must be a currency amount,
eg. {1}
+javax.faces.converter.NumberConverter.PERCENT=value must be a percentage amount
+javax.faces.converter.NumberConverter.PERCENT_detail=value must be a percentage amount,
eg. {1}
+javax.faces.converter.NumberConverter.NUMBER=value must be a number
+javax.faces.converter.NumberConverter.NUMBER_detail=value must be a number
+javax.faces.converter.NumberConverter.PATTERN=value must be a number
+javax.faces.converter.NumberConverter.PATTERN_detail=value must be a number
+javax.faces.converter.ShortConverter.SHORT=value must be a number
+javax.faces.converter.ShortConverter.SHORT_detail=value must be a number between -32768
and 32767
+
+
Added: trunk/examples/wicket/resources/seam.properties
===================================================================
Property changes on: trunk/examples/wicket/resources/seam.properties
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Authenticator.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Authenticator.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Authenticator.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,9 @@
+package org.jboss.seam.example.wicket.action;
+
+import javax.ejb.Local;
+
+@Local
+public interface Authenticator
+{
+ boolean authenticate();
+}
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/AuthenticatorAction.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/AuthenticatorAction.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/AuthenticatorAction.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,41 @@
+package org.jboss.seam.example.wicket.action;
+
+import static org.jboss.seam.ScopeType.SESSION;
+
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.security.Identity;
+
+@Stateless
+@Name("authenticator")
+public class AuthenticatorAction implements Authenticator
+{
+ @PersistenceContext
+ private EntityManager em;
+
+ @Out(required=false, scope = SESSION)
+ private User user;
+
+ public boolean authenticate()
+ {
+ List results = em.createQuery("select u from User u where
u.username=#{identity.username} and u.password=#{identity.password}")
+ .getResultList();
+
+ if ( results.size()==0 )
+ {
+ return false;
+ }
+ else
+ {
+ user = (User) results.get(0);
+ return true;
+ }
+ }
+
+}
Added: trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Booking.java
===================================================================
--- trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Booking.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Booking.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,190 @@
+//$Id: Booking.java,v 1.15 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.util.Date;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.hibernate.validator.Length;
+import org.hibernate.validator.NotNull;
+import org.hibernate.validator.Pattern;
+import org.jboss.seam.annotations.Name;
+
+@Entity
+@Name("booking")
+public class Booking implements Serializable
+{
+ private Long id;
+ private User user;
+ private Hotel hotel;
+ private Date checkinDate;
+ private Date checkoutDate;
+ private String creditCard;
+ private String creditCardName;
+ private String creditCardExpiryMonth;
+ private int creditCardExpiryYear;
+ private boolean smoking;
+ private int beds;
+
+ public Booking() {}
+
+ public Booking(Hotel hotel, User user)
+ {
+ this.hotel = hotel;
+ this.user = user;
+ }
+
+ @Transient
+ public BigDecimal getTotal()
+ {
+ return hotel.getPrice().multiply( new BigDecimal( getNights() ) );
+ }
+
+ @Transient
+ public int getNights()
+ {
+ return (int) ( checkoutDate.getTime() - checkinDate.getTime() ) / 1000 / 60 / 60 /
24;
+ }
+
+ @Id @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @NotNull
+ @Basic @Temporal(TemporalType.DATE)
+ public Date getCheckinDate()
+ {
+ return checkinDate;
+ }
+ public void setCheckinDate(Date datetime)
+ {
+ this.checkinDate = datetime;
+ }
+
+ @ManyToOne @NotNull
+ public Hotel getHotel()
+ {
+ return hotel;
+ }
+ public void setHotel(Hotel hotel)
+ {
+ this.hotel = hotel;
+ }
+
+ @ManyToOne @NotNull
+ public User getUser()
+ {
+ return user;
+ }
+ public void setUser(User user)
+ {
+ this.user = user;
+ }
+
+ @Basic @Temporal(TemporalType.DATE)
+ @NotNull
+ public Date getCheckoutDate()
+ {
+ return checkoutDate;
+ }
+ public void setCheckoutDate(Date checkoutDate)
+ {
+ this.checkoutDate = checkoutDate;
+ }
+
+ @NotNull(message="Credit card number is required")
+ @Length(min=16, max=16, message="Credit card number must 16 digits long")
+ @Pattern(regex="^\\d*$", message="Credit card number must be
numeric")
+ public String getCreditCard()
+ {
+ return creditCard;
+ }
+
+ public void setCreditCard(String creditCard)
+ {
+ this.creditCard = creditCard;
+ }
+
+ @Transient
+ public String getDescription()
+ {
+ DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
+ return hotel==null ? null : hotel.getName() +
+ ", " + df.format( getCheckinDate() ) +
+ " to " + df.format( getCheckoutDate() );
+ }
+
+ public boolean isSmoking()
+ {
+ return smoking;
+ }
+
+ public void setSmoking(boolean smoking)
+ {
+ this.smoking = smoking;
+ }
+
+ public int getBeds()
+ {
+ return beds;
+ }
+
+ public void setBeds(int beds)
+ {
+ this.beds = beds;
+ }
+ @NotNull(message="Credit card name is required")
+ @Length(min=3, max=70, message="Credit card name is required")
+ public String getCreditCardName()
+ {
+ return creditCardName;
+ }
+
+ public void setCreditCardName(String creditCardName)
+ {
+ this.creditCardName = creditCardName;
+ }
+
+ public String getCreditCardExpiryMonth()
+ {
+ return creditCardExpiryMonth;
+ }
+
+ public void setCreditCardExpiryMonth(String creditCardExpiryMonth)
+ {
+ this.creditCardExpiryMonth = creditCardExpiryMonth;
+ }
+
+ public int getCreditCardExpiryYear()
+ {
+ return creditCardExpiryYear;
+ }
+
+ public void setCreditCardExpiryYear(int creditCardExpiryYear)
+ {
+ this.creditCardExpiryYear = creditCardExpiryYear;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Booking(" + user + ","+ hotel + ")";
+ }
+
+}
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Booking.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/BookingList.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/BookingList.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/BookingList.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,14 @@
+//$Id: BookingList.java,v 1.7 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import javax.ejb.Local;
+
+@Local
+public interface BookingList
+{
+ public void getBookings();
+ public Booking getBooking();
+ public void cancel();
+ public void cancel(Booking booking);
+ public void destroy();
+}
\ No newline at end of file
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/BookingList.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/BookingListAction.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/BookingListAction.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/BookingListAction.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,82 @@
+//$Id: BookingListAction.java,v 1.23 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import static javax.ejb.TransactionAttributeType.REQUIRES_NEW;
+import static org.jboss.seam.ScopeType.SESSION;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Observer;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.log.Log;
+
+@Stateful
+@Scope(SESSION)
+@Name("bookingList")
+(a)Restrict("#{identity.loggedIn}")
+@TransactionAttribute(REQUIRES_NEW)
+public class BookingListAction implements BookingList, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @In
+ private User user;
+
+ @Out
+ private List<Booking> bookings;
+
+ private Booking booking;
+
+ @Logger
+ private Log log;
+
+ @Factory
+ @Observer("bookingConfirmed")
+ public void getBookings()
+ {
+ bookings = em.createQuery("select b from Booking b where b.user.username =
:username order by b.checkinDate")
+ .setParameter("username", user.getUsername())
+ .getResultList();
+ }
+
+ public void cancel()
+ {
+ log.info("Cancel booking: #{bookingList.booking.id} for
#{user.username}");
+ Booking cancelled = em.find(Booking.class, booking.getId());
+ if (cancelled!=null) em.remove( cancelled );
+ getBookings();
+ FacesMessages.instance().add("Booking cancelled for confirmation number
#{bookingList.booking.id}");
+ }
+
+ // TODO replace this with @Out in Wicket
+ public void cancel(Booking booking)
+ {
+ this.booking = booking;
+ cancel();
+ }
+
+ public Booking getBooking()
+ {
+ return booking;
+ }
+
+ @Remove
+ public void destroy() {}
+}
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/BookingListAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/ChangePassword.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/ChangePassword.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/ChangePassword.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,12 @@
+//$Id: ChangePassword.java,v 1.5 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import javax.ejb.Local;
+
+@Local
+public interface ChangePassword
+{
+ public void changePassword();
+
+ public void destroy();
+}
\ No newline at end of file
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/ChangePassword.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/ChangePasswordAction.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/ChangePasswordAction.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/ChangePasswordAction.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,40 @@
+//$Id: ChangePasswordAction.java,v 1.22 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import static org.jboss.seam.ScopeType.EVENT;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.security.Restrict;
+
+@Stateful
+@Scope(EVENT)
+@Name("changePassword")
+(a)Restrict("#{identity.loggedIn}")
+public class ChangePasswordAction implements ChangePassword
+{
+ @In @Out
+ private User user;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ //@In
+ //private FacesMessages facesMessages;
+
+ public void changePassword()
+ {
+ user = em.merge(user);
+ //facesMessages.add("Password updated");
+ }
+
+ @Remove
+ public void destroy() {}
+}
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/ChangePasswordAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Hotel.java
===================================================================
--- trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Hotel.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Hotel.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,114 @@
+//$Id: Hotel.java,v 1.13 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+import org.hibernate.validator.Length;
+import org.hibernate.validator.NotNull;
+import org.jboss.seam.annotations.Name;
+
+@Entity
+@Name("hotel")
+public class Hotel implements Serializable
+{
+ private Long id;
+ private String name;
+ private String address;
+ private String city;
+ private String state;
+ private String zip;
+ private String country;
+ private BigDecimal price;
+
+ @Id @GeneratedValue
+ public Long getId()
+ {
+ return id;
+ }
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @Length(max=50) @NotNull
+ public String getName()
+ {
+ return name;
+ }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @Length(max=100) @NotNull
+ public String getAddress()
+ {
+ return address;
+ }
+ public void setAddress(String address)
+ {
+ this.address = address;
+ }
+
+ @Length(max=40) @NotNull
+ public String getCity()
+ {
+ return city;
+ }
+ public void setCity(String city)
+ {
+ this.city = city;
+ }
+
+ @Length(min=4, max=6) @NotNull
+ public String getZip()
+ {
+ return zip;
+ }
+ public void setZip(String zip)
+ {
+ this.zip = zip;
+ }
+
+ @Length(min=2, max=10) @NotNull
+ public String getState()
+ {
+ return state;
+ }
+ public void setState(String state)
+ {
+ this.state = state;
+ }
+
+ @Length(min=2, max=40) @NotNull
+ public String getCountry()
+ {
+ return country;
+ }
+ public void setCountry(String country)
+ {
+ this.country = country;
+ }
+
+ @Column(precision=6, scale=2)
+ public BigDecimal getPrice()
+ {
+ return price;
+ }
+ public void setPrice(BigDecimal price)
+ {
+ this.price = price;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Hotel(" + name + "," + address + "," + city +
"," + zip + ")";
+ }
+}
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Hotel.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBooking.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBooking.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBooking.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,22 @@
+//$Id: HotelBooking.java,v 1.14 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import javax.ejb.Local;
+
+@Local
+public interface HotelBooking
+{
+ public Hotel selectHotel(Long hotelId);
+
+ public void bookHotel();
+
+ public void setBookingDetails();
+ public boolean isBookingValid();
+
+ public void confirm();
+
+ public void cancel();
+
+ public void destroy();
+
+}
\ No newline at end of file
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBooking.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBookingAction.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBookingAction.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBookingAction.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,110 @@
+//$Id: HotelBookingAction.java,v 1.53 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import static javax.persistence.PersistenceContextType.EXTENDED;
+
+import java.util.Calendar;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.End;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.core.Events;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.log.Log;
+
+@Stateful
+@Name("hotelBooking")
+(a)Restrict("#{identity.loggedIn}")
+public class HotelBookingAction implements HotelBooking
+{
+
+ @PersistenceContext(type=EXTENDED)
+ private EntityManager em;
+
+ @In
+ private User user;
+
+ @Out
+ private Hotel hotel;
+
+ @In(required=false)
+ @Out(required=false)
+ private Booking booking;
+
+ //@In
+ //private FacesMessages facesMessages;
+
+ @In
+ private Events events;
+
+ @Logger
+ private Log log;
+
+ private boolean bookingValid;
+
+ // TODO Use outjection
+ @Begin
+ public Hotel selectHotel(Long hotelId)
+ {
+ hotel = em.find(Hotel.class, hotelId);
+ return hotel;
+ }
+
+ public void bookHotel()
+ {
+ booking = new Booking(hotel, user);
+ Calendar calendar = Calendar.getInstance();
+ booking.setCheckinDate( calendar.getTime() );
+ calendar.add(Calendar.DAY_OF_MONTH, 1);
+ booking.setCheckoutDate( calendar.getTime() );
+ }
+
+ public void setBookingDetails()
+ {
+ Calendar calendar = Calendar.getInstance();
+ calendar.add(Calendar.DAY_OF_MONTH, -1);
+ if ( booking.getCheckinDate().before( calendar.getTime() ) )
+ {
+ //facesMessages.addToControl("checkinDate", "Check in date must
be a future date");
+ bookingValid=false;
+ }
+ else if ( !booking.getCheckinDate().before( booking.getCheckoutDate() ) )
+ {
+ //facesMessages.addToControl("checkoutDate", "Check out date must
be later than check in date");
+ bookingValid=false;
+ }
+ else
+ {
+ bookingValid=true;
+ }
+ }
+
+ public boolean isBookingValid()
+ {
+ return bookingValid;
+ }
+
+ @End
+ public void confirm()
+ {
+ em.persist(booking);
+ //facesMessages.add("Thank you, #{user.name}, your confimation number for
#{hotel.name} is #{booking.id}");
+ log.info("New booking: #{booking.id} for #{user.username}");
+ events.raiseTransactionSuccessEvent("bookingConfirmed");
+ }
+
+ @End
+ public void cancel() {}
+
+ @Remove
+ public void destroy() {}
+}
\ No newline at end of file
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelBookingAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelSearching.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelSearching.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelSearching.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,23 @@
+//$Id: HotelSearching.java,v 1.12 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+@Local
+public interface HotelSearching
+{
+
+ public String getSearchString();
+ public void setSearchString(String searchString);
+
+ public String getSearchPattern();
+
+ public List<Hotel> getHotels();
+
+ public void find();
+
+ public void destroy();
+
+}
\ No newline at end of file
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelSearching.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelSearchingAction.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelSearchingAction.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelSearchingAction.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,68 @@
+//$Id: HotelSearchingAction.java,v 1.20 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Factory;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.datamodel.DataModel;
+import org.jboss.seam.annotations.security.Restrict;
+
+@Stateful
+@Name("hotelSearch")
+(a)Scope(ScopeType.SESSION)
+(a)Restrict("#{identity.loggedIn}")
+public class HotelSearchingAction implements HotelSearching
+{
+
+ @PersistenceContext
+ private EntityManager em;
+
+ private String searchString;
+
+ private List<Hotel> hotels = new ArrayList<Hotel>();
+
+ public void find()
+ {
+ queryHotels();
+ }
+
+ private void queryHotels()
+ {
+ hotels = em.createQuery("select h from Hotel h where lower(h.name) like
#{pattern} or lower(h.city) like #{pattern} or lower(h.zip) like #{pattern} or
lower(h.address) like #{pattern}")
+ .getResultList();
+ }
+
+ @Factory(value="pattern", scope=ScopeType.EVENT)
+ public String getSearchPattern()
+ {
+ return searchString==null ?
+ "%" : '%' + searchString.toLowerCase().replace('*',
'%') + '%';
+ }
+
+ public String getSearchString()
+ {
+ return searchString;
+ }
+
+ public void setSearchString(String searchString)
+ {
+ this.searchString = searchString;
+ }
+
+ public List<Hotel> getHotels()
+ {
+ return hotels;
+ }
+
+ @Remove
+ public void destroy() {}
+}
\ No newline at end of file
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/HotelSearchingAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Register.java
===================================================================
--- trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Register.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Register.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,16 @@
+//$Id: Register.java,v 1.5 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import javax.ejb.Local;
+
+@Local
+public interface Register
+{
+ public void register();
+ public void invalid();
+ public String getVerify();
+ public void setVerify(String verify);
+ public boolean isRegistered();
+
+ public void destroy();
+}
\ No newline at end of file
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/Register.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/RegisterAction.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/RegisterAction.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/RegisterAction.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,79 @@
+//$Id: RegisterAction.java,v 1.23 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import static org.jboss.seam.ScopeType.EVENT;
+
+import java.util.List;
+
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+@Stateful
+@Scope(EVENT)
+@Name("register")
+public class RegisterAction implements Register
+{
+ @In
+ private User user;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ //@In
+ //private FacesMessages facesMessages;
+
+ private String verify;
+
+ private boolean registered;
+
+ public void register()
+ {
+ if ( user.getPassword().equals(verify) )
+ {
+ List existing = em.createQuery("select u.username from User u where
u.username=#{user.username}")
+ .getResultList();
+ if (existing.size()==0)
+ {
+ em.persist(user);
+ //facesMessages.add("Successfully registered as
#{user.username}");
+ registered = true;
+ }
+ else
+ {
+ //facesMessages.addToControl("username", "Username
#{user.username} already exists");
+ }
+ }
+ else
+ {
+ //facesMessages.addToControl("verify", "Re-enter your
password");
+ verify=null;
+ }
+ }
+
+ public void invalid()
+ {
+ //facesMessages.add("Please try again");
+ }
+
+ public boolean isRegistered()
+ {
+ return registered;
+ }
+ public String getVerify()
+ {
+ return verify;
+ }
+ public void setVerify(String verify)
+ {
+ this.verify = verify;
+ }
+
+ @Remove
+ public void destroy() {}
+}
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/RegisterAction.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/User.java
===================================================================
--- trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/User.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/User.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,76 @@
+//$Id: User.java,v 1.8 2007/06/27 00:06:49 gavin Exp $
+package org.jboss.seam.example.wicket.action;
+
+import static org.jboss.seam.ScopeType.SESSION;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.hibernate.validator.Length;
+import org.hibernate.validator.NotNull;
+import org.hibernate.validator.Pattern;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+@Entity
+@Name("user")
+@Scope(SESSION)
+@Table(name="Customer")
+public class User implements Serializable
+{
+ private String username;
+ private String password;
+ private String name;
+
+ public User(String name, String password, String username)
+ {
+ this.name = name;
+ this.password = password;
+ this.username = username;
+ }
+
+ public User() {}
+
+ @NotNull
+ @Length(max=100)
+ public String getName()
+ {
+ return name;
+ }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @NotNull
+ @Length(min=5, max=15)
+ public String getPassword()
+ {
+ return password;
+ }
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ @Id
+ @Length(min=4, max=15)
+ @Pattern(regex="^\\w*$", message="not a valid username")
+ public String getUsername()
+ {
+ return username;
+ }
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "User(" + username + ")";
+ }
+}
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/action/User.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/BookingTest.java
===================================================================
--- trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/BookingTest.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/BookingTest.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,288 @@
+//$Id: BookingTest.java,v 1.46 2007/07/16 06:45:47 gavin Exp $
+package org.jboss.seam.example.wicket.test;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.wicket.action.Booking;
+import org.jboss.seam.example.wicket.action.Hotel;
+import org.jboss.seam.example.wicket.action.HotelBooking;
+import org.jboss.seam.example.wicket.action.User;
+import org.jboss.seam.mock.SeamTest;
+import org.testng.annotations.Test;
+
+public class BookingTest extends SeamTest
+{
+
+ @Test
+ public void testBookHotel() throws Exception
+ {
+
+ new FacesRequest() {
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ Contexts.getSessionContext().set("user", new User("Gavin
King", "foobar", "gavin"));
+ setValue("#{identity.username}", "gavin");
+ setValue("#{identity.password}", "foobar");
+ invokeAction("#{identity.login}");
+ }
+
+ }.run();
+
+ new FacesRequest("/main.xhtml") {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{hotelSearch.searchString}", "Union Square");
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert invokeAction("#{hotelSearch.find}")==null;
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ DataModel hotels = (DataModel)
Contexts.getSessionContext().get("hotels");
+ assert hotels.getRowCount()==1;
+ assert ( (Hotel) hotels.getRowData() ).getCity().equals("NY");
+ assert getValue("#{hotelSearch.searchString}").equals("Union
Square");
+ assert !Manager.instance().isLongRunningConversation();
+ }
+
+ }.run();
+
+ String id = new FacesRequest("/main.xhtml") {
+
+ @Override
+ protected void invokeApplication() throws Exception {
+ HotelBooking hotelBooking = (HotelBooking)
getInstance("hotelBooking");
+ DataModel hotels = (DataModel)
Contexts.getSessionContext().get("hotels");
+ assert hotels.getRowCount()==1;
+ //hotelBooking.selectHotel( (Hotel) hotels.getRowData() );
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ Hotel hotel = (Hotel)
Contexts.getConversationContext().get("hotel");
+ assert hotel.getCity().equals("NY");
+ assert hotel.getZip().equals("10011");
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ }.run();
+
+ id = new FacesRequest("/hotel.xhtml", id) {
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeAction("#{hotelBooking.bookHotel}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{booking.user}")!=null;
+ assert getValue("#{booking.hotel}")!=null;
+ assert getValue("#{booking.creditCard}")==null;
+ assert getValue("#{booking.creditCardName}")==null;
+ Booking booking = (Booking)
Contexts.getConversationContext().get("booking");
+ assert
booking.getHotel()==Contexts.getConversationContext().get("hotel");
+ assert
booking.getUser()==Contexts.getSessionContext().get("user");
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ }.run();
+
+ new FacesRequest("/book.xhtml", id) {
+
+ @Override
+ protected void processValidations() throws Exception
+ {
+ validateValue("#{booking.creditCard}", "123");
+ assert isValidationFailure();
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ Iterator messages = FacesContext.getCurrentInstance().getMessages();
+ assert messages.hasNext();
+ assert ( (FacesMessage) messages.next() ).getSummary().equals("Credit
card number must 16 digits long");
+ assert !messages.hasNext();
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ @Override
+ protected void afterRequest()
+ {
+ assert !isInvokeApplicationBegun();
+ }
+
+ }.run();
+
+ new FacesRequest("/book.xhtml", id) {
+
+ @Override
+ protected void processValidations() throws Exception
+ {
+ validateValue("#{booking.creditCardName}", "");
+ assert isValidationFailure();
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ Iterator messages = FacesContext.getCurrentInstance().getMessages();
+ assert messages.hasNext();
+ assert ( (FacesMessage) messages.next() ).getSummary().equals("Credit
card name is required");
+ assert !messages.hasNext();
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ @Override
+ protected void afterRequest()
+ {
+ assert !isInvokeApplicationBegun();
+ }
+
+ }.run();
+
+ new FacesRequest("/book.xhtml", id) {
+
+ @Override @SuppressWarnings("deprecation")
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{booking.creditCard}", "1234567891021234");
+ setValue("#{booking.creditCardName}", "GAVIN KING");
+ setValue("#{booking.beds}", 2);
+ Date now = new Date();
+ setValue("#{booking.checkinDate}", now);
+ setValue("#{booking.checkoutDate}", now);
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert invokeAction("#{hotelBooking.setBookingDetails}")==null;
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ Iterator messages = FacesContext.getCurrentInstance().getMessages();
+ assert messages.hasNext();
+ FacesMessage message = (FacesMessage) messages.next();
+ assert message.getSummary().equals("Check out date must be later than
check in date");
+ assert !messages.hasNext();
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ @Override
+ protected void afterRequest()
+ {
+ assert isInvokeApplicationComplete();
+ }
+
+ }.run();
+
+ new FacesRequest("/book.xhtml", id) {
+
+ @Override @SuppressWarnings("deprecation")
+ protected void updateModelValues() throws Exception
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_MONTH, 2);
+ setValue("#{booking.checkoutDate}", cal.getTime() );
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeAction("#{hotelBooking.setBookingDetails}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert Manager.instance().isLongRunningConversation();
+ }
+
+ @Override
+ protected void afterRequest()
+ {
+ assert isInvokeApplicationComplete();
+ }
+
+ }.run();
+
+ new FacesRequest("/confirm.xhtml", id) {
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeAction("#{hotelBooking.confirm}");
+ }
+
+ @Override
+ protected void afterRequest()
+ {
+ assert isInvokeApplicationComplete();
+ }
+
+ }.run();
+
+ new NonFacesRequest("/main.xhtml") {
+
+ @Override
+ protected void renderResponse()
+ {
+ ListDataModel bookings = (ListDataModel) getInstance("bookings");
+ assert bookings.getRowCount()==1;
+ bookings.setRowIndex(0);
+ Booking booking = (Booking) bookings.getRowData();
+ assert booking.getHotel().getCity().equals("NY");
+ assert booking.getUser().getUsername().equals("gavin");
+ assert !Manager.instance().isLongRunningConversation();
+ }
+
+ }.run();
+
+ new FacesRequest("/main.xhtml") {
+
+ @Override
+ protected void invokeApplication()
+ {
+ ListDataModel bookings = (ListDataModel)
Contexts.getSessionContext().get("bookings");
+ bookings.setRowIndex(0);
+ invokeAction("#{bookingList.cancel}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ ListDataModel bookings = (ListDataModel)
Contexts.getSessionContext().get("bookings");
+ assert bookings.getRowCount()==0;
+ assert !Manager.instance().isLongRunningConversation();
+ }
+
+ }.run();
+
+ }
+
+}
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/BookingTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/ChangePasswordTest.java
===================================================================
---
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/ChangePasswordTest.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/ChangePasswordTest.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,138 @@
+//$Id: ChangePasswordTest.java,v 1.17 2007/07/16 06:45:47 gavin Exp $
+package org.jboss.seam.example.wicket.test;
+
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.wicket.action.User;
+import org.jboss.seam.mock.SeamTest;
+import org.testng.annotations.Test;
+
+public class ChangePasswordTest extends SeamTest
+{
+
+ @Test
+ public void testChangePassword() throws Exception
+ {
+
+ new FacesRequest() {
+
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ Contexts.getSessionContext().set("user", new User("Gavin
King", "foobar", "gavin"));
+ setValue("#{identity.username}", "gavin");
+ setValue("#{identity.password}", "foobar");
+ invokeMethod("#{identity.login}");
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void processValidations() throws Exception
+ {
+ validateValue("#{user.password}", "xxx");
+ assert isValidationFailure();
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("foobar");
+ assert !Manager.instance().isLongRunningConversation();
+ assert getValue("#{identity.loggedIn}").equals(true);
+
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{user.password}", "xxxyyy");
+ setValue("#{changePassword.verify}", "xxyyyx");
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert invokeAction("#{changePassword.changePassword}")==null;
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("foobar");
+ assert !Manager.instance().isLongRunningConversation();
+ assert getValue("#{identity.loggedIn}").equals(true);
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ setValue("#{user.password}", "xxxyyy");
+ setValue("#{changePassword.verify}", "xxxyyy");
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeMethod("#{changePassword.changePassword}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("xxxyyy");
+ assert !Manager.instance().isLongRunningConversation();
+ assert getValue("#{identity.loggedIn}").equals(true);
+
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ assert getValue("#{user.password}").equals("xxxyyy");
+ setValue("#{user.password}", "foobar");
+ setValue("#{changePassword.verify}", "foobar");
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeMethod("#{changePassword.changePassword}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("foobar");
+ assert !Manager.instance().isLongRunningConversation();
+ assert getValue("#{identity.loggedIn}").equals(true);
+
+ }
+
+ }.run();
+
+ }
+
+}
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/ChangePasswordTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/LoginTest.java
===================================================================
--- trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/LoginTest.java
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/LoginTest.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,115 @@
+//$Id: LoginTest.java,v 1.29 2007/07/16 06:45:47 gavin Exp $
+package org.jboss.seam.example.wicket.test;
+
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.web.Session;
+import org.jboss.seam.mock.SeamTest;
+import org.testng.annotations.Test;
+
+public class LoginTest extends SeamTest
+{
+
+ @Test
+ public void testLoginComponent() throws Exception
+ {
+ new ComponentTest() {
+
+ @Override
+ protected void testComponents() throws Exception
+ {
+ assert getValue("#{identity.loggedIn}").equals(false);
+ setValue("#{identity.username}", "gavin");
+ setValue("#{identity.password}", "foobar");
+ invokeMethod("#{identity.login}");
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("foobar");
+ assert getValue("#{identity.loggedIn}").equals(true);
+ invokeMethod("#{identity.logout}");
+ assert getValue("#{identity.loggedIn}").equals(false);
+ setValue("#{identity.username}", "gavin");
+ setValue("#{identity.password}", "tiger");
+ invokeMethod("#{identity.login}");
+ assert getValue("#{identity.loggedIn}").equals(false);
+ }
+
+ }.run();
+ }
+
+ @Test
+ public void testLogin() throws Exception
+ {
+
+ new FacesRequest() {
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert !isSessionInvalid();
+ assert getValue("#{identity.loggedIn}").equals(false);
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void updateModelValues() throws Exception
+ {
+ assert !isSessionInvalid();
+ setValue("#{identity.username}", "gavin");
+ setValue("#{identity.password}", "foobar");
+ }
+
+ @Override
+ protected void invokeApplication()
+ {
+ invokeAction("#{identity.login}");
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{user.name}").equals("Gavin King");
+ assert getValue("#{user.username}").equals("gavin");
+ assert getValue("#{user.password}").equals("foobar");
+ assert !Manager.instance().isLongRunningConversation();
+ assert getValue("#{identity.loggedIn}").equals(true);
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert !isSessionInvalid();
+ assert getValue("#{identity.loggedIn}").equals(true);
+ }
+
+ }.run();
+
+ new FacesRequest() {
+
+ @Override
+ protected void invokeApplication()
+ {
+ assert !Manager.instance().isLongRunningConversation();
+ assert !isSessionInvalid();
+ invokeMethod("#{identity.logout}");
+ assert Session.instance().isInvalid();
+ }
+
+ @Override
+ protected void renderResponse()
+ {
+ assert getValue("#{identity.loggedIn}").equals(false);
+ assert Session.instance().isInvalid();
+ }
+
+ }.run();
+
+ }
+
+}
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/LoginTest.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/testng.xml
===================================================================
--- trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/testng.xml
(rev 0)
+++
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/testng.xml 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,13 @@
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+
+<suite name="Hotel Booking" verbose="2"
parallel="false">
+
+ <test name="Hotel Booking">
+ <classes>
+ <class name="org.jboss.seam.example.booking.test.LoginTest"/>
+ <class name="org.jboss.seam.example.booking.test.BookingTest"/>
+ <class
name="org.jboss.seam.example.booking.test.ChangePasswordTest"/>
+ </classes>
+ </test>
+
+</suite>
\ No newline at end of file
Property changes on:
trunk/examples/wicket/src/action/org/jboss/seam/example/wicket/test/testng.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.html
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,74 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head></head>
+
+<body>
+
+<div wicket:id="body">
+
+<div class="section">
+ <h1>Book Hotel</h1>
+</div>
+
+<div class="section">
+ <div class="entry errors" wicket:id="messages" />
+
+ <div wicket:id="hotelView" />
+
+ <div style="clear:both"/>
+
+ <form wicket:id="booking">
+ <fieldset>
+
+ <div wicket:id="checkinDateBorder">
+ <span wicket:id="checkinDate" />
+ </div>
+
+ <div wicket:id="checkoutDateBorder">
+ <span wicket:id="checkoutDate" />
+ </div>
+
+ <div wicket:id="bedsBorder">
+ <select wicket:id="beds">
+ <option>One king-size bed</option>
+ </select>
+ </div>
+
+ <div wicket:id="smokingBorder">
+ <span wicket:id="smoking">
+ <input type="radio" value="Smoking" />
+ <input type="radio" value="Non Smoking" />
+ </span>
+ </div>
+
+ <div wicket:id="creditCardBorder">
+ <input wicket:id="creditCard" />
+ </div>
+
+ <div wicket:id="creditCardNameBorder">
+ <input wicket:id="creditCardName" />
+ </div>
+
+ <div wicket:id="creditCardExpiryBorder">
+ <select wicket:id="creditCardExpiryMonth">
+ <option>Jan</option>
+ </select>
+ <select wicket:id="creditCardExpiryYear">
+ <option>2005</option>
+ </select>
+ </div>
+
+ <div class="buttonBox">
+ <input type="submit" value="Proceed" />
+  
+ <input type="button" wicket:id="cancel"
value="Cancel" />
+ </div>
+
+ </fieldset>
+ </form>
+</div>
+
+</div>
+</body>
+</html>
+
Property changes on:
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.html
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jboss.seam.example.wicket;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.behavior.IBehavior;
+import org.apache.wicket.extensions.yui.calendar.DateField;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.RadioChoice;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.validation.ValidationError;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.example.wicket.action.Booking;
+import org.jboss.seam.example.wicket.action.HotelBooking;
+
+@Restrict
+public class Book extends WebPage
+{
+
+ private static final List<String> bedOptions = Arrays.asList("One
king-sized bed", "Two double beds", "Three beds");
+ private static final List<String> smokingOptions =
Arrays.asList("Smoking", "Non Smoking");
+ private static final List<String> monthOptions = Arrays.asList("Jan",
"Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov",
"Dec");
+ private static final List<String> yearOptions = Arrays.asList("2008",
"2009");
+
+ @In
+ private Booking booking;
+
+ @In(create=true)
+ private HotelBooking hotelBooking;
+
+ public Book(final PageParameters parameters)
+ {
+ super(parameters);
+ System.out.println(parameters);
+ Template body = new Template("body");
+ add(body);
+ body.add(new FeedbackPanel("messages"));
+ body.add(new HotelViewPanel("hotelView", booking.getHotel()));
+ body.add(new HotelBookingForm("booking"));
+
+ }
+
+ public class HotelBookingForm extends Form
+ {
+
+ public HotelBookingForm(String id)
+ {
+ super(id);
+ add(new FormInputBorder("checkinDateBorder", "Check in
date", new DateField("checkinDate").setRequired(true), new
PropertyModel(booking, "checkinDate")));
+ add(new FormInputBorder("checkoutDateBorder", "Check out
date", new DateField("checkoutDate").setRequired(true), new
PropertyModel(booking, "checkoutDate")));
+ add(new FormInputBorder("bedsBorder", "Room Preference", new
DropDownChoice("beds", bedOptions)
+ {
+ @Override
+ protected Object convertChoiceIdToChoice(String id)
+ {
+ return bedOptions.indexOf(id);
+ }
+
+ }.setRequired(true), new PropertyModel(booking, "beds")));
+ add(new FormInputBorder("smokingBorder", "Smoking
Preference", new RadioChoice("smoking", smokingOptions)
+ {
+
+ @Override
+ protected Object convertChoiceIdToChoice(String id)
+ {
+ if ("Smoking".equals(id))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ }.setRequired(true), new PropertyModel(booking, "smoking")));
+ add(new FormInputBorder("creditCardBorder", "Credit Card #",
new TextField("creditCard").setRequired(true), new PropertyModel(booking,
"creditCard")));
+ add(new FormInputBorder("creditCardNameBorder", "Credit Card
Name", new TextField("creditCardName").setRequired(true), new
PropertyModel(booking, "creditCardName")));
+ add(new FormInputBorder("creditCardExpiryBorder", "Credit Card
Expiry", new DropDownChoice("creditCardExpiryMonth",
monthOptions).setRequired(true), new PropertyModel(booking,
"creditCardExpiryMonth")).add(new
DropDownChoice("creditCardExpiryYear", yearOptions).setRequired(true), new
PropertyModel(booking, "creditCardExpiryYear")));
+ add(new Link("cancel")
+ {
+
+ @Override
+ public void onClick()
+ {
+ setResponsePage(Main.class);
+ }
+
+ });
+ }
+
+
+
+ @Override
+ protected void onSubmit()
+ {
+ hotelBooking.setBookingDetails();
+ if (hotelBooking.isBookingValid())
+ {
+ setResponsePage(Confirm.class);
+ }
+ else
+ {
+ error(new ValidationError().setMessage("Error"));
+ }
+ }
+
+ @Override
+ public Component add(IBehavior behavior)
+ {
+ // TODO Auto-generated method stub
+ return super.add(behavior);
+ }
+
+ }
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.html
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,46 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head></head>
+
+<body>
+
+<!-- content -->
+<div wicket:id="body">
+
+<div class="section">
+ <h1>Confirm Hotel Booking</h1>
+</div>
+
+<div class="section">
+
+ <div wicket:id="hotel">[include hotel details]</div>
+
+ <div wicket:id="totalBorder">
+ <span wicket:id="total">[total payment]</span>
+ </div>
+
+ <div wicket:id="checkinDateBorder">
+ <span wicket:id="checkinDate">[checkin date]</span>
+ </div>
+
+ <div wicket:id="checkoutDateBorder">
+ <span wicket:id="checkoutDate">[checkout date]</span>
+ </div>
+
+ <div wicket:id="creditCardNumberBorder">
+ <span wicket:id="creditCardNumber">[credit card number]</span>
+ </div>
+
+ <div class="buttonBox">
+ <input type="button" wicket:id="confirm"
value="Confirm" />
+  
+ <input type="button" wicket:id="revise" value="Revise"
/>
+  
+ <input type="button" wicket:id="cancel"
value="Cancel" />
+ </div>
+
+</div>
+
+</div>
+</body>
+</html>
Property changes on:
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.html
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,76 @@
+
+package org.jboss.seam.example.wicket;
+
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.Link;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.core.ConversationPropagation;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.example.wicket.action.Booking;
+import org.jboss.seam.example.wicket.action.HotelBooking;
+
+@Restrict
+public class Confirm extends WebPage
+{
+
+ @In
+ private Booking booking;
+
+ @In(create=true)
+ private HotelBooking hotelBooking;
+
+ public Confirm(final PageParameters parameters)
+ {
+ super(parameters);
+ Template body = new Template("body");
+ final String cid = Conversation.instance().getId();
+ body.add(new HotelViewPanel("hotel", booking.getHotel()));
+ body.add(new OutputBorder("totalBorder", "Total Payment", new
Label("total",
DecimalFormat.getCurrencyInstance(Locale.US).format(booking.getTotal()))));
+ body.add(new OutputBorder("checkinDateBorder", "Check in", new
Label("checkinDate", new
SimpleDateFormat("mm/dd/yy").format(booking.getCheckinDate()))));
+ body.add(new OutputBorder("checkoutDateBorder", "Check out", new
Label("checkoutDate", new
SimpleDateFormat("mm/dd/yy").format(booking.getCheckoutDate()))));
+ body.add(new OutputBorder("creditCardNumberBorder", "Credit Card
#", new Label("creditCardNumber", booking.getCreditCard())));
+ body.add(new Link("revise")
+ {
+ @Override
+ public void onClick()
+ {
+ ConversationPropagation.instance().setConversationId(cid);
+ Manager.instance().restoreConversation();
+ hotelBooking.bookHotel();
+ setResponsePage(Book.class);
+ }
+ });
+ body.add(new Link("confirm")
+ {
+ @Override
+ public void onClick()
+ {
+ ConversationPropagation.instance().setConversationId(cid);
+ Manager.instance().restoreConversation();
+ hotelBooking.confirm();
+ setResponsePage(Main.class);
+ }
+ });
+ body.add(new Link("cancel")
+ {
+ @Override
+ public void onClick()
+ {
+ hotelBooking.cancel();
+ setResponsePage(Main.class);
+ }
+
+ });
+
+ add(body);
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.html
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,17 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <wicket:border>
+ <div class="entry">
+ <label class="label #{invalid?'errors':''}"
wicket:id="label" />
+ <span class="input #{invalid?'errors':''}">
+ <wicket:body />
+ </span>
+ <span wicket:id="message" class="error errors"/>
+ </div>
+ </wicket:border>
+ </body>
+</html>
\ No newline at end of file
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.java
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,92 @@
+package org.jboss.seam.example.wicket;
+
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.border.Border;
+import org.apache.wicket.markup.html.form.FormComponent;
+import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
+import org.jboss.seam.wicket.ModelValidator;
+
+/**
+ * Wicket allows you to build powerful custom components easily.
+ *
+ * Here we've built generic border you can use to decorate a form input with
+ * a label, a * if the field is required and an feedback panel for displaying
+ * any error messages.
+ *
+ * It also attaches a model validator (which asks Seam to validate the input against
+ * Hibernate Validator).
+ * based
+ *
+ * @author Pete Muir
+ *
+ */
+public class FormInputBorder extends Border
+{
+
+ private ComponentFeedbackPanel feedbackPanel;
+
+ /**
+ * Create a new form input border
+ * @param id Id of border component on page
+ * @param label Label to add
+ * @param component The component to wrap
+ * @param model The model to attach the component to
+ */
+ public FormInputBorder(String id, String label, FormComponent component, PropertyModel
model)
+ {
+ super(id);
+ component.setLabel(new Model(label));
+ if (component.isRequired())
+ {
+ label += ":*";
+ }
+ else
+ {
+ label += ":";
+ }
+ Label labelComponent = new Label("label", label);
+ add(labelComponent);
+ add(component, model);
+ feedbackPanel = new ComponentFeedbackPanel("message", component);
+ feedbackPanel.setOutputMarkupId(true);
+ add(feedbackPanel);
+ component.add(new ModelValidator(model));
+
+ component.add(new AjaxFormComponentUpdatingBehavior("onblur")
+ {
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target)
+ {
+ getFormComponent().validate();
+ target.addComponent(feedbackPanel);
+ }
+
+ @Override
+ protected void onError(AjaxRequestTarget target, RuntimeException e)
+ {
+ target.addComponent(feedbackPanel);
+ }
+
+ @Override
+ protected boolean getUpdateModel()
+ {
+ return true;
+ }
+
+ });
+ }
+
+ public FormInputBorder add(FormComponent component, PropertyModel model)
+ {
+ component.add(new ModelValidator(model));
+ component.setModel(model);
+ add(component);
+ return this;
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.html
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,58 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
+ <title>JBoss Suites: Seam Framework</title>
+ <wicket:link>
+ <link href="css/screen.css" rel="stylesheet"
type="text/css" />
+ </wicket:link>
+</head>
+<body id="pgHome">
+<div id="document">
+ <div id="header">
+ <div id="title"><wicket:link><img
src="img/hdr.title.gif" alt="JBoss Suites: seam framework
demo"/></wicket:link></div>
+ </div>
+ <div id="container">
+ <div id="sidebar">
+ <form wicket:id="login">
+ <fieldset>
+ <div>
+ <label for="username">Login Name</label>
+ <input wicket:id="username" style="width: 175px;"/>
+ <div class="errors"><h:message
for="username"/></div>
+ </div>
+ <div>
+ <label for="password">Password</label>
+ <input wicket:id="password" type="password"
style="width: 175px;"/>
+ </div>
+ <div class="errors" wicket:id="messages" />
+ <div class="buttonBox"><input type="submit"
value="Account Login"/></div>
+ <div class="notes"><a wicket:id="register">Register
New User</a></div>
+ </fieldset>
+ </form>
+ </div>
+ <div id="content">
+ <div class="section">
+
+ <h1>About this example application</h1>
+
+ <p>
+ This sample application demonstrates how easy it is to develop stateful web
+ applications using JBoss Seam. Just register, login, and book a room to see
+ Seam in action. Throughout the application you'll see popup links like
+ the ones at the bottom of this page. Click them to see how the application
+ works under the hood.
+ </p>
+
+ <p>
+ Note: Please do NOT enter personal information or your credit card number in
+ this sample application.
+ </p>
+
+ </div>
+ </div>
+ </div>
+ <div id="footer">Created with Seam 2.0, JBoss EJB 3.0 and Apache
Wicket</div>
+</div>
+</body>
+</html>
Property changes on:
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.html
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jboss.seam.example.wicket;
+
+import javax.security.auth.login.LoginException;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.PasswordTextField;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.validation.ValidationError;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.security.Identity;
+
+public class Home extends WebPage
+{
+
+ @In
+ private Identity identity;
+
+ @Logger
+ private Log log;
+
+ private static final long serialVersionUID = 1L;
+
+ public Home(final PageParameters parameters)
+ {
+ add(new LoginForm("login"));
+ }
+
+ public class LoginForm extends Form
+ {
+ public LoginForm(String id)
+ {
+ super(id);
+ add(new TextField("username", new PropertyModel(identity,
"username")));
+ add(new PasswordTextField("password", new PropertyModel(identity,
"password")));
+ add(new BookmarkablePageLink("register", Register.class));
+ add(new FeedbackPanel("messages"));
+ }
+
+ @Override
+ protected void onSubmit()
+ {
+ try
+ {
+ identity.authenticate();
+ log.info("Login succeeded");
+ setResponsePage(Main.class);
+ }
+ catch (LoginException e)
+ {
+ error(new ValidationError().setMessage("Login failed"));
+ log.error("Login failed", e);
+ }
+ }
+
+ }
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.html
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,21 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<!-- content -->
+<div wicket:id="body">
+
+<div class="section">
+ <h1>View Hotel</h1>
+</div>
+
+<div class="section">
+ <span wicket:id="hotel">[hotel details]</span>
+
+ <div class="buttonBox">
+
+ <input type="button" wicket:id="bookHotel" value="Book
Hotel"/>
+  
+ <input type="button" wicket:id="cancel" value="Back to
Search"/>
+ </div>
+
+</div>
+</div>
Property changes on:
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.html
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,65 @@
+
+package org.jboss.seam.example.wicket;
+
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.link.Link;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.example.wicket.action.HotelBooking;
+import org.jboss.seam.wicket.SeamLink;
+
+@Restrict
+public class Hotel extends WebPage
+{
+
+ private org.jboss.seam.example.wicket.action.Hotel hotel;
+
+ @In(create=true)
+ private HotelBooking hotelBooking;
+
+ public Hotel(final PageParameters parameters)
+ {
+ super(parameters);
+ Template body = new Template("body");
+ body.add(new SeamLink("bookHotel")
+ {
+ @Override
+ public void onClick()
+ {
+ hotelBooking.bookHotel();
+ setResponsePage(Book.class);
+ }
+ });
+ body.add(new Link("cancel")
+ {
+ @Override
+ public void onClick()
+ {
+ hotelBooking.cancel();
+ setResponsePage(Main.class);
+ }
+
+ });
+ initHotel();
+ body.add(new HotelViewPanel("hotel", hotel));
+ add(body);
+ }
+
+ @Override
+ protected void onBeforeRender()
+ {
+ initHotel();
+ super.onBeforeRender();
+ }
+
+ private void initHotel()
+ {
+ if (hotel == null)
+ {
+ hotel =
hotelBooking.selectHotel(getPageParameters().getLong("hotelId"));
+ }
+ }
+
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/HotelViewPanel.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/HotelViewPanel.html
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/HotelViewPanel.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,36 @@
+<html>
+
+ <body>
+ <wicket:panel>
+
+ <span wicket:id="hotelNameBorder">
+ <span wicket:id="hotelName">[hotel name]</span>
+ </span>
+
+ <span wicket:id="hotelAddressBorder">
+ <span wicket:id="hotelAddress">[hotel address]</span>
+ </span>
+
+ <span wicket:id="hotelCityBorder">
+ <span wicket:id="hotelCity">[hotel city]</span>
+ </span>
+
+ <span wicket:id="hotelStateBorder">
+ <span wicket:id="hotelState">[hotel state]</span>
+ </span>
+
+ <span wicket:id="hotelZipBorder">
+ <span wicket:id="hotelZip">[hotel zip code]</span>
+ </span>
+
+ <span wicket:id="hotelCountryBorder">
+ <span wicket:id="hotelCountry">[hotel country]</span>
+ </span>
+
+ <span wicket:id="hotelPriceBorder">
+ <span wicket:id="hotelPrice">[hotel nightly rate]</span>
+ </span>
+
+ </wicket:panel>
+</body>
+</html>
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/HotelViewPanel.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/HotelViewPanel.java
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/HotelViewPanel.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,25 @@
+package org.jboss.seam.example.wicket;
+
+import java.text.DecimalFormat;
+import java.util.Locale;
+
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.jboss.seam.example.wicket.action.Hotel;
+
+public class HotelViewPanel extends Panel
+{
+
+ public HotelViewPanel(String id, Hotel hotel)
+ {
+ super(id);
+ add(new OutputBorder("hotelNameBorder", "Name", new
Label("hotelName", hotel.getName())));
+ add(new OutputBorder("hotelAddressBorder", "Address", new
Label("hotelAddress", hotel.getAddress())));
+ add(new OutputBorder("hotelCityBorder", "City", new
Label("hotelCity", hotel.getCity())));
+ add(new OutputBorder("hotelStateBorder", "State", new
Label("hotelState", hotel.getState())));
+ add(new OutputBorder("hotelZipBorder", "Zip", new
Label("hotelZip", hotel.getZip())));
+ add(new OutputBorder("hotelCountryBorder", "Country", new
Label("hotelCountry", hotel.getCountry())));
+ add(new OutputBorder("hotelPriceBorder", "Nightly Rate", new
Label("hotelPrice",
DecimalFormat.getCurrencyInstance(Locale.US).format(hotel.getPrice()))));
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.html
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,148 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head></head>
+<body>
+
+ <div wicket:id="body">
+
+ <!-- content -->
+ <div class="section">
+
+ <form wicket:id="searchCriteria">
+
+ <span class="errors" wicket:id="messages" />
+
+ <h1>Search Hotels</h1>
+
+
+ <fieldset>
+ <input wicket:id="searchString" style="width: 165px;" />
+  
+ <input type="submit" wicket:id="submit" value="Find
Hotels" />
+  
+ <br/>
+ <label for="pageSize">Maximum results:</label> 
+ <select wicket:id="pageSize" />
+ </fieldset>
+ </form>
+
+ </div>
+
+ <div class="section">
+ <wicket:enclosure>
+ <span wicket:id="noResults" />
+ </wicket:enclosure>
+ <div wicket:id="hotels">
+ <wicket:enclosure child="hotel">
+ <table>
+ <thead>
+ <tr>
+ <th>
+ Name
+ </th>
+ <th>
+ Address
+ </th>
+ <th>
+ City, State
+ </th>
+ <th>
+ Zip
+ </th>
+ <th>
+ Action
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr wicket:id="hotel">
+ <td>
+ <span wicket:id="hotelName">[name]</span>
+ </td>
+ <td>
+ <span wicket:id="hotelAddress">[address]</span>
+ </td>
+ <td>
+ <span wicket:id="hotelCityStateCountry">[city, state,
country]</span>
+ </td>
+ <td>
+ <span wicket:id="hotelZip">[zip]</span>
+ </td>
+ <td>
+ <a wicket:id="viewHotel">View Hotel</a>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ <span wicket:id="hotelPager" />
+ </wicket:enclosure>
+ </div>
+ </div>
+
+ <div class="section">
+ <h1>Current Hotel Bookings</h1>
+ </div>
+ <div class="section">
+ <wicket:enclosure>
+ <span wicket:id="noHotelsBooked" />
+ </wicket:enclosure>
+ <wicket:enclosure child="bookedHotel">
+ <table id="bookings">
+ <thead>
+ <tr>
+ <th>
+ Name
+ </th>
+ <th>
+ Address
+ </th>
+ <th>
+ City, State
+ </th>
+ <th>
+ Check in date
+ </th>
+ <th>
+ Check out date
+ </th>
+ <th>
+ Confirmation number
+ </th>
+ <th>
+ Action
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr wicket:id="bookedHotel">
+ <td>
+ <span wicket:id="hotelName">[name]</span>
+ </td>
+ <td>
+ <span wicket:id="hotelAddress">[address]</span>
+ </td>
+ <td>
+ <span wicket:id="hotelCityStateCountry">[city, state,
country]</span>
+ </td>
+ <td>
+ <span wicket:id="hotelCheckInDate">[check in date]</span>
+ </td>
+ <td>
+ <span wicket:id="hotelCheckOutDate">[check out date]</span>
+ </td>
+ <td>
+ <span wicket:id="hotelConfirmationNumber">[confirmation
number]</span>
+ </td>
+ <td>
+ <a wicket:id="cancel">Cancel</a>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </wicket:enclosure>
+ </div>
+
+ </div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,264 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jboss.seam.example.wicket;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.markup.repeater.data.DataView;
+import org.apache.wicket.model.PropertyModel;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.example.wicket.action.Booking;
+import org.jboss.seam.example.wicket.action.BookingList;
+import org.jboss.seam.example.wicket.action.Hotel;
+import org.jboss.seam.example.wicket.action.HotelSearching;
+import org.jboss.seam.wicket.SimpleDataProvider;
+
+@Restrict
+public class Main extends WebPage
+{
+
+ @In(create = true)
+ private HotelSearching hotelSearch;
+
+ @In(create=true)
+ private List<Booking> bookings;
+
+ @In(create=true)
+ private BookingList bookingList;
+
+ private DataView hotelDataView;
+ private DataView bookedHotelDataView;
+ private HotelSearchForm hotelSearchForm;
+ private WebMarkupContainer hotels;
+ private Component noHotelsFound;
+
+ public Main(final PageParameters parameters)
+ {
+ Template body = new Template("body");
+ add(body);
+ hotelSearchForm = new HotelSearchForm("searchCriteria");
+ body.add(hotelSearchForm);
+
+ /*
+ * Hotel Search results
+ */
+ noHotelsFound = new Label("noResults", "No Hotels Found")
+ {
+ /**
+ * Only display the message if no hotels are found
+ *
+ */
+ @Override
+ public boolean isVisible()
+ {
+ return hotelSearch.getHotels().size() == 0;
+ }
+ };
+ body.add(noHotelsFound.setOutputMarkupId(true));
+ hotelDataView = new DataView("hotel", new SimpleDataProvider() // A
DataProvider adapts between your data and Wicket's internal representation
+ {
+ public Iterator iterator(int from, int count)
+ {
+ return hotelSearch.getHotels().subList(from, from + count).iterator();
+ }
+
+ public int size()
+ {
+ return hotelSearch.getHotels().size();
+ }
+
+ })
+ {
+ /**
+ * You specify the tr in the html, and populate each one here
+ */
+ @Override
+ protected void populateItem(Item item)
+ {
+ Hotel hotel = (Hotel) item.getModelObject();
+ item.add(new Label("hotelName", hotel.getName()));
+ item.add(new Label("hotelAddress", hotel.getAddress()));
+ item.add(new Label("hotelCityStateCountry", hotel.getCity() +
", " + hotel.getState() + ", " + hotel.getCountry()));
+ item.add(new Label("hotelZip", hotel.getZip()));
+ item.add(new BookmarkablePageLink("viewHotel",
org.jboss.seam.example.wicket.Hotel.class).setParameter("hotelId",
hotel.getId()));
+ }
+
+ @Override
+ public boolean isVisible()
+ {
+ return hotelSearch.getHotels().size() > 0;
+ }
+
+ };
+
+ // Set the maximum items per page
+ hotelDataView.setItemsPerPage(hotelSearchForm.getPageSize());
+ hotelDataView.setOutputMarkupId(true);
+ hotels = new WebMarkupContainer("hotels");
+ hotels.add(hotelDataView).setOutputMarkupId(true);
+
+
+ // Add a pager
+ hotels.add(new PagingNavigator("hotelPager", hotelDataView)
+ {
+ @Override
+ public boolean isVisible()
+ {
+ return hotelDataView.isVisible();
+ }
+
+ });
+
+ body.add(hotels);
+
+ /*
+ * Existing hotel booking
+ */
+ bookedHotelDataView = new DataView("bookedHotel", new
SimpleDataProvider()
+ {
+ public Iterator iterator(int from, int count)
+ {
+ return bookings.subList(from, from + count).iterator();
+ }
+
+ public int size()
+ {
+ return bookings.size();
+ }
+
+
+
+ })
+ {
+
+ @Override
+ protected void populateItem(Item item)
+ {
+ final Booking booking = (Booking) item.getModelObject();
+ item.add(new Label("hotelName", booking.getHotel().getName()));
+ item.add(new Label("hotelAddress",
booking.getHotel().getAddress()));
+ item.add(new Label("hotelCityStateCountry",
booking.getHotel().getCity() + ", " + booking.getHotel().getState() + ",
" + booking.getHotel().getState()));
+ item.add(new Label("hotelCheckInDate",
booking.getCheckinDate().toString()));
+ item.add(new Label("hotelCheckOutDate",
booking.getCheckoutDate().toString()));
+ item.add(new Label("hotelConfirmationNumber",
booking.getId().toString()));
+ item.add(new Link("cancel")
+ {
+
+ @Override
+ public void onClick()
+ {
+ bookingList.cancel(booking);
+ }
+
+ });
+ }
+
+ @Override
+ public boolean isVisible()
+ {
+ return bookings.size() > 0;
+ }
+
+ };
+ body.add(bookedHotelDataView);
+ body.add(new Label("noHotelsBooked", "No Bookings Found")
+ {
+ @Override
+ public boolean isVisible()
+ {
+ return bookings.size() == 0;
+ }
+ });
+ }
+
+ public class HotelSearchForm extends Form
+ {
+
+ private Integer pageSize = 10;
+
+ public Integer getPageSize()
+ {
+ return pageSize;
+ }
+
+ public void setPageSize(Integer pageSize)
+ {
+ this.pageSize = pageSize;
+ }
+
+ public HotelSearchForm(String id)
+ {
+ super(id);
+ add(new TextField("searchString", new PropertyModel(hotelSearch,
"searchString")));
+ List<Integer> pageSizes = Arrays.asList(new Integer[] { 5, 10, 20 });
+ add(new DropDownChoice("pageSize", new PropertyModel(this,
"pageSize"), pageSizes));
+ final Component messages = new
FeedbackPanel("messages").setOutputMarkupId(true);
+ add(messages);
+ add(new IndicatingAjaxButton("submit", this)
+ {
+
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form form)
+ {
+ target.addComponent(messages);
+ hotelSearch.find();
+ hotelDataView.setCurrentPage(0);
+ hotelDataView.setItemsPerPage(getPageSize());
+ hotelDataView.modelChanged();
+ hotels.modelChanged();
+ target.addComponent(hotels);
+ target.addComponent(noHotelsFound);
+ }
+
+ @Override
+ protected void onError(AjaxRequestTarget target, Form form)
+ {
+ target.addComponent(messages);
+ }
+
+ });
+ }
+
+ @Override
+ protected void onSubmit()
+ {
+ hotelDataView.setCurrentPage(0);
+ hotelDataView.setItemsPerPage(getPageSize());
+ hotelSearch.find();
+ }
+
+ }
+}
+
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/OutputBorder.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/OutputBorder.html
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/OutputBorder.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,14 @@
+<html>
+ <body>
+ <wicket:border>
+ <div class="entry">
+ <span class="label">
+ <span wicket:id="label" />
+ </span>
+ <span class="input">
+ <wicket:body />
+ </span>
+ </div>
+ </wicket:border>
+ </body>
+</html>
\ No newline at end of file
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/OutputBorder.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/OutputBorder.java
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/OutputBorder.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,31 @@
+package org.jboss.seam.example.wicket;
+
+import org.apache.wicket.markup.html.WebComponent;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.border.Border;
+
+/**
+ * Wicket allows you to build powerful custom components easily.
+ *
+ * Here we've built generic border you can use to decorate an output
+ *
+ * @author Pete Muir
+ *
+ */
+public class OutputBorder extends Border
+{
+
+ /**
+ * Create a new form input border
+ * @param id Id of border component on page
+ * @param label Label to add
+ * @param component The component to wrap
+ */
+ public OutputBorder(String id, String label, WebComponent component)
+ {
+ super(id);
+ add(new Label("label", label + ": "));
+ add(component);
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.html
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,44 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+</head>
+
+<body>
+
+<!-- content -->
+<div wicket:id="body">
+
+<div class="section">
+ <h1>Change Your Password</h1>
+</div>
+
+<div class="section">
+
+ <form wicket:id="setpassword">
+
+ <div class="entry errors" wicket:id="messages" />
+
+ <fieldset>
+
+ <span wicket:id="passwordBorder">
+ <input type="password" wicket:id="password" />
+ </span>
+
+ <span wicket:id="verifyBorder">
+ <input type="password" wicket:id="verify" />
+ </span>
+
+ <div class="buttonBox">
+ <input type="submit" value="Change" />
+  
+ <input type="button" wicket:id="cancel"
value="Cancel" />
+ </div>
+
+ </fieldset>
+
+ </form>
+</div>
+
+</div>
+</body>
+</html>
\ No newline at end of file
Property changes on:
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.html
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,70 @@
+package org.jboss.seam.example.wicket;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.FormComponent;
+import org.apache.wicket.markup.html.form.PasswordTextField;
+import org.apache.wicket.markup.html.form.validation.EqualInputValidator;
+import org.apache.wicket.markup.html.link.PageLink;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.PropertyModel;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.example.wicket.action.ChangePassword;
+import org.jboss.seam.example.wicket.action.User;
+
+@Restrict
+public class Password extends WebPage
+{
+
+ @In(create=true)
+ private User user;
+
+ @In(create=true)
+ private ChangePassword changePassword;
+
+
+ public Password()
+ {
+ Template body = new Template("body");
+ body.add(new RegisterForm("setpassword"));
+ add(body);
+ }
+
+ public class RegisterForm extends Form
+ {
+
+ private String verify;
+
+ public String getVerify()
+ {
+ return verify;
+ }
+
+ public void setVerify(String verify)
+ {
+ this.verify = verify;
+ }
+
+ public RegisterForm(String id)
+ {
+ super(id);
+ add(new PageLink("cancel", Main.class));
+ FormComponent password = new
PasswordTextField("password").setRequired(true);
+ FormComponent verify = new
PasswordTextField("verify").setRequired(true);
+ add(new FormInputBorder("passwordBorder", "Password",
password , new PropertyModel(user, "password")));
+ add(new FormInputBorder("verifyBorder", "Verify Password",
verify, new PropertyModel(this, "verify")));
+ add(new FeedbackPanel("messages"));
+ add(new EqualInputValidator(password, verify));
+ }
+
+ @Override
+ protected void onSubmit()
+ {
+ changePassword.changePassword();
+ setResponsePage(Main.class);
+ }
+
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.html
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns:a="http://richfaces.org/a4j">
+<head>
+ <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
+ <title>JBoss Suites: Seam Framework</title>
+ <wicket:link>
+ <link href="css/screen.css" rel="stylesheet"
type="text/css" />
+ </wicket:link>
+</head>
+
+<body id="pgHome">
+
+<div id="document">
+
+ <div id="header">
+ <div id="title"><img src="/seam-wicket/img/hdr.title.gif"
alt="JBoss Suites: seam framework demo"/></div>
+ </div>
+
+ <div id="container">
+
+ <div id="sidebar">
+
+ </div>
+
+ <div id="content">
+
+ <div class="section">
+ <h1>Register</h1>
+ </div>
+
+ <div class="section">
+
+ <form wicket:id="registration">
+ <fieldset>
+
+ <div wicket:id="usernameDecorate">
+ <input wicket:id="username" />
+ </div>
+
+ <span wicket:id="nameDecorate">
+ <input wicket:id="name" />
+ </span>
+
+ <span wicket:id="passwordDecorate">
+ <input type="password" wicket:id="password" />
+ </span>
+
+ <span wicket:id="verifyDecorate">
+ <input type="password" wicket:id="verify" />
+ </span>
+
+ <div class="buttonBox">
+ <input type="submit" value="Register"/>
+  
+ <input type="button" wicket:id="cancel"
value="Cancel"/>
+ </div>
+
+ </fieldset>
+ <div class="errors" wicket:id="messages" />
+ </form>
+
+ </div>
+
+ </div>
+
+ </div>
+
+ <div id="footer">Created with Seam 2.0, JBoss EJB 3.0 and Apache
Wicket</div>
+
+</div>
+
+</body>
+
+</html>
Property changes on:
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.html
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,76 @@
+package org.jboss.seam.example.wicket;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.FormComponent;
+import org.apache.wicket.markup.html.form.PasswordTextField;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.form.validation.EqualInputValidator;
+import org.apache.wicket.markup.html.link.PageLink;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.PropertyModel;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.example.wicket.action.User;
+
+public class Register extends WebPage
+{
+
+ @In(create=true)
+ private User user;
+
+ @In(create=true)
+ private org.jboss.seam.example.wicket.action.Register register;
+
+ private TextField username;
+
+
+ public Register()
+ {
+ add(new RegisterForm("registration"));
+ }
+
+ public class RegisterForm extends Form
+ {
+
+ public RegisterForm(String id)
+ {
+ super(id);
+ add(new PageLink("cancel", Home.class));
+ username = new TextField("username");
+ username.setRequired(true);
+ add(new FormInputBorder("usernameDecorate", "Username",
username, new PropertyModel(user, "username")));
+ add(new FormInputBorder("nameDecorate", "Real Name", new
TextField("name").setRequired(true), new PropertyModel(user,
"name")));
+ FormComponent password = new
PasswordTextField("password").setRequired(true);
+ FormComponent verify = new
PasswordTextField("verify").setRequired(true);
+ add(new FormInputBorder("passwordDecorate", "Password",
password , new PropertyModel(user, "password")));
+ add(new FormInputBorder("verifyDecorate", "Verify Password",
verify, new PropertyModel(register, "verify")));
+ add(new FeedbackPanel("messages"));
+ add(new EqualInputValidator(password, verify));
+ }
+
+ @Override
+ protected void onSubmit()
+ {
+ register.register();
+ setResponsePage(Home.class);
+ }
+
+ @Override
+ protected void onError()
+ {
+ super.onError();
+ System.out.println("onError");
+ System.out.println(username.getFeedbackMessage());
+ }
+
+ }
+
+ @Override
+ protected void onBeforeRender()
+ {
+ super.onBeforeRender();
+ System.out.println("onBeforeRender");
+ System.out.println(username.getFeedbackMessage());
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Template.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Template.html
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Template.html 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,41 @@
+<wicket:border>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:s="http://jboss.com/products/seam/taglib">
+<head>
+ <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
+ <title>JBoss Suites: Seam Framework</title>
+ <wicket:link>
+ <link href="css/screen.css" rel="stylesheet"
type="text/css" />
+ </wicket:link>
+</head>
+
+
+
+<body>
+
+<div id="document">
+ <div id="header">
+ <div id="title"><wicket:link><img
src="img/hdr.title.gif" alt="JBoss Suites: seam framework
demo"/></wicket:link></div>
+ <div id="status">
+ Welcome <span wicket:id="userName" />
+ | <a wicket:id="search">Search</a>
+ | <a wicket:id="settings">Settings</a>
+ | <a wicket:id="logout">Logout</a>
+ </div>
+ </div>
+ <div id="container">
+ <div id="sidebar">
+ <!-- <ui:insert name="sidebar"/>-->
+ </div>
+ <div id="content">
+ <wicket:body />
+ </div>
+ </div>
+ <div id="footer">Created with Seam 2.0, JBoss EJB 3.0 and Apache
Wicket</div>
+</div>
+</body>
+</html>
+</wicket:border>
\ No newline at end of file
Property changes on:
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Template.html
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Template.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Template.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Template.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,37 @@
+package org.jboss.seam.example.wicket;
+
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.border.Border;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.Link;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.example.wicket.action.User;
+import org.jboss.seam.security.Identity;
+
+public class Template extends Border
+{
+
+ @In
+ private User user;
+
+ @In
+ private Identity identity;
+
+ public Template(String id)
+ {
+ super(id);
+ add(new BookmarkablePageLink("search", Main.class));
+ add(new BookmarkablePageLink("settings", Password.class));
+ add(new Link("logout")
+ {
+ @Override
+ public void onClick()
+ {
+ identity.logout();
+ setResponsePage(Home.class);
+ }
+ });
+ add(new Label("userName", user.getName()));
+ }
+
+}
Added:
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/WicketBookingApplication.java
===================================================================
---
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/WicketBookingApplication.java
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/WicketBookingApplication.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jboss.seam.example.wicket;
+
+import java.util.Map;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.Page;
+import org.apache.wicket.Request;
+import org.apache.wicket.RequestCycle;
+import org.apache.wicket.RequestListenerInterface;
+import org.apache.wicket.Response;
+import org.apache.wicket.Session;
+import org.apache.wicket.markup.html.form.IFormSubmitListener;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WebRequestCycleProcessor;
+import org.apache.wicket.protocol.http.WebSession;
+import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
+import org.apache.wicket.request.IRequestCodingStrategy;
+import org.apache.wicket.request.IRequestCycleProcessor;
+import org.apache.wicket.request.RequestParameters;
+import org.apache.wicket.request.target.component.IBookmarkablePageRequestTarget;
+import
org.apache.wicket.request.target.component.listener.IListenerInterfaceRequestTarget;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.wicket.SeamAuthorizationStrategy;
+import org.jboss.seam.wicket.SeamSupport;
+
+/**
+ * Test application for Wicket/ Seam/ Jetty.
+ */
+public class WicketBookingApplication extends WebApplication {
+
+ /**
+ * Constructor.
+ */
+ public WicketBookingApplication() {
+ }
+
+ /**
+ * @see wicket.Application#getHomePage()
+ */
+ @SuppressWarnings("unchecked")
+ public Class getHomePage() {
+ return Home.class;
+ }
+
+ /**
+ * Custom session with invalidation override. We can't just let Wicket
+ * invalidate the session as Seam might have to do some cleaning up to do.
+ */
+ @Override
+ public Session newSession(Request request, Response response) {
+ return new WebSession(WicketBookingApplication.this, request) {
+
+ @Override
+ public void invalidate() {
+ org.jboss.seam.web.Session.getInstance().invalidate();
+ }
+
+ @Override
+ public void invalidateNow() {
+ // sorry, can't support this with Seam
+ org.jboss.seam.web.Session.getInstance().invalidate();
+ }
+ };
+ }
+
+ @Override
+ protected IRequestCycleProcessor newRequestCycleProcessor()
+ {
+ return new WebRequestCycleProcessor()
+ {
+ @Override
+ protected IRequestCodingStrategy newRequestCodingStrategy()
+ {
+ return new WebRequestCodingStrategy()
+ {
+ @Override
+ protected CharSequence encode(RequestCycle requestCycle, final
IListenerInterfaceRequestTarget requestTarget)
+ {
+ if
(IFormSubmitListener.INTERFACE.getName().equals(requestTarget.getRequestListenerInterface().getName()))
+ {
+ // TODO Do this nicely
+ StringBuilder stringBuilder = new
StringBuilder(super.encode(requestCycle, requestTarget));
+ if (Manager.instance().isReallyLongRunningConversation())
+ {
+ stringBuilder.append("&" +
Manager.instance().getConversationIdParameter() + "=" +
Conversation.instance().getId());
+ }
+ return stringBuilder.subSequence(0, stringBuilder.length());
+ }
+ else
+ {
+ return super.encode(requestCycle, requestTarget);
+ }
+ }
+
+ @Override
+ protected CharSequence encode(RequestCycle requestCycle,
IBookmarkablePageRequestTarget requestTarget)
+ {
+ if (requestCycle.getRequest().getParameter("cid") != null)
+ {
+ // TODO Do this nicely
+ StringBuilder stringBuilder = new
StringBuilder(super.encode(requestCycle, requestTarget));
+ if (Manager.instance().isReallyLongRunningConversation())
+ {
+ stringBuilder.append("&" +
Manager.instance().getConversationIdParameter() + "=" +
Conversation.instance().getId());
+ }
+ return stringBuilder.subSequence(0, stringBuilder.length());
+
+ }
+ return super.encode(requestCycle, requestTarget);
+ }
+
+ };
+ }
+ };
+ }
+
+ @Override
+ protected void init() {
+ super.init();
+ SeamSupport.activate(this);
+ getSecuritySettings().setAuthorizationStrategy(new
SeamAuthorizationStrategy(Home.class));
+ }
+}
\ No newline at end of file
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedAttribute.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedAttribute.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedAttribute.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,14 @@
+package org.jboss.seam.wicket;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+
+public interface BijectedAttribute<T extends Annotation>
+{
+ public String getName();
+ public T getAnnotation();
+ public Class getType();
+ public void set(Object bean, Object value);
+ public Object get(Object bean);
+ public MetaModel getMetaModel();
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedField.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedField.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedField.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,54 @@
+package org.jboss.seam.wicket;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+public class BijectedField<T extends Annotation> implements
BijectedAttribute<T>
+ {
+ private String name;
+ private Field field;
+ private T annotation;
+ private MetaModel metaModel;
+
+ public BijectedField(String name, Field field, T annotation, MetaModel metaModel)
+ {
+ this.name = name;
+ this.field = field;
+ this.annotation = annotation;
+ this.metaModel = metaModel;
+ }
+ public String getName()
+ {
+ return name;
+ }
+ public Field getField()
+ {
+ return field;
+ }
+ public T getAnnotation()
+ {
+ return annotation;
+ }
+ public Class getType()
+ {
+ return field.getType();
+ }
+ public void set(Object bean, Object value)
+ {
+ metaModel.setFieldValue(bean, field, name, value);
+ }
+ public Object get(Object bean)
+ {
+ return metaModel.getFieldValue(bean, field, name);
+ }
+ @Override
+ public String toString()
+ {
+ return "BijectedField(" + name + ')';
+ }
+
+ public MetaModel getMetaModel()
+ {
+ return metaModel;
+ }
+ }
\ No newline at end of file
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedMethod.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedMethod.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedMethod.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,53 @@
+package org.jboss.seam.wicket;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+public class BijectedMethod<T extends Annotation> implements
BijectedAttribute<T>
+ {
+ private String name;
+ private Method method;
+ private T annotation;
+ private MetaModel metaModel;
+
+ public BijectedMethod(String name, Method method, T annotation, MetaModel
metaModel)
+ {
+ this.name = name;
+ this.method = method;
+ this.annotation = annotation;
+ }
+ public String getName()
+ {
+ return name;
+ }
+ public Method getMethod()
+ {
+ return method;
+ }
+ public T getAnnotation()
+ {
+ return annotation;
+ }
+ public void set(Object bean, Object value)
+ {
+ metaModel.setPropertyValue(bean, method, name, value);
+ }
+ public Object get(Object bean)
+ {
+ return metaModel.getPropertyValue(bean, method, name);
+ }
+ public Class getType()
+ {
+ return method.getParameterTypes()[0];
+ }
+ @Override
+ public String toString()
+ {
+ return "BijectedMethod(" + name + ')';
+ }
+
+ public MetaModel getMetaModel()
+ {
+ return metaModel;
+ }
+ }
\ No newline at end of file
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedProperty.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedProperty.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/BijectedProperty.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,66 @@
+package org.jboss.seam.wicket;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import org.jboss.seam.util.Reflections;
+
+public class BijectedProperty<T extends Annotation> implements
BijectedAttribute<T>
+ {
+
+ private BijectedMethod<T> getter;
+ private BijectedMethod<T> setter;
+ private MetaModel metaModel;
+
+ public BijectedProperty(String name, Method getter, Method setter, T annotation,
MetaModel metaModel)
+ {
+ this.getter = new BijectedMethod(name, getter, annotation, metaModel);
+ this.setter = new BijectedMethod(name, setter, annotation, metaModel);
+ }
+
+ public BijectedProperty(String name, Method getter, T annotation, MetaModel
metaModel)
+ {
+ this.getter = new BijectedMethod(name, getter, annotation, metaModel);
+ try
+ {
+ Method setterMethod = Reflections.getSetterMethod(getter.getDeclaringClass(),
name);
+ this.setter = new BijectedMethod(name, setterMethod, annotation, metaModel);
+ }
+ catch (IllegalArgumentException e) {}
+ }
+
+ public Object get(Object bean)
+ {
+ return getter.get(bean);
+ }
+
+ public T getAnnotation()
+ {
+ return getter.getAnnotation();
+ }
+
+ public String getName()
+ {
+ return getter.getName();
+ }
+
+ public Class getType()
+ {
+ return getter.getType();
+ }
+
+ public void set(Object bean, Object value)
+ {
+ if (setter == null)
+ {
+ throw new IllegalArgumentException("Component must have a setter for
" + metaModel.getName());
+ }
+ setter.set(bean, value);
+ }
+
+ public MetaModel getMetaModel()
+ {
+ return metaModel;
+ }
+
+ }
\ No newline at end of file
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionInterceptor.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionInterceptor.java
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionInterceptor.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,112 @@
+package org.jboss.seam.wicket;
+
+import static org.jboss.seam.ScopeType.STATELESS;
+import static org.jboss.seam.ScopeType.UNSPECIFIED;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.Namespace;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.core.Expressions;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.util.Reflections;
+
+import javassist.util.proxy.MethodHandler;
+
+public class InjectionInterceptor implements MethodHandler, Serializable
+{
+
+ private String name;
+ private In annotation;
+ private String metaModelName;
+ private transient MetaModel metaModel;
+
+ public InjectionInterceptor(BijectedAttribute<In> in)
+ {
+ this.name = in.getName();
+ this.annotation = in.getAnnotation();
+ this.metaModelName = in.getMetaModel().getMetaModelName();
+ }
+
+ private static LogProvider log = Logging.getLogProvider(InjectionInterceptor.class);
+
+ public Object invoke(final Object proxy, final Method method, final Method proceed,
final Object[] params) throws Throwable
+ {
+ return Reflections.invoke(method, getValueToInject(proxy), params);
+ }
+
+ private Object getValueToInject(Object bean)
+ {
+ if ( name.startsWith("#") )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.trace("trying to inject with EL expression: " + name);
+ }
+ return Expressions.instance().createValueExpression(name).getValue();
+ }
+ else if ( annotation.scope()==UNSPECIFIED )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.trace("trying to inject with hierarchical context search: " +
name);
+ }
+ return getInstanceInAllNamespaces(name, annotation.create());
+ }
+ else
+ {
+ if ( annotation.create() )
+ {
+ throw new IllegalArgumentException(
+ "cannot combine create=true with explicit scope on @In: " +
+ getMetaModel().getAttributeMessage(name)
+ );
+ }
+ if ( annotation.scope()==STATELESS )
+ {
+ throw new IllegalArgumentException(
+ "cannot specify explicit scope=STATELESS on @In: " +
+ getMetaModel().getAttributeMessage(name)
+ );
+ }
+
+
+ log.trace("trying to inject from specified context: " + name);
+
+ if ( annotation.scope().isContextActive() )
+ {
+ return annotation.scope().getContext().get(name);
+ }
+ }
+ return null;
+ }
+
+ private Object getInstanceInAllNamespaces(String name, boolean create)
+ {
+ Object result;
+ result = Component.getInstance(name, create);
+ if (result==null)
+ {
+ for ( Namespace namespace: Init.instance().getGlobalImports() )
+ {
+ result = namespace.getComponentInstance(name, create);
+ if (result!=null) break;
+ }
+ }
+ return result;
+ }
+
+ private MetaModel getMetaModel()
+ {
+ if (metaModel == null)
+ {
+ metaModel = MetaModel.forName(metaModelName);
+ }
+ return metaModel;
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionSupport.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionSupport.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/InjectionSupport.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,91 @@
+package org.jboss.seam.wicket;
+
+import static org.jboss.seam.wicket.MetaModelUtils.createProxyFactory;
+import static org.jboss.seam.wicket.MetaModelUtils.toName;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javassist.util.proxy.ProxyObject;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.Namespace;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+
+
+public class InjectionSupport
+{
+
+ // TODO Ouch
+ private static final Map<Class, Class<ProxyObject>> proxyFactories = new
HashMap<Class, Class<ProxyObject>>();
+
+ private LogProvider log = Logging.getLogProvider(InjectionSupport.class);
+
+ private List<BijectedAttribute<In>> inAttributes = new
ArrayList<BijectedAttribute<In>>();
+
+ private MetaModel metaModel;
+
+ public InjectionSupport(MetaModel metaModel)
+ {
+ this.metaModel = metaModel;
+ }
+
+ public void add(Method method)
+ {
+ if ( method.isAnnotationPresent(In.class) )
+ {
+ In in = method.getAnnotation(In.class);
+ String name = toName( in.value(), method );
+ inAttributes.add( new BijectedMethod(name, method, in, metaModel) );
+ }
+ }
+
+ public void add(Field field)
+ {
+ if ( field.isAnnotationPresent(In.class) )
+ {
+ In in = field.getAnnotation(In.class);
+ String name = toName( in.value(), field );
+ inAttributes.add( new BijectedField(name, field, in, metaModel) );
+ }
+ }
+
+ public void inject(Object instance) throws Exception
+ {
+ for ( BijectedAttribute<In> in : inAttributes )
+ {
+ // Currently need a proxy here as Wicket has no native support for interceptors
+ // TODO Replace this with a Seam ClientSide interceptor. Needs JBSEAM-699
+ in.set( instance, wrap( instance, in ) );
+ }
+ }
+
+ private static Object wrap(Object bean, BijectedAttribute<In> in) throws
Exception
+ {
+ ProxyObject proxy = getProxyFactory(in.getType()).newInstance();
+ proxy.setHandler(new InjectionInterceptor(in));
+ return proxy;
+ }
+
+ private static Class<ProxyObject> getProxyFactory(Class type)
+ {
+ if (proxyFactories.containsKey(type))
+ {
+ return proxyFactories.get(type);
+ }
+ else
+ {
+ Class<ProxyObject> factory = createProxyFactory( type );
+ proxyFactories.put(type, factory);
+ return factory;
+ }
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/LoggerSupport.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/LoggerSupport.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/LoggerSupport.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,58 @@
+package org.jboss.seam.wicket;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.util.Reflections;
+
+// TODO Reimplement as Seam ClientSide Interceptor
+public class LoggerSupport
+{
+
+ private List<Field> logFields = new ArrayList<Field>();
+ private List<org.jboss.seam.log.Log> logInstances = new
ArrayList<org.jboss.seam.log.Log>();
+
+ private MetaModel metaModel;
+
+ public LoggerSupport(MetaModel metaModel)
+ {
+ this.metaModel = metaModel;
+ }
+
+ public void add(Field field)
+ {
+ if ( field.isAnnotationPresent(org.jboss.seam.annotations.Logger.class) )
+ {
+ String category =
field.getAnnotation(org.jboss.seam.annotations.Logger.class).value();
+ org.jboss.seam.log.Log logInstance;
+ if ( "".equals( category ) )
+ {
+ logInstance = org.jboss.seam.log.Logging.getLog(metaModel.getBeanClass());
+ }
+ else
+ {
+ logInstance = org.jboss.seam.log.Logging.getLog(category);
+ }
+ if ( Modifier.isStatic( field.getModifiers() ) )
+ {
+ Reflections.setAndWrap(field, null, logInstance);
+ }
+ else
+ {
+ logFields.add(field);
+ logInstances.add(logInstance);
+ }
+ }
+ }
+
+ public void inject(Object instance) throws Exception
+ {
+ for (int i=0; i<logFields.size(); i++)
+ {
+ metaModel.setFieldValue( instance, logFields.get(i), "log",
logInstances.get(i) );
+ }
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModel.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModel.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModel.java 2008-02-04 13:32:52
UTC (rev 7355)
@@ -0,0 +1,144 @@
+package org.jboss.seam.wicket;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.jboss.seam.Model;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.util.Reflections;
+
+public abstract class MetaModel extends Model
+{
+
+ private InjectionSupport injectionSupport;
+ private OutjectionSupport outjectionSupport;
+ private LoggerSupport loggerSupport;
+
+ public MetaModel(Class<?> beanClass)
+ {
+ super(beanClass);
+ injectionSupport = new InjectionSupport(this);
+ outjectionSupport = new OutjectionSupport(this);
+ loggerSupport = new LoggerSupport(this);
+ scan();
+ }
+
+ public void initialize()
+ {
+ scan();
+ }
+
+ public void inject(Object instance) throws Exception
+ {
+ injectionSupport.inject(instance);
+ loggerSupport.inject(instance);
+ }
+
+ public void outject(Object instance)
+ {
+ outjectionSupport.outject(instance);
+ }
+
+ private void scan()
+ {
+ Class clazz = getBeanClass();
+ for ( ; clazz!=Object.class; clazz = clazz.getSuperclass() )
+ {
+ for ( Method method: clazz.getDeclaredMethods() )
+ {
+ scanMethod(method);
+ }
+
+ for ( Field field: clazz.getDeclaredFields() )
+ {
+ scanField(field);
+ }
+ }
+ }
+
+ private void scanField(Field field)
+ {
+ if ( !field.isAccessible() )
+ {
+ field.setAccessible(true);
+ }
+ injectionSupport.add(field);
+ loggerSupport.add(field);
+ }
+
+ private void scanMethod(Method method)
+ {
+ injectionSupport.add(method);
+ }
+
+ protected void setFieldValue(Object bean, Field field, String name, Object value)
+ {
+ try
+ {
+ Reflections.set(field, bean, value);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not set field value: " +
getAttributeMessage(name), e);
+ }
+ }
+
+ protected Object getFieldValue(Object bean, Field field, String name)
+ {
+ try {
+ return Reflections.get(field, bean);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not get field value: " +
getAttributeMessage(name), e);
+ }
+ }
+
+ protected String getAttributeMessage(String attributeName)
+ {
+ return getName() + '.' + attributeName;
+ }
+
+ protected String getName()
+ {
+ return getBeanClass().getName();
+ }
+
+ protected abstract String getMetaModelName();
+
+ protected void setPropertyValue(Object bean, Method method, String name, Object
value)
+ {
+ try
+ {
+ Reflections.invoke(method, bean, value );
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not set property value: " +
getAttributeMessage(name), e);
+ }
+ }
+
+ public Object getPropertyValue(Object bean, Method method, String name)
+ {
+ try {
+ return Reflections.invoke(method, bean);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("could not get property value: " +
getAttributeMessage(name), e);
+ }
+ }
+
+ public static MetaModel forName(String name)
+ {
+ if (Contexts.isApplicationContextActive())
+ {
+ return (MetaModel) Contexts.getApplicationContext().get(name);
+ }
+ else
+ {
+ throw new IllegalStateException("Application context is not active");
+ }
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModelUtils.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModelUtils.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/MetaModelUtils.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,48 @@
+package org.jboss.seam.wicket;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javassist.util.proxy.ProxyObject;
+
+import org.jboss.seam.util.ProxyFactory;
+
+public class MetaModelUtils
+{
+
+ public static String toName(String name, Method method)
+ {
+ //TODO: does not handle "isFoo"
+ if (name==null || name.length() == 0)
+ {
+ name = method.getName().substring(3, 4).toLowerCase()
+ + method.getName().substring(4);
+ }
+ return name;
+ }
+
+ public static String toName(String name, Field field)
+ {
+ if (name==null || name.length() == 0)
+ {
+ name = field.getName();
+ }
+ return name;
+ }
+
+ public static Class<ProxyObject> createProxyFactory(final Class beanClass)
+ {
+ ProxyFactory factory = new ProxyFactory();
+ if (beanClass.isInterface())
+ {
+ factory.setInterfaces(new Class[] {beanClass, Serializable.class});
+ }
+ else
+ {
+ factory.setSuperclass( beanClass );
+ }
+ return factory.createClass();
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/ModelValidator.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/ModelValidator.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/ModelValidator.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,51 @@
+package org.jboss.seam.wicket;
+
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.validation.IValidatable;
+import org.apache.wicket.validation.IValidationError;
+import org.apache.wicket.validation.IValidator;
+import org.apache.wicket.validation.ValidationError;
+import org.hibernate.validator.ClassValidator;
+import org.hibernate.validator.InvalidValue;
+import org.jboss.seam.core.Validators;
+
+
+/**
+ *
+ * An implementation of Hibernate Model Validation for Wicket
+ *
+ * @author Pete Muir
+ *
+ */
+public class ModelValidator implements IValidator
+{
+
+ private Class clazz;
+ private String property;
+
+ public ModelValidator(Class clazz, String property)
+ {
+ this.clazz = clazz;
+ this.property = property;
+ }
+
+ public ModelValidator(PropertyModel propertyModel)
+ {
+ this.clazz = propertyModel.getTarget().getClass();
+ this.property = propertyModel.getPropertyExpression();
+ }
+
+ public void validate(IValidatable validatable)
+ {
+ System.out.println("model validator " + property + " / " +
clazz);
+ ClassValidator classValidator = Validators.instance().getValidator(clazz);
+ InvalidValue[] invalidValues = classValidator.getPotentialInvalidValues(property,
validatable.getValue());
+ if (invalidValues.length > 0)
+ {
+ String message = invalidValues[0].getMessage();
+ IValidationError validationError = new ValidationError().setMessage(message);
+ validatable.error(validationError);
+ }
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/OutjectionSupport.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/OutjectionSupport.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/OutjectionSupport.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,94 @@
+package org.jboss.seam.wicket;
+
+import static org.jboss.seam.ScopeType.STATELESS;
+import static org.jboss.seam.ScopeType.UNSPECIFIED;
+import static org.jboss.seam.wicket.MetaModelUtils.toName;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.RequiredException;
+import org.jboss.seam.annotations.Out;
+
+
+public class OutjectionSupport
+{
+
+ private List<BijectedAttribute<Out>> outAttributes = new
ArrayList<BijectedAttribute<Out>>();
+
+ private MetaModel metaModel;
+
+ public OutjectionSupport(MetaModel metaModel)
+ {
+ this.metaModel = metaModel;
+ }
+
+ public void add(Method method)
+ {
+ Out out = method.getAnnotation(Out.class);
+ String name = toName( out.value(), method );
+ outAttributes.add( new BijectedMethod(name, method, out, metaModel) );
+ }
+
+ public void add(Field field)
+ {
+ if ( field.isAnnotationPresent(Out.class) )
+ {
+ Out out = field.getAnnotation(Out.class);
+ String name = toName( out.value(), field );
+ outAttributes.add(new BijectedField(name, field, out, metaModel) );
+ }
+ }
+
+ public void outject(Object instance)
+ {
+ for ( BijectedAttribute<Out> att: outAttributes )
+ {
+ outjectAttribute( att.getAnnotation(), att.getName(), instance,
att.get(instance) );
+ }
+ }
+
+ private void outjectAttribute(Out out, String name, Object bean, Object value)
+ {
+
+ if (value==null && out.required())
+ {
+ throw new RequiredException(
+ "@Out attribute requires non-null value: " +
+ metaModel.getAttributeMessage(name)
+ );
+ }
+ else
+ {
+ if ( out.scope()==UNSPECIFIED )
+ {
+ throw new IllegalArgumentException(
+ "Must specify a scope to outject to: " +
+ metaModel.getAttributeMessage(name)
+ );
+ }
+ else if ( out.scope()==STATELESS )
+ {
+ throw new IllegalArgumentException(
+ "cannot specify explicit scope=STATELESS on @Out: " +
+ metaModel.getAttributeMessage(name)
+ );
+ }
+
+ if ( out.scope().isContextActive() )
+ {
+ if (value==null)
+ {
+ out.scope().getContext().remove(name);
+ }
+ else
+ {
+ out.scope().getContext().set(name, value);
+ }
+ }
+ }
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamAuthorizationStrategy.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamAuthorizationStrategy.java
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamAuthorizationStrategy.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,72 @@
+package org.jboss.seam.wicket;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.Page;
+import org.apache.wicket.RestartResponseAtInterceptPageException;
+import org.apache.wicket.authorization.Action;
+import org.apache.wicket.authorization.IAuthorizationStrategy;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.NotLoggedInException;
+import org.jboss.seam.util.Strings;
+
+public class SeamAuthorizationStrategy implements IAuthorizationStrategy
+{
+
+ private LogProvider log = Logging.getLogProvider(SeamAuthorizationStrategy.class);
+ private Class loginPage;
+
+ public SeamAuthorizationStrategy()
+ {
+ this(null);
+ }
+
+ public SeamAuthorizationStrategy(final Class loginPage)
+ {
+ this.loginPage = loginPage;
+ }
+
+ // TODO Use permission schemes for this?
+ public boolean isActionAuthorized(Component component, Action action)
+ {
+ return isInstantiationAuthorized(component.getClass());
+ }
+
+ public boolean isInstantiationAuthorized(Class componentClass)
+ {
+ Restrict restrict = (Restrict) componentClass.getAnnotation(Restrict.class);
+ if ( restrict != null && Identity.isSecurityEnabled() )
+ {
+ String expr = !Strings.isEmpty( restrict.value() ) ? restrict.value() :
"#{identity.loggedIn}";
+ try
+ {
+ Identity.instance().checkRestriction(expr);
+ }
+ catch (NotLoggedInException e)
+ {
+ log.error("Unauthorized access to " + componentClass.getName() +
", user not logged in", e);
+ return handleException(componentClass);
+ }
+ catch (org.jboss.seam.security.AuthorizationException e)
+ {
+ log.error("Unauthorized access to " + componentClass.getName(),
e);
+ return handleException(componentClass);
+ }
+ }
+ return true;
+ }
+
+ private boolean handleException(Class componentClass)
+ {
+ if (Page.class.isAssignableFrom(componentClass))
+ {
+ // Redirect to page to let the user sign in
+ throw new RestartResponseAtInterceptPageException(loginPage);
+ }
+ return false;
+ }
+
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamLink.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamLink.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamLink.java 2008-02-04 13:32:52
UTC (rev 7355)
@@ -0,0 +1,39 @@
+package org.jboss.seam.wicket;
+
+import org.apache.wicket.markup.html.link.ILinkListener;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.util.value.ValueMap;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.core.Manager;
+
+public abstract class SeamLink extends Link
+{
+
+ public SeamLink(String id)
+ {
+ super(id);
+ }
+
+ public SeamLink(String id, IModel model)
+ {
+ super(id, model);
+ }
+
+ @Override
+ protected CharSequence getURL()
+ {
+ return getRequestCycle().urlFor(this, ILinkListener.INTERFACE, getParameterMap());
+ }
+
+ private ValueMap getParameterMap()
+ {
+ ValueMap valueMap = new ValueMap();
+ if (Conversation.instance().isLongRunning())
+ {
+ valueMap.add(Manager.instance().getConversationIdParameter(),
Conversation.instance().getId());
+ }
+ return valueMap;
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamSupport.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamSupport.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/SeamSupport.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jboss.seam.wicket;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.Component;
+import org.apache.wicket.application.IComponentInstantiationListener;
+
+/**
+ * Main support class for letting Wicket work with Seam annotations. Active
+ * support by calling {@link #activate(Application) the activate method}
+ * preferably from your {@link Application#init() application's init method}.
+ *
+ * @author eelcohillenius
+ * @author Pete Muir
+ */
+// TODO handle outjection etc. Might need onAfterRender and may
+// onBeforeRender for that, in which case this class can implement the
+// appropriate interfaces and register itself as a listener for them.
+// TODO handle method level sometime. For starters, see if there is any example/
+// test case/ whatever in Seam first that shows off that kind of usage
+public class SeamSupport implements IComponentInstantiationListener {
+
+ /**
+ * Activate support for Seam annotations on components for the provided
+ * application.
+ *
+ * @param application
+ * The application to active support for
+ */
+ public static void activate(Application application) {
+ SeamSupport listener = new SeamSupport();
+ application.addComponentInstantiationListener(listener);
+ }
+
+ /**
+ * @see
org.apache.wicket.application.IComponentInstantiationListener#onInstantiation(org.apache.wicket.Component)
+ */
+ public void onInstantiation(Component component)
+ {
+ WicketComponent wicketComponent = WicketComponent.forClass(component.getClass());
+ try
+ {
+ wicketComponent.inject(component);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/SimpleDataProvider.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/SimpleDataProvider.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/SimpleDataProvider.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,22 @@
+package org.jboss.seam.wicket;
+
+import java.io.Serializable;
+
+import org.apache.wicket.markup.repeater.data.IDataProvider;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+
+public abstract class SimpleDataProvider implements IDataProvider
+{
+
+ public IModel model(Object object)
+ {
+ return new Model((Serializable) object);
+ }
+
+ public void detach()
+ {
+ // No - op
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketComponent.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketComponent.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketComponent.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,47 @@
+package org.jboss.seam.wicket;
+
+import org.jboss.seam.contexts.Contexts;
+
+public class WicketComponent extends MetaModel
+{
+
+ public WicketComponent(Class<?> beanClass)
+ {
+ super(beanClass);
+ }
+
+ @Override
+ protected String getMetaModelName()
+ {
+ return getComponentName(getBeanClass());
+ }
+
+ protected static String getComponentName(Class clazz)
+ {
+ return clazz.getName() + ".wicketComponent";
+ }
+
+ public static WicketComponent forClass(Class clazz)
+ {
+ if (Contexts.isApplicationContextActive())
+ {
+ String metaModelName = getComponentName(clazz);
+ instantiate(metaModelName, clazz);
+ return (WicketComponent) forName(metaModelName);
+ }
+ else
+ {
+ throw new IllegalStateException("Application context is not active");
+ }
+ }
+
+ private static void instantiate(String componentName, Class clazz)
+ {
+ if (!Contexts.getApplicationContext().isSet(componentName))
+ {
+ WicketComponent component = new WicketComponent(clazz);
+ Contexts.getApplicationContext().set(componentName, component);
+ }
+ }
+
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketManager.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketManager.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketManager.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,48 @@
+package org.jboss.seam.wicket;
+
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.core.Manager;
+
+(a)Scope(ScopeType.EVENT)
+(a)Name("org.jboss.seam.core.manager")
+@Install(precedence=100, classDependencies="org.apache.wicket.Application")
+@BypassInterceptors
+public class WicketManager extends Manager
+{
+
+ private boolean controllingRedirect;
+
+ public String appendConversationIdFromRedirectFilter(String url, String viewId)
+ {
+ boolean appendConversationId = !controllingRedirect;
+ if (appendConversationId)
+ {
+ beforeRedirect(viewId);
+ url = encodeConversationId(url, viewId);
+ }
+ return url;
+ }
+
+ /**
+ * Temporarily promote a temporary conversation to
+ * a long running conversation for the duration of
+ * a browser redirect. After the redirect, the
+ * conversation will be demoted back to a temporary
+ * conversation. Handle any changes to the conversation
+ * id, due to propagation via natural id.
+ */
+ public void beforeRedirect(String viewId)
+ {
+ // TODO - do something here!
+ }
+
+ public static WicketManager instance()
+ {
+ return (WicketManager) Manager.instance();
+ }
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketRedirectFilter.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketRedirectFilter.java
(rev 0)
+++
trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketRedirectFilter.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,43 @@
+package org.jboss.seam.wicket;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.annotations.web.Filter;
+import org.jboss.seam.web.AbstractFilter;
+
+/**
+ *
+ * @author Kill the redirect filter
+ */
+@Scope(APPLICATION)
+(a)Name("org.jboss.seam.web.redirectFilter")
+@Install(precedence = 100, classDependencies="org.apache.wicket.Application")
+@BypassInterceptors
+(a)Filter(within="org.jboss.seam.web.ajax4jsfFilter")
+public class WicketRedirectFilter extends AbstractFilter
+{
+
+
+ @Override
+ public boolean isDisabled()
+ {
+ return true;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException, ServletException
+ {
+
+
+ }
+}
Added: trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketSeamFilter.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketSeamFilter.java
(rev 0)
+++ trunk/examples/wicket/src/web/org/jboss/seam/wicket/WicketSeamFilter.java 2008-02-04
13:32:52 UTC (rev 7355)
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jboss.seam.wicket;
+
+import static org.jboss.seam.ScopeType.APPLICATION;
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.io.IOException;
+import java.util.Set;
+
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.protocol.http.WicketFilter;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.annotations.web.Filter;
+import org.jboss.seam.contexts.Context;
+import org.jboss.seam.contexts.ServletLifecycle;
+import org.jboss.seam.core.ConversationPropagation;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.servlet.ContextualHttpServletRequest;
+import org.jboss.seam.servlet.ServletRequestSessionMap;
+import org.jboss.seam.web.AbstractFilter;
+import org.jboss.seam.web.ServletContexts;
+
+/**
+ * Seam component that delegates requests to the {@link WicketFilter} and sets
+ * up and pulls down Seam {@link Context}s for the request.
+ * <p>
+ * Users do not have to install this filter, but instead just install
+ * {@link WicketFilter} like they would normally do. This Seam component
+ * automatically attaches to it.
+ * </p>
+ * <p>
+ * The filter automatically picks up the {@link WebApplication} when there is
+ * only one active for the web application this filter is configured for. If
+ * there are multiple Wicket applications active in the web application, you'll
+ * have to explicitly configure which one to use by providing filter init
+ * parameter 'applicationName', which corresponds to the filter name of the
+ * Wicket filter for the application you want to use this filter with.
+ * </p>
+ *
+ * @author eelcohillenius
+ */
+@Scope(APPLICATION)
+(a)Name("org.apache.wicket.seam.WicketSeamFilter")
+@Install(classDependencies = { "org.apache.wicket.protocol.http.WebApplication"
}, precedence = BUILT_IN)
+@BypassInterceptors
+@Filter()
+public class WicketSeamFilter extends AbstractFilter {
+
+ private static final class WicketSeamFilterConfigurationException extends
+ IllegalStateException {
+ public WicketSeamFilterConfigurationException(String msg) {
+ super(msg);
+ }
+ }
+
+ private static final String APPLICATION_NONE = "<none>";
+
+ private static LogProvider log = Logging.getLogProvider(WicketSeamFilter.class);
+
+ private String applicationName = null;
+
+ private WicketFilter delegate = null;
+
+ /**
+ * Construct.
+ */
+ public WicketSeamFilter() {
+ }
+
+ @SuppressWarnings("unchecked")
+ public void doFilter(final ServletRequest servletRequest,
+ final ServletResponse servletResponse, final FilterChain filterChain)
+ throws IOException, ServletException {
+
+ // Check for the Wicket filter (which might be initialized after this
+ // filter, hence the lazy loading). Synchronization is not important.
+ if (delegate == null && !APPLICATION_NONE.equals(applicationName)) {
+
+ if (applicationName == null) {
+ Set<String> applicationKeys = Application.getApplicationKeys();
+ if (applicationKeys.size() > 1) {
+ throw new WicketSeamFilterConfigurationException(
+ "If you run this filter in the context of multiple Wicket "
+ + "application instances (/ filters) you have to provide filer "
+ + "init parameter 'applicationName' which should correspond to
"
+ + "the filter name you want to use this filter with.");
+ } else if (applicationKeys.size() == 0) {
+ // no Wicket apps configured... set to special name
+ applicationName = APPLICATION_NONE;
+ } else {
+ applicationName = applicationKeys.iterator().next();
+ }
+ }
+ Application application = (!APPLICATION_NONE
+ .equals(applicationName)) ? Application
+ .get(applicationName) : null;
+ if (application != null && !(application instanceof WebApplication)) {
+ log
+ .warn("This filter can only be used with Wicket WebApplications. Currently,
"
+ + "it is configured to work with an application of type "
+ + application.getClass().getName());
+ applicationName = APPLICATION_NONE;
+ filterChain.doFilter(servletRequest, servletResponse);
+ return;
+ }
+
+ WebApplication webApplication = (WebApplication) application;
+ if (webApplication == null) {
+ log
+ .warn("ignoring request: no Wicket web application instance found");
+ applicationName = APPLICATION_NONE;
+ filterChain.doFilter(servletRequest, servletResponse);
+ return;
+ }
+
+ delegate = webApplication.getWicketFilter();
+ }
+
+ new ContextualHttpServletRequest((HttpServletRequest) servletRequest)
+ {
+ @Override
+ public void process() throws Exception
+ {
+ delegate.doFilter(servletRequest, servletResponse, filterChain);
+ }
+
+ }.run();
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ super.init(filterConfig);
+ this.applicationName = filterConfig.getInitParameter("applicationName");
+ }
+}
Added: trunk/examples/wicket/view/conversations.xhtml
===================================================================
--- trunk/examples/wicket/view/conversations.xhtml (rev 0)
+++ trunk/examples/wicket/view/conversations.xhtml 2008-02-04 13:32:52 UTC (rev 7355)
@@ -0,0 +1,36 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:c="http://java.sun.com/jstl/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:s="http://jboss.com/products/seam/taglib">
+ <div>
+
+ <div class="section">
+ <h1><h:outputText rendered="#{not empty conversationList}"
value="Workspaces"/></h1>
+ </div>
+
+ <div class="section">
+ <h:form>
+ <h:dataTable value="#{conversationList}" var="entry">
+ <h:column>
+ <h:commandLink action="#{entry.select}"
value="#{entry.description}"/>
+  
+ <h:outputText value="[current]"
rendered="#{entry.current}"/>
+ </h:column>
+ <h:column>
+ <h:outputText value="#{entry.startDatetime}">
+ <s:convertDateTime type="time"
pattern="hh:mm"/>
+ </h:outputText>
+ -
+ <h:outputText value="#{entry.lastDatetime}">
+ <s:convertDateTime type="time"
pattern="hh:mm"/>
+ </h:outputText>
+ </h:column>
+ </h:dataTable>
+ </h:form>
+ </div>
+
+ </div>
+</ui:composition>
\ No newline at end of file
Property changes on: trunk/examples/wicket/view/conversations.xhtml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/view/css/screen.css
===================================================================
--- trunk/examples/wicket/view/css/screen.css (rev 0)
+++ trunk/examples/wicket/view/css/screen.css 2008-02-04 13:32:52 UTC (rev 7355)
@@ -0,0 +1,274 @@
+/* Setup defaults since variable in browsers
+----------------------------------------------- */
+body, div, span, dd, dt, dl, img, ul, ol, li, p, h1, h2, h3, h4, h5, form, hr, fieldset
{
+ margin: 0;
+ padding: 0;
+}
+/* Element Defaults
+----------------------------------------------- */
+html {
+ height: 100%;
+ background-color: #DBD4C6;
+}
+img {
+ border: 0;
+}
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: small;
+ line-height: 1.25em;
+ color: #362F2D;
+ position: relative;
+ width: 760px;
+ height: 100%;
+ margin-left: auto;
+ margin-right: auto;
+}
+.label {
+ font-weight: bold;
+ color: #5E5147;
+}
+input {
+ border: 1px solid #C3BBB6;
+ padding: 4px;
+ margin: 5px 0;
+ background: #fff url(../img/input.bg.gif) 0 0 repeat-x;
+}
+select {
+ border: 1px solid #C3BBB6;
+ padding: 4px;
+ margin: 5px 0;
+ background: #fff url(../img/input.bg.gif) 0 0 repeat-x;
+}
+ol, ul {
+ margin: 10px 0px 10px 6px;
+}
+li {
+ margin: 10px 12px;
+}
+fieldset {
+ border: 0;
+}
+/* Layout
+----------------------------------------------- */
+#document {
+ padding: 0 1px;
+ background: #fff url(../img/bg.gif) 0 0 repeat-y;
+ float: left;
+ border-bottom: 1px solid #C3BBB6;
+}
+#header {
+ float: left;
+ width: 758px;
+ height: 46px;
+ background: url(../img/hdr.bg.gif) 0 0 repeat-x;
+}
+#container {
+ float: left;
+ width: 758px;
+ background: url(../img/hdr.bar.jpg) 0 0 repeat-x;
+}
+#sidebar {
+ float: left;
+ width: 190px;
+ margin-top: 96px;
+ padding: 20px 10px 0 10px;
+ background: url(../img/sdb.bg.gif) 0 0 no-repeat;
+}
+#content {
+ float: left;
+ width: 548px;
+ margin-top: 75px;
+ padding-top: 5px;
+ background: #fff url(../img/cnt.bg.gif) 0 0 repeat-x;
+}
+#footer {
+ clear: both;
+ margin-top: 40px;
+ float: left;
+ padding: 20px;
+ border-top: 1px solid #C3BBB6;
+ background-color: #fff;
+ width: 718px;
+ text-align: right;
+}
+/* General
+----------------------------------------------- */
+input[type="submit"], input[type="button"] {
+ font-weight: bold;
+ color: #fff;
+ border: 1px solid #5D1414;
+ height: 26px;
+ background: #fff url(../img/btn.bg.gif) 0 0 repeat-x;
+ border-style: none;
+}
+.center {
+ text-align: center;
+}
+.entry {
+ clear: both;
+ padding-top: 10px;
+}
+.entry .label {
+ float: left;
+ padding-right: 5px;
+ font-weight: bold;
+ width: 150px;
+ text-align: right;
+}
+.entry .output {
+ float: right;
+ width: 360px;
+ padding-top: 10px;
+ text-align: left;
+}
+.entry .input {
+ float: right;
+ width: 360px;
+ text-align: left;
+}
+.entry .error {
+ float: right;
+ width: 360px;
+ text-align: left;
+}
+/* Sidebar
+----------------------------------------------- */
+.notes {
+ text-align: center;
+ font-size: small;
+}
+.errors {
+ font-size: small;
+ font-weight: bold;
+ text-align: center;
+ color: #600;
+}
+.errors div {
+ text-align: left;
+}
+.errors span {
+ text-align: left;
+}
+.errors input {
+ border: 1px solid #600;
+}
+.errors ul {
+ list-style: none;
+}
+.buttonBox {
+ text-align: center;
+ padding: 5px 0;
+ clear: both;
+}
+#sidebar p {
+ font-size: small;
+ color: #8B7869;
+ line-height: 150%;
+ padding-bottom: 10px;
+}
+#sidebar li {
+ font-size: small;
+ color: #8B7869;
+}
+#sidebar h1 {
+ line-height: normal;
+ font-weight: bold;
+ font-size: small;
+}
+/*
+#sidebar p:hover {
+ color: #362F2D;
+}
+*/
+/* Content
+----------------------------------------------- */
+#content .section {
+ float: left;
+ width: 518px;
+ padding: 15px 15px 0 15px;
+}
+#content .section h1 {
+ font-family: "Trebuchet MS", Arial, sans-serif;
+ line-height: normal;
+ font-weight: normal;
+ font-size: large;
+}
+#content .section p {
+ line-height: 150%;
+ padding: 10px 0;
+ font-size: small;
+}
+#content table {
+ width: 100%;
+ border: 1px solid #D2C9C4;
+ border-collapse: collapse;
+}
+#content table caption {
+ padding-bottom: 6px;
+ text-align: left;
+ font-weight: bold;
+}
+#content table thead th {
+ border-left: 1px solid #D2C9C4;
+ background: #fff url(../img/th.bg.gif) 0 100% repeat-x;
+ border-bottom: 1px solid #D2C9C4;
+ padding: 6px;
+ text-align: left;
+ font-size: small;
+}
+#content table tbody td {
+ border-left: 1px solid #E4DBD5;
+ padding: 4px;
+ border-bottom: 1px solid #D2C9C4;
+ font-size: small;
+}
+#content dt {
+ font-weight: bold;
+ float: left;
+ width: 33%;
+}
+#content dd {
+ padding-left: 10px;
+ float: left;
+ width: 66%;
+}
+#content table.radio {
+ border: 0px;
+}
+#content table.radio tbody tr td {
+ border: 0px;
+ border-left: 0px;
+ border-bottom: 0px;
+}
+/* Header
+----------------------------------------------- */
+#title {
+ float: left;
+ padding: 1px 0 6px 15px;
+}
+#status {
+ color: #C7B299;
+ float: right;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ font-size: x-small;
+ text-align: right;
+ padding-top: 14px;
+ padding-right: 15px;
+}
+#status a {
+ color: #C7B299;
+ text-decoration: none;
+}
+/* Homepage Modifications
+----------------------------------------------- */
+#pgHome #container {
+ background: url(../img/hdr.ad.jpg) 0 0 repeat-x;
+}
+#pgHome #sidebar {
+ margin-top: 207px;
+}
+#pgHome #content {
+ margin-top: 183px;
+}
Property changes on: trunk/examples/wicket/view/css/screen.css
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/wicket/view/css/trailblazer_main.css
===================================================================
--- trunk/examples/wicket/view/css/trailblazer_main.css (rev 0)
+++ trunk/examples/wicket/view/css/trailblazer_main.css 2008-02-04 13:32:52 UTC (rev
7355)
@@ -0,0 +1,148 @@
+* {
+ margin: 0px;
+ padding: 0px;
+ border: none;
+}
+
+body {
+ font: 1em verdana, arial, sans-serif;
+ background: #CCCCCC;
+}
+
+div#main {
+ margin-left: 0px;
+ width: 751px;
+ background: #ecefdf;
+}
+
+div#top,div#pictures{
+}
+
+div#pictures img {
+ float:left;
+}
+
+img#head1 {
+ margin-right: 3px;
+}
+
+img#head2 {
+ margin-right: 4px;
+}
+
+div.trail {
+ clear:both;
+ margin-left: 50px;
+ margin-top: 0px;
+ margin-right: 50px
+}
+
+div.foot {
+ margin-left: 50px;
+ margin-right: 50px;
+ margin-top: 50px;
+ text-align: center;
+ font-size: .5em;
+ height: 36px;
+}
+
+div.trail h1 {
+ margin-top: -30px;
+ margin-left: -50px;
+ font-size: 1.2em;
+ font-weight: bold;
+ padding-left: .4em;
+}
+
+div.trail h2 {
+ float: left;
+ font-size: 1em;
+ font-weight: bold;
+ padding-left: .4em;
+}
+
+div.trail h3 {
+ float: left;
+ font-size: .8em;
+ font-weight: bold;
+ margin-left: -1.4em;
+ margin-bottom: 1em;
+}
+
+
+div.trail p {
+ clear: both;
+ margin-top: 20px;
+ font-size: .8em;
+ text-decoration: none;
+}
+
+div#next_trail {
+ margin-left: 36px;
+}
+
+div.numbox {
+ border: thin solid black;
+ margin-left: -.8em;
+ float: left;
+ background: #ffffff;
+ padding: .2em .35em .3em;
+ font-style: normal;
+ font-weight: bold;
+ font-size: 1.4em;
+}
+
+div.figure {
+ text-align: center;
+ font-size: .6em;
+ margin-top: 30px;
+}
+
+div.figure img {
+ display: block;
+ margin-right: auto;
+ margin-left: auto;
+}
+
+code {
+ font: 1.1em "Courier New", Courier, mono;
+}
+
+code.block {
+ white-space: pre;
+ font: 10pt "Courier New", Courier, mono;
+ display: block;
+ border-style: dashed;
+ border-width: thin;
+ padding: .5em;
+ background: #ffffff;
+ margin: 20px;
+}
+
+div.foot_image {
+ float: left;
+ height: 86px;
+}
+
+a:active {
+ color : #666666;
+ text-decoration: none;
+}
+
+a:hover {
+ color : #000000;
+ background-color : #D6E0FE;
+ text-decoration: none;
+}
+
+a:link {
+ color : #005EB6;
+ text-decoration: none;
+}
+
+a:visited {
+ color : #888888;
+ text-decoration: none;
+}
+
+
Added: trunk/examples/wicket/view/img/bg.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/bg.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/btn.bg.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/btn.bg.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/cal-next.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/cal-next.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/cal-prev.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/cal-prev.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/cnt.bg.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/cnt.bg.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/dtpick.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/dtpick.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/hdr.ad.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/hdr.ad.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/hdr.bar.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/hdr.bar.jpg
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/hdr.bg.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/hdr.bg.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/hdr.title.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/hdr.title.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/header_line.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/header_line.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/input.bg.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/input.bg.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/sdb.bg.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/sdb.bg.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/spinner.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/spinner.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/wicket/view/img/th.bg.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/wicket/view/img/th.bg.gif
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream