r2003 - in trunk: . nuiton-tapestry-extra nuiton-tapestry-extra/src nuiton-tapestry-extra/src/license nuiton-tapestry-extra/src/main nuiton-tapestry-extra/src/main/java nuiton-tapestry-extra/src/main/java/org nuiton-tapestry-extra/src/main/java/org/nuiton nuiton-tapestry-extra/src/main/java/org/nuiton/web nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5 nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations nuiton-tapestry-extra/src/main/java/org/nuiton/w
Author: tchemit Date: 2010-12-30 13:09:09 +0100 (Thu, 30 Dec 2010) New Revision: 2003 Url: http://nuiton.org/repositories/revision/nuiton-utils/2003 Log: Evolution #1190: Introduce nuiton-tapestry-extra module Added: trunk/nuiton-tapestry-extra/ trunk/nuiton-tapestry-extra/LICENSE.txt trunk/nuiton-tapestry-extra/README.txt trunk/nuiton-tapestry-extra/changelog.txt trunk/nuiton-tapestry-extra/pom.xml trunk/nuiton-tapestry-extra/src/ trunk/nuiton-tapestry-extra/src/license/ trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties trunk/nuiton-tapestry-extra/src/main/ trunk/nuiton-tapestry-extra/src/main/java/ trunk/nuiton-tapestry-extra/src/main/java/org/ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java trunk/nuiton-tapestry-extra/src/main/resources/ trunk/nuiton-tapestry-extra/src/main/resources/org/ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/SubForm.tml trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js trunk/nuiton-tapestry-extra/src/site/ trunk/nuiton-tapestry-extra/src/site/apt/ trunk/nuiton-tapestry-extra/src/site/apt/index.apt trunk/nuiton-tapestry-extra/src/site/site_fr.xml trunk/nuiton-tapestry-extra/src/test/ trunk/nuiton-tapestry-extra/src/test/java/ trunk/nuiton-tapestry-extra/src/test/resources/ Modified: trunk/pom.xml Property changes on: trunk/nuiton-tapestry-extra ___________________________________________________________________ Added: svn:ignore + target velocity.log maven.log .eclipse .classpath *.iml *.ipr *.iws .settings .project Added: trunk/nuiton-tapestry-extra/LICENSE.txt =================================================================== --- trunk/nuiton-tapestry-extra/LICENSE.txt (rev 0) +++ trunk/nuiton-tapestry-extra/LICENSE.txt 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,166 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. + Property changes on: trunk/nuiton-tapestry-extra/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: trunk/nuiton-tapestry-extra/README.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Property changes on: trunk/nuiton-tapestry-extra/changelog.txt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/pom.xml =================================================================== --- trunk/nuiton-tapestry-extra/pom.xml (rev 0) +++ trunk/nuiton-tapestry-extra/pom.xml 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,170 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Nuiton Utils :: Nuiton Tapestry Extra + $Id$ + $HeadURL: http://svn.nuiton.org/svn/nuiton-utils/trunk/nuiton-utils-extra/pom.xml $ + %% + Copyright (C) 2004 - 2010 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils-parent</artifactId> + <version>2.0-SNAPSHOT</version> + </parent> + + <artifactId>nuiton-tapestry-extra</artifactId> + + <dependencies> + + <!--dependency> + <groupId>${project.groupId}</groupId> + <artifactId>nuiton-utils</artifactId> + <version>${project.version}</version> + </dependency--> + + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + </dependency> + + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.tapestry</groupId> + <artifactId>tapestry-core</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.tapestry</groupId> + <artifactId>tapestry-ioc</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.tapestry</groupId> + <artifactId>tapestry5-annotations</artifactId> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + </dependencies> + + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + + <name>Nuiton Utils :: Nuiton Tapestry Extra</name> + <description>Extra classes for Tapestry based applications</description> + <inceptionYear>2010</inceptionYear> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <properties> + + <!-- extra files to include in release --> + <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles> + + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <compress>true</compress> + <index>true</index> + <!-- Add NuitonModule to manifest for Tapestry IOC engine --> + <manifestEntries> + <Tapestry-Module-Classes> + org.nuiton.web.tapestry5.services.NuitonModule + </Tapestry-Module-Classes> + <Implementation-Version> + ${project.version} + </Implementation-Version> + </manifestEntries> + </archive> + </configuration> + </plugin> + + </plugins> + </build> + + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> + + <profiles> + <profile> + <id>reporting</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + + <reporting> + <plugins> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <quiet>true</quiet> + <links> + <link>http://java.sun.com/javase/6/docs/api/</link> + </links> + </configuration> + </plugin> + </plugins> + </reporting> + + </profile> + + </profiles> + +</project> Property changes on: trunk/nuiton-tapestry-extra/pom.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties =================================================================== --- trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties (rev 0) +++ trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,17 @@ +# Generated by org.nuiton.license.plugin.AddThirdPartyMojo +#------------------------------------------------------------------------------- +# Already used licenses in project : +# - Apache Software License 2.0 +# - BSD License +# - Common Public License Version 1.0 +# - Lesser General Public License (LGPL) v 2.1 +# - MIT License +# - The Apache Software License, Version 2.0 +# - The BSD License +#------------------------------------------------------------------------------- +# Please fill the missing licenses for dependencies : +# +# +#Thu Dec 30 13:07:08 CET 2010 +javassist--javassist--3.9.0.GA--jar=Lesser General Public License (LGPL) v 2.1 +org.antlr--antlr-runtime--3.1.1--jar=BSD License Property changes on: trunk/nuiton-tapestry-extra/src/license/THIRD-PARTY.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,48 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.nuiton.web.tapestry5.annotations; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This annotation is used on pages and components that need authentication + * to be rendered. + * + * Created: 3 mai 2010 + * + * @author fdesbois + * $Id$ + */ +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RequiresAuthentication { + +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/annotations/RequiresAuthentication.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,158 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.web.tapestry5.components; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tapestry5.BindingConstants; +import org.apache.tapestry5.ComponentResources; +import org.apache.tapestry5.MarkupWriter; +import org.apache.tapestry5.annotations.IncludeStylesheet; +import org.apache.tapestry5.annotations.Log; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.ioc.annotations.Inject; + +/** + * Composant qui affiche des messages à l'utilisateur. + * + * Ce composant permet d'afficher des messages avec une apparence différente + * selon leur type (info ou erreur). Lors de l'affichage de la page, les + * messages seront affichés et la collection de messages sera vidée. + * + * Pour personnaliser l'apparence des messages il faut définir les classes + * fb-error et fb-info dans le CSS. + * + * <pre> + * Utilisation : + * <t:feedback t:id="feedback"/> + * @Component(id = "feedback") private FeedBack feedback; + * feedback.addInfo("message d'info"); + * feedback.addError("message d'erreur"); + * </pre> + * + * @author rannou + * @version $Id$ + */ +@IncludeStylesheet("feedback.css") +public class FeedBack { + + @Parameter(defaultPrefix = BindingConstants.LITERAL, value= "true") + private boolean autoClear; + + /** Messages d'erreur */ + private List<String> errorMessages; + + /** Messages d'info */ + private List<String> infoMessages; + + private boolean errors; + + @Inject + private ComponentResources resources; + + private boolean reload; + + public FeedBack() { + errorMessages = new ArrayList<String>(); + infoMessages = new ArrayList<String>(); + } + + void beginRender(MarkupWriter writer) { + + // Rendu des messages d'erreur et vidage de la collection + if (!errorMessages.isEmpty()) { + errors = true; + writer.element("div", "class", "fb-error"); + for (String message : errorMessages) { + writer.write(message); + writer.element("br"); + writer.end(); + } + writer.end(); + } + if (autoClear) { + errorMessages.clear(); + } + + // Rendu des messages d'info et vidage de la collection + if (!infoMessages.isEmpty()) { + writer.element("div", "class", "fb-info"); + for (String message : infoMessages) { + writer.write(message); + writer.element("br"); + writer.end(); + } + writer.end(); + } + infoMessages.clear(); + + resources.renderInformalParameters(writer); + } + + void afterRender(MarkupWriter writer) { + + } + + /** + * Ajout d'un message d'info. + * + * @param message le message + */ + public void addInfo(String message) { + if (!infoMessages.contains(message)) { + infoMessages.add(message); + } + } + + /** + * Ajout d'un message d'erreur. + * + * @param message le message + */ + public void addError(String message) { + if (!errorMessages.contains(message)) { + errorMessages.add(message); + } + } + + public boolean hasErrors() { + return errors; + } + + @Log + public void reload() { + reload = true; + } + + public boolean hasBeeanReloaded() { + return reload; + } + + public void clearErrors() { + errorMessages.clear(); + reload = false; + } +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/FeedBack.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,61 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.web.tapestry5.components; + +import org.apache.tapestry5.Block; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.slf4j.Logger; + +/** + * Created: 14 mai 2010 + * + * @author fdesbois <fdesbois@codelutin.com> + * @version $Id$ + */ +public class SubForm { + + @Parameter + private boolean visible; + + @Inject + private Logger logger; + + @Inject + private Block formBlock; + + @Inject + private Block noFormBlock; + + public Block getActiveBlock() { + if (logger.isDebugEnabled()) { + logger.debug("form already visible : " + visible); + } + if (visible) { + return formBlock; + } + return noFormBlock; + } +} \ No newline at end of file Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubForm.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,214 @@ +/** %%Ignore-License + * + * Copyright 2007 The Apache Software Foundation + * + * Licensed 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.nuiton.web.tapestry5.components; + +import org.apache.tapestry5.Asset; +import org.apache.tapestry5.BindingConstants; +import org.apache.tapestry5.ClientElement; +import org.apache.tapestry5.ComponentAction; +import org.apache.tapestry5.ComponentResources; +import org.apache.tapestry5.EventConstants; +import org.apache.tapestry5.MarkupWriter; +import org.apache.tapestry5.RenderSupport; +import org.apache.tapestry5.annotations.Environmental; +import org.apache.tapestry5.annotations.Events; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.annotations.SupportsInformalParameters; +import org.apache.tapestry5.dom.Element; +import org.apache.tapestry5.ioc.annotations.Inject; +import org.apache.tapestry5.services.FormSupport; +import org.apache.tapestry5.services.Heartbeat; +import org.apache.tapestry5.services.Request; + +/** + * Corresponds to <input type="submit">, a client-side element that can + * force the enclosing form to submit. The submit responsible for the form + * submission will post a notification that allows the application to know that + * it was the responsible entity. The notification is named "selected" and has a + * String context. The major difference between this component and Tapestry's + * Submit component is that this component's context is immutable and can, for + * example, be set to different values within a loop. + */ +@SupportsInformalParameters +@Events(EventConstants.SELECTED + " by default, may be overridden") +public final class SubmitContext implements ClientElement { + + /** + * If true, then any notification sent by the component will be deferred + * until the end of the form submission (this is usually desirable). + */ + @Parameter + private boolean defer = true; + + /** + * The name of the event that will be triggered if this component is the + * cause of the form submission. The default is "selected". + */ + @Parameter(allowNull = false, defaultPrefix = BindingConstants.LITERAL) + private String event = EventConstants.SELECTED; + + /** + * If true, then the field will render out with a disabled attribute (to + * turn off client-side behavior). Further, a disabled field ignores any + * value in the request when the form is submitted. + */ + @Parameter("false") + private boolean disabled; + + /** + * The value that will be made available to event handler method of this + * component when the form is submitted. + */ + @Parameter + private String context; + + /** + * If provided, the component renders an input tag with type "image". + * Otherwise "submit". + */ + @Parameter(defaultPrefix = BindingConstants.ASSET) + private Asset image; + + @Environmental + private FormSupport formSupport; + + @Environmental + private Heartbeat heartbeat; + + @Inject + private ComponentResources resources; + + @Inject + private Request request; + + @Inject + private RenderSupport renderSupport; + + private Element element; + + private String clientId; + + private static class ProcessSubmission implements ComponentAction<SubmitContext> { + + private final String elementName; + + private final String context; + + public ProcessSubmission(String elementName, String context) { + this.elementName = elementName; + this.context = context; + } + + public void execute(SubmitContext component) { + component.processSubmission(elementName, context); + } + } + + public SubmitContext() { + } + + SubmitContext(Request request) { + this.request = request; + } + + void beginRender(MarkupWriter writer) { + clientId = null; + + String name = formSupport.allocateControlName(resources.getId()); + + // Save the element, to see if an id is later requested. + + String type = image == null ? "submit" : "image"; + + element = writer.element("input", "type", type, "name", name); + + if (disabled) { + writer.attributes("disabled", "disabled"); + } + + if (image != null) { + writer.attributes("src", image.toClientURL()); + } + + formSupport.store(this, new ProcessSubmission(name, context)); + + resources.renderInformalParameters(writer); + } + + void afterRender(MarkupWriter writer) { + writer.end(); + } + + void processSubmission(final String elementName, final String context) { + if (disabled) { + return; + } + + String value = request.getParameter(elementName); + + if (value == null) { + return; + } + + Runnable sendNotification = new Runnable() { + public void run() { + resources.triggerEvent(event, new Object[]{context}, null); + } + }; + + // When not deferred, don't wait, fire the event now (actually, at the end of the current + // heartbeat). This is most likely because the Submit is inside a Loop and some contextual + // information will change if we defer. + + if (defer) { + formSupport.defer(sendNotification); + } else { + heartbeat.defer(sendNotification); + } + } + + // For testing: + + void setDefer(boolean defer) { + this.defer = defer; + } + + void setup(ComponentResources resources, FormSupport formSupport, Heartbeat heartbeat, RenderSupport renderSupport) { + this.resources = resources; + this.formSupport = formSupport; + this.heartbeat = heartbeat; + this.renderSupport = renderSupport; + } + + /** + * Returns the component's client id. This must be called after the + * component has rendered. The id is allocated lazily (first time this + * method is invoked). + * + * @return client id for the component + */ + public String getClientId() { + if (clientId == null) { + clientId = renderSupport.allocateClientId(resources); + + element.forceAttributes("id", clientId); + } + + return clientId; + } +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/components/SubmitContext.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,172 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.nuiton.web.tapestry5.data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.collections.CollectionUtils; +import org.apache.tapestry5.beaneditor.PropertyModel; +import org.apache.tapestry5.grid.ColumnSort; +import org.apache.tapestry5.grid.GridDataSource; +import org.apache.tapestry5.grid.SortConstraint; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * AbstractMappedGridDataSource + * + * TODO : javadoc + * + * Created: 18 janv. 2010 + * + * @param <K> Type of the map key + * @param <E> Type of the map value + * @author fdesbois <fdesbois@codelutin.com> + */ +public abstract class AbstractMappedGridDataSource<K, E> + implements GridDataSource { + + private Logger log = + LoggerFactory.getLogger(AbstractMappedGridDataSource.class); + + private Map<K, E> mapResults; + + private List<E> listResults; + + private int nbRows = -1; + + private int nbRowsPerPage; + + private boolean prepared; + + /** Need to be provided by subclass, used by Grid component **/ + @Override + public abstract Class<?> getRowType(); + + protected abstract int count(); + + protected abstract Map<K, E> execute(int startIndex, int endIndex, + SortConstraint orderBy); + + @Override + public int getAvailableRows() { + if (nbRows < 0) { + nbRows = count(); + if (log.isDebugEnabled()) { + log.debug("Count : " + nbRows); + } + } + return nbRows; + } + + @Override + public void prepare(int startIndex, int endIndex, + List<SortConstraint> sortConstraints) { + if (log.isDebugEnabled()) { + log.debug("Prepare results : " + startIndex + ", " + endIndex); + } + nbRowsPerPage = endIndex - startIndex + 1; + mapResults = execute(startIndex, endIndex, + getSortConstraint(sortConstraints)); + listResults = new ArrayList<E>(mapResults.values()); + prepared = true; + } + + @Override + public Object getRowValue(int index) { + index = index % nbRowsPerPage; + if (index >= listResults.size()) { + if (log.isErrorEnabled()) { + log.error("Size error : " + index + " / " + listResults.size()); + } + return null; + } + return CollectionUtils.get(listResults, index); + } + + /** + * Detect if the data has already been prepared. This will prevent errors + * on calling {@link #get(Object)}, {@link #values()} and + * {@link #contains(Object)} methods. + * + * @return true if data is ready, false otherwise. + */ + public boolean isPrepared() { + return prepared; + } + + public E get(K key) { + if (mapResults == null) { + return null; + } + return mapResults.get(key); + } + + public List<E> values() { + if (listResults == null) { + listResults = new ArrayList<E>(); + } + return listResults; + } + + public boolean contains(K key) { + if (mapResults == null) { + return false; + } + return mapResults.containsKey(key); + } + + protected SortConstraint getSortConstraint( + List<SortConstraint> sortConstraints) { + for (SortConstraint constraint : sortConstraints) { + final ColumnSort sort = constraint.getColumnSort(); + if (sort != ColumnSort.UNSORTED) { + return constraint; + } + } + return null; + } + + protected String resolveOrderBy(SortConstraint orderBy) { + String filterOrder = null; + if (orderBy != null) { + PropertyModel property = orderBy.getPropertyModel(); + filterOrder = property.getPropertyName(); + + ColumnSort sort = orderBy.getColumnSort(); + if (sort.equals(ColumnSort.DESCENDING)) { + filterOrder += " desc"; + } + + if (log.isDebugEnabled()) { + log.debug("Order : " + filterOrder); + } + } + return filterOrder; + } + +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/data/AbstractMappedGridDataSource.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,72 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.web.tapestry5.mixins; + +import org.apache.tapestry5.BindingConstants; +import org.apache.tapestry5.ClientElement; +import org.apache.tapestry5.RenderSupport; +import org.apache.tapestry5.annotations.AfterRender; +import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary; +import org.apache.tapestry5.annotations.InjectContainer; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.ioc.annotations.Inject; + +/** + * A simple mixin for attaching a javascript confirmation box to the onclick + * event of any component that implements ClientElement. + * + * @author fdesbois + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +@IncludeJavaScriptLibrary("confirm.js") +public class Confirm { + + @Parameter(value = "Are you sure?", defaultPrefix = BindingConstants.MESSAGE) + private String message; + + @Parameter(value = "true") + private boolean condition; + + @Inject + private RenderSupport renderSupport; + + @InjectContainer + private ClientElement element; + + @Parameter + private boolean wDisabled; + + @AfterRender + public void afterRender() { + if (!wDisabled) { + renderSupport.addScript(String.format("new Confirm('%s', '%s', %b);", + element.getClientId(), message.replace("'", "\\'"), condition)); + } + } + +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/Confirm.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,103 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.web.tapestry5.mixins; + +import org.apache.commons.lang.ArrayUtils; +import org.apache.tapestry5.BindingConstants; +import org.apache.tapestry5.ClientElement; +import org.apache.tapestry5.ComponentResources; +import org.apache.tapestry5.Link; +import org.apache.tapestry5.RenderSupport; +import org.apache.tapestry5.annotations.Environmental; +import org.apache.tapestry5.annotations.IncludeJavaScriptLibrary; +import org.apache.tapestry5.annotations.InjectContainer; +import org.apache.tapestry5.annotations.Parameter; +import org.apache.tapestry5.ioc.annotations.Inject; + +/** + * From <a href="http://tinybits.blogspot.com/2009/05/update-zone-on-any-client-side-event.html">Ingesol Blog</a> + * + * @author ingesol + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + */ +@IncludeJavaScriptLibrary("zoneUpdater.js") +public class ZoneUpdater { + + public static final String PLACEHOLDER = "XXX"; + + @Inject + private ComponentResources resources; + + @Environmental + private RenderSupport renderSupport; + + @Parameter(defaultPrefix = BindingConstants.LITERAL) + private String clientEvent; + + @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true) + private String event; + + @InjectContainer + private ClientElement element; + + @Parameter + private Object[] context; + + @Parameter(defaultPrefix = BindingConstants.LITERAL) + // To enable popups to fire events on this document, enter "document" here. + private String listeningElement; + + @Parameter(defaultPrefix = BindingConstants.LITERAL, required = true) + private String zone; + + protected Link createLink(Object[] context) { + + if (context == null) { + context = new Object[]{PLACEHOLDER}; + } else { + context = ArrayUtils.add(context, PLACEHOLDER); // To be replaced by javascript + } + + return resources.createEventLink(event, context); + + } + + void afterRender() { + String link = createLink(context).toAbsoluteURI(); + String elementId = element.getClientId(); + if (clientEvent == null) { + clientEvent = event; + } + + if (listeningElement == null) { + listeningElement = "$('" + elementId + "')"; + } + renderSupport.addScript("new ZoneUpdater('%s', %s, '%s', '%s', '%s', '%s')", elementId, listeningElement, clientEvent, link, zone, PLACEHOLDER); + + } +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/mixins/ZoneUpdater.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,170 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.web.tapestry5.services; + +import java.io.IOException; +import java.lang.annotation.Annotation; +import org.apache.tapestry5.Link; +import org.apache.tapestry5.runtime.Component; +import org.apache.tapestry5.services.ComponentEventRequestParameters; +import org.apache.tapestry5.services.ComponentRequestFilter; +import org.apache.tapestry5.services.ComponentRequestHandler; +import org.apache.tapestry5.services.ComponentSource; +import org.apache.tapestry5.services.PageRenderLinkSource; +import org.apache.tapestry5.services.PageRenderRequestParameters; +import org.apache.tapestry5.services.Response; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * AbstractAuthenticationFilter + * + * Created: 3 mai 2010 + * + * @param <U> type of User + * @param <A> type of Annotation that manage authentication on pages/components + * @author fdesbois + * $Id$ + */ +public abstract class AbstractAuthenticationFilter<U, A extends Annotation> + implements ComponentRequestFilter { + + private static final Logger logger = + LoggerFactory.getLogger(AbstractAuthenticationFilter.class); + + private final PageRenderLinkSource pageRender; + + private final ComponentSource componentSource; + + private final Response response; + + private final ServiceAuthentication<U> serviceAuthentication; + + protected Class<A> annotationClass; + + protected enum AuthenticationRedirect { + NOT_CONNECTED, NOT_ALLOWED; + } + + protected abstract Class<?> getRedirectPage( + AuthenticationRedirect redirectType); + + public AbstractAuthenticationFilter(PageRenderLinkSource renderLinkSource, + ComponentSource componentSource, Response response, + ServiceAuthentication<U> serviceAuthentication, + Class<A> annotationClass) { + this.pageRender = renderLinkSource; + this.componentSource = componentSource; + this.response = response; + this.serviceAuthentication = serviceAuthentication; + this.annotationClass = annotationClass; + + if (logger.isTraceEnabled()) { + logger.trace("Construct"); + } + } + + @Override + public void handleComponentEvent( + ComponentEventRequestParameters parameters, + ComponentRequestHandler handler) throws IOException { + + if (logger.isTraceEnabled()) { + logger.trace("handleComponentEvent"); + } + + if (redirectUnauthorizedUser(parameters.getActivePageName())) { + return; + } + + handler.handleComponentEvent(parameters); + + } + + @Override + public void handlePageRender(PageRenderRequestParameters parameters, + ComponentRequestHandler handler) throws IOException { + + if (logger.isTraceEnabled()) { + logger.trace("handlePageRender"); + } + + if (redirectUnauthorizedUser(parameters.getLogicalPageName())) { + return; + } + + handler.handlePageRender(parameters); + } + + protected boolean redirectUnauthorizedUser(String pageName) + throws IOException { + + Component page = componentSource.getPage(pageName); + + if (logger.isTraceEnabled()) { + logger.trace("Page name : " + pageName); + logger.trace("Page class : " + page.getClass()); + logger.trace("RequiresLogin annotation : " + + page.getClass().isAnnotationPresent(annotationClass)); + logger.trace("User in session : " + + serviceAuthentication.isUserConnected()); + } + + if (!page.getClass().isAnnotationPresent(annotationClass)) { + return false; + } + + AuthenticationRedirect redirectType = AuthenticationRedirect.NOT_CONNECTED; + + if (serviceAuthentication.isUserConnected()) { + U user = serviceAuthentication.getUserConnected(); + if (logger.isTraceEnabled()) { + logger.trace("User connected : " + user); + logger.trace("User allowed : " + + serviceAuthentication.isAllowed(page.getClass())); + } + + if (serviceAuthentication.isAllowed(page.getClass())) { + return false; + } + + redirectType = AuthenticationRedirect.NOT_ALLOWED; + } + + Class<?> redirectPage = getRedirectPage(redirectType); + Link link = pageRender.createPageRenderLinkWithContext(redirectPage, + pageName); + + if (logger.isTraceEnabled()) { + logger.trace("Redirection to " + redirectPage.getSimpleName() + + " page..."); + } + + response.sendRedirect(link); + + return true; + } +} + Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/AbstractAuthenticationFilter.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,102 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.web.tapestry5.services; + +import java.util.ArrayList; +import java.util.List; +import org.apache.tapestry5.Binding; +import org.apache.tapestry5.internal.bindings.AbstractBinding; +import org.apache.tapestry5.ioc.Location; +import org.apache.tapestry5.ioc.Messages; + +/** + * From <a href="http://wiki.apache.org/tapestry/Tapestry5HowToAddMessageFormatBindingPrefix">Tapestry5HowTo</a> + * <h2>Usage :</h2> + * <pre> + * ${format:key=value1,value2} or <t:component t:parameter="format:key=value1,value2"> + * </pre> + * + * Created: 27 avr. 2010 + * + * @see FormatBindingFactory + * @author fdesbois + * $Id$ + */ +public class FormatBinding extends AbstractBinding { + + private final Messages messages; + private final boolean invariant; + private final List<Binding> keyBindings; + private final List<Binding> valueBindings; + + public FormatBinding(Location location, Messages messages, boolean invariant, + ArrayList<Binding> keyBindings, List<Binding> valueBindings) { + super(location); + + this.messages = messages; + this.invariant = invariant; + this.keyBindings = keyBindings; + this.valueBindings = valueBindings; + } + + public FormatBinding(Location location, Messages messages, boolean invariant, ArrayList<Binding> keyBindings) { + super(location); + + this.messages = messages; + this.invariant = invariant; + this.keyBindings = keyBindings; + this.valueBindings = null; + } + + @Override + public Object get() { + String key = ""; + for (Binding keyBinding : keyBindings) { + key += keyBinding.get(); + } + + if (null == valueBindings) { + return messages.get(key); + } + + List<Object> values = new ArrayList<Object>(valueBindings.size()); + for (Binding valueBinding : valueBindings) { + values.add(valueBinding.get()); + } + + return messages.format(key, values.toArray()); + } + + @Override + public boolean isInvariant() { + return this.invariant; + } + + @SuppressWarnings("unchecked") + @Override + public Class<?> getBindingType() { + return String.class; + } +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBinding.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,113 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +package org.nuiton.web.tapestry5.services; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.apache.tapestry5.Binding; +import org.apache.tapestry5.BindingConstants; +import org.apache.tapestry5.ComponentResources; +import org.apache.tapestry5.ioc.Location; +import org.apache.tapestry5.services.BindingFactory; +import org.apache.tapestry5.services.BindingSource; + +/** + * From <a href="http://wiki.apache.org/tapestry/Tapestry5HowToAddMessageFormatBindingPrefix">Tapestry5HowTo</a> + * <br \> + * <h2>AppModule contribution :</h2> + * <pre> + * public static void contributeBindingSource( + * MappedConfiguration<String, BindingFactory> configuration, + * BindingSource bindingSource) { + * configuration.add("format", new FormatBindingFactory(bindingSource)); + * } + * </pre> + * + * Created: 27 avr. 2010 + * + * @author fdesbois + * $Id$ + */ +public class FormatBindingFactory + implements BindingFactory { + + private static final String SEPARATOR = "="; + private static final String DELIMITER = ","; + private static final String KEY_PREFIX = BindingConstants.LITERAL; + private static final String VALUE_PREFIX = BindingConstants.PROP; + private final BindingSource bindingSource; + + public FormatBindingFactory(BindingSource bindingSource) { + this.bindingSource = bindingSource; + } + + @Override + public Binding newBinding(String description, ComponentResources container, ComponentResources component, + String expression, Location location) { + int separatorIndex = expression.indexOf(SEPARATOR); + + if (-1 == separatorIndex) { + List<String> keys = Arrays.asList(expression.split(DELIMITER)); + + ArrayList<Binding> keyBindings = createBindings(description, container, component, KEY_PREFIX, keys, location); + + boolean invariant = isInvariant(keyBindings); + return new FormatBinding(location, container.getMessages(), invariant, keyBindings); + } + + List<String> keys = Arrays.asList(expression.substring(0, separatorIndex).split(DELIMITER)); + ArrayList<Binding> keyBindings = createBindings(description, container, component, KEY_PREFIX, keys, location); + + List<String> values = Arrays.asList(expression.substring(separatorIndex + 1).split(DELIMITER)); + ArrayList<Binding> valueBindings = createBindings(description, container, component, VALUE_PREFIX, values, + location); + + boolean invariant = isInvariant(keyBindings) && isInvariant(valueBindings); + return new FormatBinding(location, container.getMessages(), invariant, keyBindings, valueBindings); + } + + private ArrayList<Binding> createBindings(String description, ComponentResources container, + ComponentResources component, String defaultPrefix, + List<String> expressions, Location location) { + ArrayList<Binding> bindings = new ArrayList<Binding>(expressions.size()); + + for (String expression : expressions) { + bindings.add(bindingSource.newBinding(description, container, component, defaultPrefix, expression, location)); + } + + return bindings; + } + + private boolean isInvariant(ArrayList<Binding> bindings) { + for (Binding binding : bindings) { + if (!binding.isInvariant()) { + return false; + } + } + + return true; + } +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/FormatBindingFactory.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,59 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.nuiton.web.tapestry5.services; + +import org.apache.tapestry5.ioc.Configuration; +import org.apache.tapestry5.ioc.MappedConfiguration; +import org.apache.tapestry5.services.BindingFactory; +import org.apache.tapestry5.services.BindingSource; +import org.apache.tapestry5.services.LibraryMapping; + +/** + * NuitonModule + * + * Created: 4 mai 2010 + * + * @author fdesbois + * $Id$ + */ +public class NuitonModule { + + private static final String PACKAGE_ROOT = "org.nuiton.web.tapestry5"; + + public void contributeComponentClassResolver( + Configuration<LibraryMapping> configuration) { + + configuration.add(new LibraryMapping("nuiton", PACKAGE_ROOT)); + } + + public static void contributeBindingSource( + MappedConfiguration<String, BindingFactory> configuration, + BindingSource bindingSource) { + + configuration.add("format", new FormatBindingFactory(bindingSource)); + } + +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/NuitonModule.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,115 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.nuiton.web.tapestry5.services; + +/** + * This service is used to provide authentication managment for a final + * application. The user type used in the application is needed. This service + * need to be implemented and build in the AppModule of your application. + * An abstract implementation is available {@link ServiceAuthenticationAbstract} + * This service is used in {@link AbstractAuthenticationFilter} to verify + * user rights for displaying pages using {@link #isAllowed(Class)} method. + * See documentation site for more explanation of using this service and + * authentication managment. + * <br \> + * <h2>AppModule contribution :</2> + * Exemple with MyUser type for user and ServiceAuthenticationImpl for + * implementation : + * <pre> + * public ServiceAuthentication<MyUser> buildServiceAuthentication( + * ApplicationStateManager stateManager) { + * ServiceAuthentication<MyUser> instance = + * new ServiceAuthenticationImpl(stateManager); + * return instance; + * } + * </pre> + * Contribute to ApplicationStateManager to instantiate MyUser automatically : + * <pre> + * public void contributeApplicationStateManager( + * MappedConfiguration<Class<?>, + * ApplicationStateContribution> configuration, + * final ServiceAuthentication<MyUser> serviceAuthentication) { + * + * ApplicationStateCreator<MyUser> creator = + * new ApplicationStateCreator<MyUser>() { + * + * @Override + * public MyUser create() { + * return serviceAuthentication.getNewUserInstance(); + * } + * }; + * + * configuration.add(MyUser.class, + * new ApplicationStateContribution("session", creator)); + * } + * </pre> + * + * + * Created: 3 mai 2010 + * + * @param <U> user type + * @author fdesbois + * $Id$ + */ +public interface ServiceAuthentication<U> { + + /** + * Detect if user is connected. + * + * @return true if the user is connected, false otherwise. + */ + boolean isUserConnected(); + + /** + * Get the current user connected. + * + * @return the user connected + */ + U getUserConnected(); + + /** + * Set the connected user to {@code user}. + * + * @param user that will be connected + */ + void setUserConnected(U user); + + /** + * Check if the current user is allowed to display this {@code page}. + * + * @param page to check + * @return true if the connected user is allowed, false otherwise + */ + boolean isAllowed(Class<?> page); + + /** + * Create a new instance of user. + * + * @return a new user. + */ + U getNewUserInstance(); + +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthentication.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,166 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.nuiton.web.tapestry5.services; + +import java.lang.annotation.Annotation; +import org.apache.tapestry5.ioc.internal.util.TapestryException; +import org.apache.tapestry5.services.ApplicationStateManager; + +/** + * This class is an abstract implementation of {@link ServiceAuthentication}. + * This service use {@link ApplicationStateManager} to manage connected user. + * You can inherit this class to provide a momre specific authentication + * managmentan depends on user type and annotation used to identify + * pages that need authentication. This behavior is done in + * {@link #isAllowed(Class)} that detect the annotation on the page (ex : + * {@link RequiresAuthentication} annotation) and call the method + * {@link #checkAuthorizations(Object, Annotation)} that is implemented by + * default to do nothing (return true). + * <br \> + * <h2>AppModule contribution :</2> + * Exemple with MyUser type for user and RequiresAnnotation for annotation : + * <pre> + * public ServiceAuthentication<MyUser> buildServiceAuthentication(ApplicationStateManager stateManager) { + * return new ServiceAuthenticationImpl<MyUser, RequiresAuthentication>(stateManager); + * } + * </pre> + * No need to contribute to ApplicationStateManager to provide instantiation + * of user. Even this service used the default constructor to instanciate a new + * user. + * + * Created: 3 mai 2010 + * + * @param <U> user type + * @param <A> annotation type used to identify which page need authentication + * @author fdesbois + * $Id$ + */ +public class ServiceAuthenticationImpl<U, A extends Annotation> + implements ServiceAuthentication<U> { + + /** + * Tapestry service used to save user in session and retrieve it when + * needed. + **/ + private final ApplicationStateManager stateManager; + + /** + * User type + **/ + protected Class<U> userClass; + + /** + * Annotation type to detect pages that need authentication (ex : + * RequiresAuthentication). + */ + protected Class<A> annotationClass; + + /** + * Constructor to call in subclasses. + * + * @param stateManager from Tapestry + * @param userClass to identify which type of user is managed + * @param annotationClass to identify which type of annotation is managed + * for authentication treatment. + */ + public ServiceAuthenticationImpl(ApplicationStateManager stateManager, + Class<U> userClass, Class<A> annotationClass) { + this.stateManager = stateManager; + this.userClass = userClass; + this.annotationClass = annotationClass; + } + + @Override + public boolean isUserConnected() { + return stateManager.exists(userClass); + } + + @Override + public U getUserConnected() { + return stateManager.getIfExists(userClass); + } + + @Override + public void setUserConnected(U user) { + stateManager.set(userClass, user); + } + + /** + * Detect the annotation in the given {@code page}. If annotation is + * detected, the user authorizations need to be check using + * {@link #checkAuthorizations(Object, Annotation)} method. + * + * @param page to check + * @return true if connected user can display the page, false otherwise + */ + @Override + public boolean isAllowed(Class<?> page) { + if (page.isAnnotationPresent(annotationClass) && + isUserConnected()) { + + A check = page.getAnnotation(annotationClass); + + U user = getUserConnected(); + + return checkAuthorizations(user, check); + } + // No restriction if annotation is not present + return true; + } + + /** + * Check the connected user authorizations. Called in + * {@link #isAllowed(Class)} method after detect the annotation on the + * current page. Override this method to provide more specific + * authentication managment. + * + * @param user current user connected. + * @param annotation from page to check authorizations. + * @return true if the user is granted, false otherwise + */ + protected boolean checkAuthorizations(U user, A annotation) { + // The user is connected so, he can access to the page. + return true; + } + + /** + * Default instanciation of the user. The user class need a default + * constructor. + * + * @return a new user instance. + */ + @Override + public U getNewUserInstance() { + try { + return userClass.newInstance(); + } catch (Exception eee) { + new TapestryException("Error on user instanciation " + + userClass.getName(), eee); + } + return null; + } + +} Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/ServiceAuthenticationImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java =================================================================== --- trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,30 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +/** + * This package contains extra services (or abstraction) for Tapestry + * applications. Generally, these services need to be built in the + * AppModule class of your Tapestry application. + */ +package org.nuiton.web.tapestry5.services; \ No newline at end of file Property changes on: trunk/nuiton-tapestry-extra/src/main/java/org/nuiton/web/tapestry5/services/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/SubForm.tml =================================================================== --- trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/SubForm.tml (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/SubForm.tml 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,38 @@ +<!-- + #%L + Nuiton Utils :: Nuiton Tapestry Extra + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter"> + + <t:delegate t:to="activeBlock" /> + <t:block t:id="formBlock"> + <form t:type="form" action="tapestry"> + <t:body /> + </form> + </t:block> + <t:block t:id="noFormBlock"> + <t:body /> + </t:block> + +</html> \ No newline at end of file Added: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css =================================================================== --- trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,48 @@ +/* + * #%L + * Nuiton Utils :: Nuiton Tapestry Extra + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +.fb-error { + width: 400px; + margin: auto; + text-align: center; + color: #000; + font-weight: bold; + padding: 3px; + border: solid; + border-color: #f00; + border-width: 2px; + margin-bottom: 10px; +} + +.fb-info { + width: 400px; + margin: auto; + text-align: center; + color: #000; + padding: 3px; + border: solid; + border-color: #000; + border-width: 2px; +} \ No newline at end of file Property changes on: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/components/feedback.css ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js =================================================================== --- trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,23 @@ +/** + * Dialogue de confirmation + */ +var Confirm = Class.create({ + /** + * element : Element DOM depuis lequel le dialogue de confirmation va s'ouvrir + * message : Message à afficher dans la boîte de dialogue + */ + initialize: function(element, message, condition) { + this.message = message; + this.condition = condition; + Event.observe($(element), 'click', this.doConfirm.bindAsEventListener(this)); + }, + doConfirm: function(e) { + //Tapestry.debug('click ' + element); + if (this.condition) { + if (!confirm(this.message)) { + //Tapestry.debug('STOP ' + e); + Event.stop(e); + } + } + } +}); \ No newline at end of file Property changes on: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/confirm.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js =================================================================== --- trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js (rev 0) +++ trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,103 @@ +var ZoneUpdater = Class.create(); + +ZoneUpdater.prototype = { + + initialize: function(zoneElementId, listeningElement, event, link, zone, placeholder) { + + this.zoneElement = $(zoneElementId); + + this.event = event; + + this.link = link; + + this.placeholder = placeholder; + + $T(this.zoneElement).zoneId = zone; + + listeningElement.observe(this.event, this.updateZone.bindAsEventListener(this)); + + }, + + updateZone: function(event) { + + var zoneObject = Tapestry.findZoneManager(this.zoneElement); + + if ( !zoneObject ) return; + + var param; + + if (this.zoneElement.value) { + + param = this.zoneElement.value; + + } + + if (!param) param = ' '; + + param = this.encodeForUrl(param); + + var updatedLink = this.link.gsub(this.placeholder, param); + + zoneObject.updateFromURL(updatedLink); + + }, + + encodeForUrl: function(string) { + + /** + + * See equanda.js for updated version of this + + */ + + string = string.replace(/\r\n/g,"\n"); + + var res = ""; + + for (var n = 0; n < string.length; n++) + + { + + var c = string.charCodeAt( n ); + + if ( '$' == string.charAt( n ) ) + + { + + res += '$$'; + + } + + else if ( this.inRange( c, "AZ" ) || this.inRange( c, "az" ) || this.inRange( c, "09" ) || this.inRange( c, ".." ) ) + + { + + res += string.charAt( n ) + + } + + else + + { + + var tmp = c.toString(16); + + while ( tmp.length < 4 ) tmp = "0" + tmp; + + res += '$' + tmp; + + } + + } + + return res; + + }, + + inRange: function(code, range) { + + return code >= range.charCodeAt( 0 ) && code <= range.charCodeAt( 1 ); + + } + +} \ No newline at end of file Property changes on: trunk/nuiton-tapestry-extra/src/main/resources/org/nuiton/web/tapestry5/mixins/zoneUpdater.js ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/site/apt/index.apt =================================================================== --- trunk/nuiton-tapestry-extra/src/site/apt/index.apt (rev 0) +++ trunk/nuiton-tapestry-extra/src/site/apt/index.apt 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,34 @@ +~~~ +~~ #%L +~~ Nuiton Utils :: Nuiton Tapestry Extra +~~ +~~ $Id$ +~~ $HeadURL$ +~~ %% +~~ Copyright (C) 2010 CodeLutin, Florian Desbois, Tony chemit +~~ %% +~~ This program is free software: you can redistribute it and/or modify +~~ it under the terms of the GNU Lesser General Public License as +~~ published by the Free Software Foundation, either version 3 of the +~~ License, or (at your option) any later version. +~~ +~~ This program is distributed in the hope that it will be useful, +~~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~~ GNU General Lesser Public License for more details. +~~ +~~ You should have received a copy of the GNU General Lesser Public +~~ License along with this program. If not, see +~~ <http://www.gnu.org/licenses/lgpl-3.0.html>. +~~ #L% +~~~ + ---- + Nuiton Tapestry Extra + ---- + ---- + 2009-08-23 + ---- + +Présentation + + A Faire... \ No newline at end of file Property changes on: trunk/nuiton-tapestry-extra/src/site/apt/index.apt ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/nuiton-tapestry-extra/src/site/site_fr.xml =================================================================== --- trunk/nuiton-tapestry-extra/src/site/site_fr.xml (rev 0) +++ trunk/nuiton-tapestry-extra/src/site/site_fr.xml 2010-12-30 12:09:09 UTC (rev 2003) @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + Nuiton Utils :: Nuiton Tapestry Extra + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 CodeLutin, Florian Desbois, Tony Chemit + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Lesser Public License for more details. + + You should have received a copy of the GNU General Lesser Public + License along with this program. If not, see + <http://www.gnu.org/licenses/lgpl-3.0.html>. + #L% + --> + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <body> + + <breadcrumbs> + <item name="${project.name}" href="index.html"/> + </breadcrumbs> + + <menu ref="parent"/> + + <menu name="Utilisateur"> + <item name="Accueil" href="index.html"/> + </menu> + + <menu name="Téléchargement"> + <item + href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}.jar" + name="Librairie (jar)"/> + <item + href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar" + name="Javadoc (jar)"/> + <item + href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar" + name="Sources (jar)"/> + </menu> + + <menu ref="reports"/> + + </body> +</project> Property changes on: trunk/nuiton-tapestry-extra/src/site/site_fr.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-12-30 11:25:43 UTC (rev 2002) +++ trunk/pom.xml 2010-12-30 12:09:09 UTC (rev 2003) @@ -45,6 +45,7 @@ <module>nuiton-utils</module> <module>nuiton-validator</module> <module>nuiton-utils-extra</module> + <module>nuiton-tapestry-extra</module> <module>nuiton-rss</module> </modules> @@ -70,7 +71,7 @@ <version>7.1.0.v20100505</version> </dependency> - <!-- xworks dependencies --> + <!-- xworks dependencies --> <dependency> <groupId>com.opensymphony</groupId> @@ -104,33 +105,73 @@ <version>${aspectwerkzVersion}</version> </dependency> - <dependency> - <groupId>org.jdom</groupId> - <artifactId>jdom</artifactId> - <version>1.1</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>rome</groupId> - <artifactId>rome</artifactId> - <version>0.9</version> - <scope>compile</scope> - <exclusions> - <exclusion> - <groupId>jdom</groupId> - <artifactId>jdom</artifactId> - </exclusion> - </exclusions> - </dependency> + <!-- tapestry dependencies --> - <!--Provided--> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.5</version> - <scope>provided</scope> - </dependency> + <dependency> + <groupId>org.apache.tapestry</groupId> + <artifactId>tapestry-core</artifactId> + <version>${tapestryVersion}</version> + <scope>compile</scope> + <exclusions> + <exclusion> + <groupId>jboss</groupId> + <artifactId>javassist</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.tapestry</groupId> + <artifactId>tapestry-ioc</artifactId> + <version>${tapestryVersion}</version> + </dependency> + + <dependency> + <groupId>org.apache.tapestry</groupId> + <artifactId>tapestry5-annotations</artifactId> + <version>${tapestryVersion}</version> + </dependency> + + <!-- sl4j dependencies --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${slf4jVersion}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>${slf4jVersion}</version> + </dependency> + + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom</artifactId> + <version>1.1</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>rome</groupId> + <artifactId>rome</artifactId> + <version>0.9</version> + <scope>compile</scope> + <exclusions> + <exclusion> + <groupId>jdom</groupId> + <artifactId>jdom</artifactId> + </exclusion> + </exclusions> + </dependency> + + <!--Provided--> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.5</version> + <scope>provided</scope> + </dependency> + </dependencies> </dependencyManagement> @@ -163,7 +204,7 @@ <organization>CodeLutin</organization> <timezone>+2</timezone> <roles> - <role>Développeur</role> + <role>developer</role> <role>Debian packager</role> </roles> </developer> @@ -175,18 +216,29 @@ <organization>CodeLutin</organization> <timezone>+2</timezone> <roles> - <role>Développeur</role> + <role>developer</role> </roles> </developer> <developer> + <name>Florian Desbois</name> + <id>fdesbois</id> + <email>desbois@codelutin.com</email> + <organization>Code Lutin</organization> + <timezone>+2</timezone> + <roles> + <role>developer</role> + </roles> + </developer> + + <developer> <name>Sylvain Letellier</name> <id>sletellier</id> <email>letellier@codelutin.com</email> <organization>CodeLutin</organization> <timezone>+2</timezone> <roles> - <role>Développeur</role> + <role>developer</role> </roles> </developer> @@ -216,12 +268,16 @@ <nuitonI18nVersion>2.0.1</nuitonI18nVersion> <aspectwerkzVersion>2.0</aspectwerkzVersion> - + + <tapestryVersion>5.1.0.5</tapestryVersion> + + <slf4jVersion>1.5.10</slf4jVersion> </properties> <build> <pluginManagement> <plugins> + <!-- plugin i18n --> <plugin> <groupId>org.nuiton.i18n</groupId>
participants (1)
-
tchemit@users.nuiton.org