Author: chris.laprun(a)jboss.com
Date: 2009-06-04 23:25:58 -0400 (Thu, 04 Jun 2009)
New Revision: 13436
Added:
modules/faces/
modules/faces/trunk/
modules/faces/trunk/build/
modules/faces/trunk/build/licences/
modules/faces/trunk/build/licences/JBossEULA.txt
modules/faces/trunk/build/misc/
modules/faces/trunk/build/misc/codeguide.html
modules/faces/trunk/build/pom.xml
modules/faces/trunk/faces/
modules/faces/trunk/faces/pom.xml
modules/faces/trunk/faces/src/
modules/faces/trunk/faces/src/main/
modules/faces/trunk/faces/src/main/java/
modules/faces/trunk/faces/src/main/java/org/
modules/faces/trunk/faces/src/main/java/org/jboss/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFInvocation.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFPortalContext.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFServerContext.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFUserContext.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFWindowContext.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletActionEvent.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletEvent.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletEventEvent.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletHandler.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletListener.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRequestDecoder.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRequestEncoder.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/UIPortlet.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/ScrollerTag.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/UIScroller.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/ClassConstantPublisherBean.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/DelegatingPropertyResolver.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/PropertyValue.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/AbstractBeanDecorator.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/AbstractPropertyDecorator.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/BeanDecorator.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/PropertyDecorator.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/SimpleBeanDecorator.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/AbstractDynamicBean.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/AbstractDynamicProperty.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/DynamicBean.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/DynamicProperty.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/SimpleDynamicBean.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/facelet/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/facelet/ContextTagHandler.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/BeanContext.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/JSFBeanContext.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/ManagedBean.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesClassLoader.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesLoaderServlet.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesPortlet.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/util/
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/util/ActionEventDispatcher.java
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/util/JSFFunctor.java
modules/faces/trunk/faces/src/main/resources/
modules/faces/trunk/faces/src/main/resources/portal-faces-lib-jar/
modules/faces/trunk/faces/src/main/resources/portal-faces-lib-jar/META-INF/
modules/faces/trunk/faces/src/main/resources/portal-faces-lib-jar/META-INF/portal.taglib.xml
modules/faces/trunk/faces/src/main/resources/portal-faces-war/
modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/
modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/faces-config.xml
modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/web.xml
modules/faces/trunk/faces/src/main/resources/portal-faces-war/index.jsp
modules/faces/trunk/faces/src/test/
modules/faces/trunk/faces/src/test/java/
modules/faces/trunk/faces/src/test/java/org/
modules/faces/trunk/faces/src/test/java/org/jboss/
modules/faces/trunk/faces/src/test/java/org/jboss/portal/
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/ManagedBeanTestCase.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/MessageFormatTestCase.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/AbstractDynamicBeanTestCase.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant1.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant2.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant3.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstantPublisherBeanTestCase.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/DelegatingPropertyResolverTestCase.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/SimpleDynamicBeanTestCase.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBean.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanDecorator.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanInterface.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanInterfaceSuperInterface.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanSuperClass.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestDynamicBean.java
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/Value.java
modules/faces/trunk/faces/src/test/java/util/
modules/faces/trunk/faces/src/test/java/util/JSFFunctorTestCase.java
modules/faces/trunk/pom.xml
Log:
First import of faces module, extracted from Portal main code. Tests do not currently
work.
Added: modules/faces/trunk/build/licences/JBossEULA.txt
===================================================================
--- modules/faces/trunk/build/licences/JBossEULA.txt (rev 0)
+++ modules/faces/trunk/build/licences/JBossEULA.txt 2009-06-05 03:25:58 UTC (rev 13436)
@@ -0,0 +1,106 @@
+LICENSE AGREEMENT
+JBOSS(r)
+
+This License Agreement governs the use of the Software Packages and any updates to the
Software
+Packages, regardless of the delivery mechanism. Each Software Package is a collective
work
+under U.S. Copyright Law. Subject to the following terms, Red Hat, Inc. ("Red
Hat") grants to
+the user ("Client") a license to the applicable collective work(s) pursuant to
the
+GNU Lesser General Public License v. 2.1 except for the following Software Packages:
+(a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to
the
+GNU General Public License v.2;
+
+(b) JBoss Rules, which is licensed pursuant to the Apache License v.2.0;
+
+(c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is
licensed under the
+(open source) Sleepycat License (if Client does not wish to use the open source version
of this database,
+it may purchase a license from Sleepycat Software);
+
+and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public
License v.1,
+and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to
enter various
+royalty-free patent licenses.
+
+Each of the foregoing licenses is available at
http://www.opensource.org/licenses/index.php.
+
+1. The Software. "Software Packages" refer to the various software modules
that are created and made available
+for distribution by the
JBoss.org open source community at
http://www.jboss.org. Each
of the Software Packages
+may be comprised of hundreds of software components. The end user license agreement for
each component is located in
+the component's source code. With the exception of certain image files identified in
Section 2 below,
+the license terms for the components permit Client to copy, modify, and redistribute the
component,
+in both source code and binary code forms. This agreement does not limit Client's
rights under,
+or grant Client rights that supersede, the license terms of any particular component.
+
+2. Intellectual Property Rights. The Software Packages are owned by Red Hat and others
and are protected under copyright
+and other laws. Title to the Software Packages and any component, or to any copy,
modification, or merged portion shall
+remain with the aforementioned, subject to the applicable license. The "JBoss"
trademark, "Red Hat" trademark, the
+individual Software Package trademarks, and the "Shadowman" logo are registered
trademarks of Red Hat and its affiliates
+in the U.S. and other countries. This agreement permits Client to distribute unmodified
copies of the Software Packages
+using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the
condition that Client follows Red Hat's
+trademark guidelines for those trademarks located at
http://www.redhat.com/about/corporate/trademark/. Client must abide by
+these trademark guidelines when distributing the Software Packages, regardless of whether
the Software Packages have been modified.
+If Client modifies the Software Packages, then Client must replace all Red Hat trademarks
and logos identified at
+http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed
or other permission granted.
+Merely deleting the files containing the Red Hat trademarks may corrupt the Software
Packages.
+
+3. Limited Warranty. Except as specifically stated in this Paragraph 3 or a license for
a particular
+component, to the maximum extent permitted under applicable law, the Software Packages
and the
+components are provided and licensed "as is" without warranty of any kind,
expressed or implied,
+including the implied warranties of merchantability, non-infringement or fitness for a
particular purpose.
+Red Hat warrants that the media on which Software Packages may be furnished will be free
from defects in
+materials and manufacture under normal use for a period of 30 days from the date of
delivery to Client.
+Red Hat does not warrant that the functions contained in the Software Packages will meet
Client's requirements
+or that the operation of the Software Packages will be entirely error free or appear
precisely as described
+in the accompanying documentation. This warranty extends only to the party that purchases
the Services
+pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor.
+
+4. Limitation of Remedies and Liability. To the maximum extent permitted by applicable
law, the remedies
+described below are accepted by Client as its only remedies. Red Hat's entire
liability, and Client's
+exclusive remedies, shall be: If the Software media is defective, Client may return it
within 30 days of
+delivery along with a copy of Client's payment receipt and Red Hat, at its option,
will replace it or
+refund the money paid by Client for the Software. To the maximum extent permitted by
applicable law,
+Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental
or consequential
+damages, including lost profits or lost savings arising out of the use or inability to
use the Software,
+even if Red Hat or such dealer has been advised of the possibility of such damages. In
no event shall
+Red Hat's liability under this agreement exceed the amount that Client paid to Red
Hat under this
+Agreement during the twelve months preceding the action.
+
+5. Export Control. As required by U.S. law, Client represents and warrants that it:
+(a) understands that the Software Packages are subject to export controls under the
+U.S. Commerce Department's Export Administration Regulations ("EAR");
+
+(b) is not located in a prohibited destination country under the EAR or U.S. sanctions
regulations
+(currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria);
+
+(c) will not export, re-export, or transfer the Software Packages to any prohibited
destination, entity,
+or individual without the necessary export license(s) or authorizations(s) from the U.S.
Government;
+
+(d) will not use or transfer the Software Packages for use in any sensitive nuclear,
chemical or
+biological weapons, or missile technology end-uses unless authorized by the U.S.
Government by
+regulation or specific license;
+
+(e) understands and agrees that if it is in the United States and exports or transfers
the Software
+Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit
semi-annual
+reports to the Commerce Department's Bureau of Industry & Security (BIS), which
include the name and
+address (including country) of each transferee;
+
+and (f) understands that countries other than the United States may restrict the import,
use, or
+export of encryption products and that it shall be solely responsible for compliance with
any such
+import, use, or export restrictions.
+
+6. Third Party Programs. Red Hat may distribute third party software programs with the
Software Packages
+that are not part of the Software Packages and which Client must install separately.
These third party
+programs are subject to their own license terms. The license terms either accompany the
programs or
+can be viewed at
http://www.redhat.com/licenses/. If Client does not agree to abide by
the applicable
+license terms for such programs, then Client may not install them. If Client wishes to
install the programs
+on more than one system or transfer the programs to another party, then Client must
contact the licensor
+of the programs.
+
+7. General. If any provision of this agreement is held to be unenforceable, that shall
not affect the
+enforceability of the remaining provisions. This License Agreement shall be governed by
the laws of the
+State of North Carolina and of the United States, without regard to any conflict of laws
provisions,
+except that the United Nations Convention on the International Sale of Goods shall not
apply.
+
+Copyright 2006 Red Hat, Inc. All rights reserved.
+"JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc.
+All other trademarks are the property of their respective owners.
+
+ Page 1 of 1 18 October 2006
Added: modules/faces/trunk/build/misc/codeguide.html
===================================================================
--- modules/faces/trunk/build/misc/codeguide.html (rev 0)
+++ modules/faces/trunk/build/misc/codeguide.html 2009-06-05 03:25:58 UTC (rev 13436)
@@ -0,0 +1,133 @@
+<html>
+
+<head>
+<style type="text/css">
+pre { border-style:solid; border-width:thin; padding:5px; background-color:#EEEEFF;}
+span.bad { text-decoration:line-through; }
+span.important { font-weight:bold; color:red; }
+</style>
+</head>
+
+<body>
+
+<h2>Coding Conventions</h2>
+
+<h3>Some more general guidelines</h3>
+<ul>
+<li>Fully qualified imports should be used, rather than importing
x.y.*.</li>
+<li>Use newlines for opening braces, so that the top and bottom braces can be
visually matched.</li>
+<li>Aid visual separation of logical steps by introducing newlines and appropriate
comments above them.</li>
+</ul>
+
+
+<h3>A class that conforms to JBoss coding guidelines</h3>
+
+<pre>
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package x;
+
+// <span class="important">Explicit imports</span>
+import a.b.C1; // <span class="important">good</span>
+import a.b.C2;
+import a.b.C3;
+
+// <span class="important">Do not write</span>
+<span class="bad">import a.b.*;</span> // <span
class="important">bad</span>
+
+// <span class="important">DO NOT USE "TAB" TO INDENT CODE USE
*3* SPACES FOR PORTABILITY AMONG EDITORS</span>
+
+/**
+ * A description of this class.
+ *
+ * @see SomeRelatedClass.
+ *
+ * @version <tt>$Revision: 7755 $</tt>
+ * @author <a href="mailto:{email}">{full
name}</a>
+ */
+public class X
+ extends Y
+ implements Z
+{
+ public void startService() throws Exception
+ {
+ // Use the newline for the opening bracket so we can match top
+ // and bottom bracket visually
+
+ Class cls = Class.forName(dataSourceClass);
+ vendorSource = (XADataSource)cls.newInstance();
+
+ // Jump a line between logically distinct <span
class="important">steps</span> and add<
+ // line of comment to it
+ cls = vendorSource.getClass();
+
+ // Comment lines <span class="important">always</span> start
with an uppercase
+ // except if it is the second line
+ if(properties != null)
+ {
+
+ try
+ {
+ }
+ catch (IOException ioe)
+ {
+ }
+ for (Iterator i = props.entrySet().iterator(); i.hasNext();)
+ {
+
+ // Get the name and value for the attributes
+ Map.Entry entry = (Map.Entry) i.next();
+ String attributeName = (String) entry.getKey();
+ String attributeValue = (String) entry.getValue();
+
+ // Print the debug message
+ log.debug("Setting attribute '" + attributeName + "'
to '" + attributeValue + "'");
+
+ // get the attribute
+ Method setAttribute =
+ cls.getMethod("set" + attributeName, new Class[] { String.class
});
+
+ // And set the value
+ setAttribute.invoke(vendorSource, new Object[] { attributeValue });
+ }
+ }
+
+ <span class="bad">// this is a <span
class="important">bad</span> comment line because it starts with a
lower case</span>
+ vendorSource.getXAConnection().close();
+
+ // Bind in JNDI
+ bind(new InitialContext(), "java:/"+getPoolName(),
+ new Reference(vendorSource.getClass().getName(),
+ getClass().getName(), null));
+
+ // Block must always be delimited explicitely
+ if (0 == 0)
+ <span class="important">{</span>
+ System.out.println(true);
+ <span class="important">}</span>
+
+ }
+}
+</pre>
+</body>
+</html>
Property changes on: modules/faces/trunk/build/misc/codeguide.html
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/faces/trunk/build/pom.xml
===================================================================
--- modules/faces/trunk/build/pom.xml (rev 0)
+++ modules/faces/trunk/build/pom.xml 2009-06-05 03:25:58 UTC (rev 13436)
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2009, Red Hat Middleware, LLC, and individual
+ ~ contributors as indicated by the @authors tag. See the
+ ~ copyright.txt in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ This 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 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software 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
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!--
+ This pom functions as a default configuration. The subproject
+ poms each inherit configuration from this one.
+
+ When adding version information for an artifact please do the following
+ - add a version property for the specific version
+ - add a dependency in the dependencyManagement section which refers to
+ the property
+-->
+<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/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal</groupId>
+ <artifactId>jboss-portal-parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.portal.faces</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>JBoss Portal JSF Support Parent</name>
+ <description>JBoss Portal JSF Support</description>
+
+
+ <!--JBoss reporitories to be able to grab jboss-portal-parent pom-->
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <
url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <
url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+
+ <!--Sample additional plugin repository. This one is not needed if you don't
use maven-antrun-extended-plugin
+ (used in module-c)-->
+ <pluginRepositories>
+ <pluginRepository>
+ <
id>java.net maven repository</id>
+ <
url>http://download.java.net/maven/2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+
+</project>
Added: modules/faces/trunk/faces/pom.xml
===================================================================
--- modules/faces/trunk/faces/pom.xml (rev 0)
+++ modules/faces/trunk/faces/pom.xml 2009-06-05 03:25:58 UTC (rev 13436)
@@ -0,0 +1,82 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2009, Red Hat Middleware, LLC, and individual
+ ~ contributors as indicated by the @authors tag. See the
+ ~ copyright.txt in the distribution for a full listing of
+ ~ individual contributors.
+ ~
+ ~ This 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 2.1 of
+ ~ the License, or (at your option) any later version.
+ ~
+ ~ This software 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
+ ~ Lesser General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public
+ ~ License along with this software; if not, write to the Free
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<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/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.faces</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>faces</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal JSF Support</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>common-common</artifactId>
+ <version>1.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.portal.portlet</groupId>
+ <artifactId>portlet-portlet</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.portal.portlet</groupId>
+ <artifactId>portlet-bridge</artifactId>
+ <version>trunk-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.2_12</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.facelets</groupId>
+ <artifactId>jsf-facelets</artifactId>
+ <version>1.1.15.B1</version>
+ </dependency>
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.15</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFInvocation.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFInvocation.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFInvocation.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,284 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.application.ViewHandler;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.net.media.MediaType;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.util.MarkupInfo;
+import org.jboss.portal.portlet.ActionURL;
+import org.jboss.portal.portlet.ContainerURL;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.URLFormat;
+import org.jboss.portal.portlet.bridge.JBossServletContextProvider;
+import org.jboss.portal.portlet.impl.spi.AbstractPortletInvocationContext;
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.portlet.spi.SecurityContext;
+import org.jboss.portal.portlet.spi.ServerContext;
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.spi.WindowContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 11167 $
+ */
+public class JSFInvocation
+{
+
+ /** . */
+ final HttpServletRequest clientRequest;
+
+ /** . */
+ final HttpServletResponse clientResponse;
+
+ /** . */
+ final FacesContext faces;
+
+ /** . */
+ final UIPortlet uiportlet;
+
+ /** . */
+ final PortalContext portalContext;
+
+ /** . */
+ final RequestContext requestContext;
+
+ /** . */
+ final SecurityContext securityContext;
+
+ /** . */
+ final UserContext userContext;
+
+ /** . */
+ final WindowContext windowContext;
+
+ /** . */
+ final ServerContext serverContext;
+
+ public JSFInvocation(FacesContext faces, UIPortlet uiportlet)
+ {
+ // Get request and response
+ JBossServletContextProvider.BridgeInfo info = JBossServletContextProvider.get();
+ PortletInvocation portletInvocation = info.getInvocation();
+ this.clientRequest = portletInvocation.getDispatchedRequest();
+ this.clientResponse = portletInvocation.getDispatchedResponse();
+ this.faces = faces;
+ this.uiportlet = uiportlet;
+
+ //
+ this.portalContext = new JSFPortalContext(faces, uiportlet);
+ this.requestContext = new AbstractRequestContext(clientRequest);
+ this.securityContext = new JSFSecurityContext(faces);
+ this.windowContext = new JSFWindowContext(faces);
+ this.serverContext = new JSFServerContext(this);
+ this.userContext = new JSFUserContext((JSFServerContext)serverContext, faces);
+ }
+
+ String renderURL(ContainerURL containerURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ {
+ ViewHandler vh = faces.getApplication().getViewHandler();
+ String viewId = faces.getViewRoot().getViewId();
+ String clientId = uiportlet.getClientId(faces);
+
+ String actionURL = vh.getActionURL(faces, viewId);
+ actionURL = faces.getExternalContext().encodeActionURL(actionURL);
+
+ CharBuffer url = new CharBuffer();
+ url.append(actionURL);
+
+ //
+ url.append("&").append(clientId).append("=jbp");
+
+ PortletRequestEncoder encoder = new PortletRequestEncoder();
+
+ if (containerURL instanceof ActionURL)
+ {
+ ActionURL actionURL2 = (ActionURL)containerURL;
+ encoder.encodeAction(null, actionURL2.getInteractionState(),
actionURL2.getMode(), actionURL2.getWindowState());
+ }
+ else if (containerURL instanceof RenderURL)
+ {
+ RenderURL renderURL = (RenderURL)containerURL;
+ encoder.encodeRender(renderURL.getNavigationalState(), renderURL.getMode(),
renderURL.getWindowState());
+ }
+
+ for (Iterator<Map.Entry<String, String[]>> i =
encoder.getQueryParameters().entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry<String, String[]> entry = (Map.Entry<String,
String[]>)i.next();
+ String name = FastURLEncoder.getUTF8Instance().encode((String)entry.getKey());
+ String[] values = (String[])entry.getValue();
+ for (int j = 0; j < values.length; j++)
+ {
+ String value = values[j];
+ url.append("&").append(name).append('=');
+ FastURLEncoder.getUTF8Instance().encode(value, url);
+ }
+ }
+
+ //
+ return url.asString();
+ }
+
+ public PortletInvocationResponse action(
+ Portlet portlet,
+ Mode mode,
+ WindowState windowState,
+ StateString interactionState) throws PortletInvokerException
+ {
+ PortletInvocationContext portletInvocationContext = new
JSFPortletInvocationContext(clientRequest, clientResponse, new
MarkupInfo(MediaType.TEXT_HTML, "UTF-8"), this);
+
+ //
+ ActionInvocation action = new ActionInvocation(portletInvocationContext);
+ action.setInteractionState(interactionState);
+
+ if (mode != null)
+ {
+ action.setMode(mode);
+ }
+ else
+ {
+ action.setMode(Mode.VIEW);
+ }
+
+ if (windowState != null)
+ {
+ action.setWindowState(windowState);
+ }
+ else
+ {
+ action.setWindowState(WindowState.NORMAL);
+ }
+
+ //
+ return invoke(portlet, action);
+ }
+
+ public PortletInvocationResponse render(
+ Portlet portlet,
+ Mode mode,
+ WindowState windowState,
+ Map<String, String[]> navState) throws PortletInvokerException
+ {
+
+ PortletInvocationContext portletInvocationContext = new
JSFPortletInvocationContext(clientRequest, clientResponse, new
MarkupInfo(MediaType.TEXT_HTML, "UTF-8"), this);
+
+ //
+ PortletInvocation render = new RenderInvocation(portletInvocationContext);
+ render.setNavigationalState(ParametersStateString.create(navState));
+
+ if (mode != null)
+ {
+ render.setMode(mode);
+ }
+ else
+ {
+ render.setMode(Mode.VIEW);
+ }
+
+ if (windowState != null)
+ {
+ render.setWindowState(windowState);
+ }
+ else
+ {
+ render.setWindowState(WindowState.NORMAL);
+ }
+
+ //
+ return invoke(portlet, render);
+ }
+
+ private PortletInvocationResponse invoke(
+ Portlet portlet,
+ PortletInvocation invocation) throws PortletInvokerException
+ {
+ //
+ invocation.setPortalContext(portalContext);
+ invocation.setSecurityContext(securityContext);
+ invocation.setUserContext(userContext);
+ invocation.setServerContext(serverContext);
+ invocation.setWindowContext(windowContext);
+
+ //
+ invocation.setTarget(portlet.getContext());
+ PortletInvoker invoker = uiportlet.getPortletInvoker();
+ return invoker.invoke(invocation);
+ }
+
+ private static class JSFPortletInvocationContext extends
AbstractPortletInvocationContext
+ {
+
+ private HttpServletRequest clientRequest;
+
+ private HttpServletResponse clientResponse;
+
+ private JSFInvocation invocation;
+
+ public JSFPortletInvocationContext(HttpServletRequest clientRequest,
HttpServletResponse clientResponse, MarkupInfo markupInfo, JSFInvocation invocation)
+ {
+ super(markupInfo);
+
+ this.clientRequest = clientRequest;
+ this.clientResponse = clientResponse;
+ this.invocation = invocation;
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return clientRequest;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return clientResponse;
+ }
+
+ public String renderURL(ContainerURL containerURL, URLFormat urlFormat)
+ {
+ return invocation.renderURL(containerURL, urlFormat.getWantSecure(),
urlFormat.getWantAuthenticated(), urlFormat.getWantRelative());
+ }
+ }
+
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFPortalContext.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFPortalContext.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFPortalContext.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.spi.PortalContext;
+
+import javax.faces.context.FacesContext;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class JSFPortalContext implements PortalContext
+{
+
+ /** . */
+ private static final Set defaultModes = Collections.unmodifiableSet(Tools.toSet(new
Mode[]{Mode.VIEW, Mode.EDIT, Mode.HELP}));
+
+ /** . */
+ private static final Set defaultWindowStates =
Collections.unmodifiableSet(Tools.toSet(new WindowState[]{WindowState.NORMAL,
WindowState.MINIMIZED, WindowState.MAXIMIZED}));
+
+ /** . */
+ private final FacesContext faces;
+
+ /** . */
+ private final UIPortlet portlet;
+
+ /** . */
+ private Set modes;
+
+ /** . */
+ private Set windowStates;
+
+ public JSFPortalContext(FacesContext faces, UIPortlet portlet)
+ {
+ this.faces = faces;
+ this.portlet = portlet;
+ }
+
+ public String getInfo()
+ {
+ return "JSF/1.0";
+ }
+
+ public Set getWindowStates()
+ {
+ if (windowStates == null)
+ {
+ Set tmp = portlet.getSupportedWindowStates();
+ if (tmp != null)
+ {
+ windowStates = new HashSet(tmp.size());
+ for (Iterator i = tmp.iterator(); i.hasNext();)
+ {
+ String windowStateName = (String)i.next();
+ WindowState windowState = WindowState.create(windowStateName);
+ windowStates.add(windowState);
+ }
+ }
+ else
+ {
+ windowStates = defaultWindowStates;
+ }
+ }
+ return windowStates;
+ }
+
+ public Set getModes()
+ {
+ if (modes == null)
+ {
+ Set tmp = portlet.getSupportedModes();
+ if (tmp != null)
+ {
+ modes = new HashSet(tmp.size());
+ for (Iterator i = tmp.iterator(); i.hasNext();)
+ {
+ String modeName = (String)i.next();
+ Mode windowState = Mode.create(modeName);
+ modes.add(windowState);
+ }
+ }
+ else
+ {
+ modes = defaultModes;
+ }
+ }
+ return modes;
+ }
+
+ public Map getProperties()
+ {
+ return Collections.EMPTY_MAP;
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import org.jboss.portal.portlet.spi.SecurityContext;
+
+import javax.faces.context.FacesContext;
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class JSFSecurityContext implements SecurityContext
+{
+
+ /** . */
+ private final FacesContext faces;
+
+ public JSFSecurityContext(FacesContext faces)
+ {
+ this.faces = faces;
+ }
+
+ public boolean isSecure()
+ {
+ return false;
+ }
+
+ public boolean isAuthenticated()
+ {
+ return faces.getExternalContext().getRemoteUser() != null;
+ }
+
+ public String getAuthType()
+ {
+ return faces.getExternalContext().getAuthType();
+ }
+
+ public String getRemoteUser()
+ {
+ return faces.getExternalContext().getRemoteUser();
+ }
+
+ public Principal getUserPrincipal()
+ {
+ return faces.getExternalContext().getUserPrincipal();
+ }
+
+ public boolean isUserInRole(String roleName)
+ {
+ return faces.getExternalContext().isUserInRole(roleName);
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFServerContext.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFServerContext.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFServerContext.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.impl.spi.AbstractServerContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 10090 $
+ */
+public class JSFServerContext extends AbstractServerContext
+{
+
+ /** . */
+ private final JSFInvocation invocation;
+
+ public JSFServerContext(JSFInvocation invocation)
+ {
+ super(invocation.clientRequest, invocation.clientResponse);
+
+ //
+ this.invocation = invocation;
+
+ //
+ /*
+ addResolver(PortletInvocation.INVOCATION_SCOPE, new MapAttributeResolver());
+ addResolver(PortletInvocation.REQUEST_SCOPE, new
RequestAttributeResolver(invocation.clientRequest));
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new
PrincipalAttributeResolver(invocation.clientRequest));
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE,
EmptyAttributeResolver.getInstance());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new
MapAttributeResolver());
+ */
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return invocation.clientRequest;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return invocation.clientResponse;
+ }
+
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean
wantAuthenticated, boolean relative)
+ {
+ return invocation.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFUserContext.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFUserContext.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFUserContext.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.spi.UserContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 11166 $
+ */
+public class JSFUserContext implements UserContext
+{
+
+ /** . */
+ private final FacesContext faces;
+
+ private AttributeResolver principalAttributeResolver;
+
+ public JSFUserContext(JSFServerContext ctx, FacesContext faces)
+ {
+ this.faces = faces;
+ this.principalAttributeResolver = new
PrincipalAttributeResolver(ctx.getClientRequest());
+ }
+
+ public String getId()
+ {
+ return null;
+ }
+
+ public Map<String, String> getInformations()
+ {
+ return null;
+ }
+
+ public Locale getLocale()
+ {
+ return faces.getExternalContext().getRequestLocale();
+ }
+
+ public List<Locale> getLocales()
+ {
+ return Tools.toList(faces.getExternalContext().getRequestLocales());
+ }
+
+ public Object getAttribute(String arg0)
+ {
+ return principalAttributeResolver.getAttribute(arg0);
+ }
+
+ public void setAttribute(String arg0, Object arg1)
+ {
+ principalAttributeResolver.setAttribute(arg0, arg1);
+ }
+
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFWindowContext.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFWindowContext.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/JSFWindowContext.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import org.jboss.portal.common.util.UUIDGenerator;
+import org.jboss.portal.portlet.spi.WindowContext;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class JSFWindowContext implements WindowContext
+{
+
+ /** . */
+ private static final UUIDGenerator generator = new UUIDGenerator();
+
+ /** . */
+ private final FacesContext faces;
+
+ /** . */
+ private String id;
+
+ public JSFWindowContext(FacesContext faces)
+ {
+ this.faces = faces;
+ this.id = generator.generateKey();
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletActionEvent.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletActionEvent.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletActionEvent.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,149 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 11068 $
+ */
+public class PortletActionEvent extends PortletEvent
+{
+
+ /** . */
+ private final Map<String, String[]> interactionState;
+
+ /** . */
+ private Mode mode;
+
+ /** . */
+ private WindowState windowState;
+
+ PortletActionEvent(UIComponent uiComponent, Map<String, String[]>
interactionState, Mode mode, WindowState windowState)
+ {
+ super(uiComponent);
+
+ //
+ if (mode == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (windowState == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.interactionState = interactionState;
+ this.mode = mode;
+ this.windowState = windowState;
+ }
+
+ public Map<String, String[]> getParameterMap()
+ {
+ return interactionState;
+ }
+
+ public String getMode()
+ {
+ return mode.toString();
+ }
+
+ public void setMode(String mode)
+ {
+ if (mode == null)
+ {
+ throw new IllegalArgumentException("No mode provided");
+ }
+ this.mode = Mode.create(mode);
+ }
+
+ public String getWindowState()
+ {
+ return windowState.toString();
+ }
+
+ public void setWindowState(String windowState)
+ {
+ if (mode == null)
+ {
+ throw new IllegalArgumentException("No window state provided");
+ }
+ this.windowState = WindowState.create(windowState);
+ }
+
+ protected PortletInvocationResponse pir;
+
+ void execute(FacesContext faces)
+ {
+ UIPortlet uiportlet = (UIPortlet)getComponent();
+
+ // Get portlet
+ Portlet portlet = uiportlet.getPortlet();
+
+ //
+ JSFInvocation invocation = new JSFInvocation(faces, uiportlet);
+
+ //
+ try
+ {
+ pir = invocation.action(portlet, mode, windowState,
ParametersStateString.create(interactionState));
+ if (pir instanceof UpdateNavigationalStateResponse)
+ {
+ UpdateNavigationalStateResponse response =
(UpdateNavigationalStateResponse)pir;
+
+ //
+
uiportlet.setInternalNavState(((ParametersStateString)response.getNavigationalState()).getParameters());
+
+ //
+ if (response.getWindowState() != null)
+ {
+ uiportlet.setInternalWindowState(response.getWindowState());
+ }
+
+ //
+ if (response.getMode() != null)
+ {
+ uiportlet.setInternalMode(response.getMode());
+ }
+
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletEvent.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletEvent.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletEvent.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class PortletEvent extends ActionEvent
+{
+
+ public PortletEvent(UIComponent uiComponent)
+ {
+ super(uiComponent);
+ }
+
+ public boolean isAppropriateListener(FacesListener listener)
+ {
+ return listener instanceof PortletListener;
+ }
+
+ public void processListener(FacesListener listener)
+ {
+ ((PortletListener)listener).processEvent(this);
+ }
+
+ void execute(FacesContext faces)
+ {
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletEventEvent.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletEventEvent.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletEventEvent.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class PortletEventEvent extends PortletEvent
+{
+ /** . */
+ private final ParameterMap interactionState;
+
+ /** . */
+ private UpdateNavigationalStateResponse.Event event;
+
+ public PortletEventEvent(UIComponent uiComponent, ParameterMap interactionState,
UpdateNavigationalStateResponse.Event event)
+ {
+ // FIXME PortletEventEvent constructor
+ super(uiComponent);
+ this.event = event;
+ this.interactionState = interactionState;
+ }
+
+ public UpdateNavigationalStateResponse.Event getEvent()
+ {
+ return event;
+ }
+
+ public Map getParameterMap()
+ {
+ return interactionState;
+ }
+
+}
+
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletHandler.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletHandler.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletHandler.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+import org.jboss.portal.common.util.Tools;
+
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 12190 $
+ */
+public class PortletHandler extends ComponentHandler
+{
+ public PortletHandler(ComponentConfig config)
+ {
+ super(config);
+ }
+
+
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ MetaRuleset mr = super.createMetaRuleset(type);
+
+ //
+ mr.addRule(new MetaRule()
+ {
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta)
+ {
+ if ("supportedModes".equals(name))
+ {
+ if (attribute.isLiteral())
+ {
+ String s = attribute.getValue();
+ PropertyEditor editor =
PropertyEditorManager.findEditor(String[].class);
+ editor.setAsText(s);
+ String[] values = (String[])editor.getValue();
+ final Set set = Tools.toSet(values);
+ return new Metadata()
+ {
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ UIPortlet portlet = (UIPortlet)instance;
+ portlet.setSupportedModes(set);
+ }
+ };
+ }
+ }
+ if ("supportedWindowStates".equals(name))
+ {
+ if (attribute.isLiteral())
+ {
+ String s = attribute.getValue();
+ PropertyEditor editor =
PropertyEditorManager.findEditor(String[].class);
+ editor.setAsText(s);
+ String[] values = (String[])editor.getValue();
+ final Set set = Tools.toSet(values);
+ return new Metadata()
+ {
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ UIPortlet portlet = (UIPortlet)instance;
+ portlet.setSupportedWindowStates(set);
+ }
+ };
+ }
+ }
+ if ("onClick".equals(name))
+ {
+ final String s = attribute.getValue();
+ return new Metadata()
+ {
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ UIPortlet portlet = (UIPortlet)instance;
+ portlet.setOnClick(s);
+ }
+ };
+ }
+ return null;
+ }
+ });
+
+ return mr;
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletListener.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletListener.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletListener.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface PortletListener extends FacesListener
+{
+ void processEvent(PortletEvent event);
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 11068 $
+ */
+public class PortletRenderEvent extends PortletEvent
+{
+
+ /** . */
+ private final Map<String, String[]> navState;
+
+ /** . */
+ private Mode mode;
+
+ /** . */
+ private WindowState windowState;
+
+ public PortletRenderEvent(UIComponent uiComponent, Map<String, String[]>
navState, Mode mode, WindowState windowState)
+ {
+ super(uiComponent);
+
+ //
+ this.navState = navState;
+ this.mode = mode;
+ this.windowState = windowState;
+ }
+
+ public Map getParameterMap()
+ {
+ return navState;
+ }
+
+ public String getMode()
+ {
+ return mode != null ? mode.toString() : null;
+ }
+
+ public void setMode(String mode)
+ {
+ this.mode = mode != null ? Mode.create(mode) : null;
+ }
+
+ public String getWindowState()
+ {
+ return windowState != null ? windowState.toString() : null;
+ }
+
+ public void setWindowState(String windowState)
+ {
+ this.windowState = windowState != null ? WindowState.create(windowState) : null;
+ }
+
+ void execute(FacesContext faces)
+ {
+ UIPortlet uiportlet = (UIPortlet)getComponent();
+ uiportlet.setInternalNavState(navState);
+
+ //
+ if (windowState != null)
+ {
+
+ uiportlet.setInternalWindowState(windowState);
+ }
+
+ //
+ if (mode != null)
+ {
+ uiportlet.setInternalMode(mode);
+ }
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRequestDecoder.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRequestDecoder.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRequestDecoder.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,324 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.OpaqueStateString;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This class is a possible implementation for the behavior of a request made to a
portlet. Which means that this
+ * implementation does not preclude other implementations.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6549 $
+ */
+public class PortletRequestDecoder
+{
+
+ /** The mask for action. */
+ public static final int ACTION_MASK = 0x00000001;
+
+ /** The mask for render. */
+ public static final int RENDER_MASK = 0x00000002;
+
+ /** The mask for mode. */
+ public static final int MODE_MASK = 0x00000004;
+
+ /** The mask for window state. */
+ public static final int WINDOW_STATE_MASK = 0x00000008;
+
+ /** The mask for opacity. */
+ public static final int OPAQUE_MASK = 0x00000010;
+
+ /** The name of the URL parameter containing the mode. */
+ public static final String MODE_PARAMETER = "mode";
+
+ /** The name of the URL parameter containing the window state. */
+ public static final String WINDOW_STATE_PARAMETER = "windowstate";
+
+ /** The name of the URL parameter containing the interaction state. */
+ public static final String INTERACTION_STATE_PARAMETER = "is";
+
+ /** The name of the URL parameter containing the navigational state. */
+ public static final String NAVIGATIONAL_STATE_PARAMETER = "ns";
+
+ /** The name of the URL parameter containing the meta information. */
+ public static final String META_PARAMETER = "action";
+
+ /** . */
+ public static final int ACTION_TYPE = 0;
+
+ /** . */
+ public static final int RENDER_TYPE = 1;
+
+ /** . */
+ public static final int NAV_TYPE = 2;
+
+ /** . */
+ private Mode mode;
+
+ /** . */
+ private WindowState windowState;
+
+ /** . */
+ private StateString navigationalstate;
+
+ /** . */
+ private StateString interactionState;
+
+ /** . */
+ private ParameterMap form;
+
+ /** . */
+ private int type;
+
+ public void decode(Map queryParams, Map bodyParams) throws IllegalArgumentException
+ {
+ // The meta info from the URL
+ int meta = 0;
+ String[] metaParam = (String[])queryParams.get(META_PARAMETER);
+ if (metaParam != null)
+ {
+ try
+ {
+ meta = Integer.parseInt(metaParam[0], 16);
+ }
+ catch (NumberFormatException ignore)
+ {
+ // If mask is not present then we assume that it can only be a navigation URL
(NAV_TYPE)
+ }
+ }
+
+ //
+ if ((meta & (ACTION_MASK | RENDER_MASK)) != 0)
+ {
+ // Check validity
+ if ((meta & (ACTION_MASK | RENDER_MASK)) == (ACTION_MASK | RENDER_MASK))
+ {
+ throw new IllegalArgumentException("Cannot have both action and render
in the mask at the same time");
+ }
+
+ //
+ if ((meta & ACTION_MASK) != 0)
+ {
+ type = ACTION_TYPE;
+ }
+ else
+ {
+ type = RENDER_TYPE;
+ }
+
+ // Get the mode from the parameters if it exists
+ if ((meta & MODE_MASK) != 0)
+ {
+ String[] modeParam = (String[])queryParams.get(MODE_PARAMETER);
+ if (modeParam == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ mode = Mode.create(modeParam[0]);
+ }
+ else
+ {
+ mode = null;
+ }
+
+ // Get the window state from the parameters if it exists
+ if ((meta & WINDOW_STATE_MASK) != 0)
+ {
+ String[] windowStateParam =
(String[])queryParams.get(WINDOW_STATE_PARAMETER);
+ if (windowStateParam == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ windowState = WindowState.create(windowStateParam[0]);
+ }
+ else
+ {
+ windowState = null;
+ }
+
+ //
+ boolean opaque = (meta & OPAQUE_MASK) != 0;
+ if (!opaque)
+ {
+ // Compute the parameters skipping the portlet navigational state that may be
encoded as well
+ ParametersStateString query = ParametersStateString.create();
+ for (Iterator i = queryParams.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ int index = 0;
+ String name = (String)entry.getKey();
+ String[] queryValues = (String[])entry.getValue();
+
+ //
+ if (META_PARAMETER.equals(name))
+ {
+ index = 1;
+ }
+ else if ((meta & MODE_MASK) != 0 &&
MODE_PARAMETER.equals(name))
+ {
+ index = 1;
+ }
+ else if ((meta & WINDOW_STATE_MASK) != 0 &&
WINDOW_STATE_PARAMETER.equals(name))
+ {
+ index = 1;
+ }
+
+ // We have interaction param(s) in the query string
+ if (index < queryValues.length)
+ {
+ String[] values = new String[queryValues.length - index];
+ System.arraycopy(queryValues, index, values, 0, values.length);
+ query.setValues(name, values);
+ }
+ }
+
+ // Julien :
+ ParameterMap form = new ParameterMap();
+ if (bodyParams != null)
+ {
+ form.putAll(bodyParams);
+ }
+
+ //
+ if (type == ACTION_TYPE)
+ {
+ this.navigationalstate = null;
+ this.interactionState = query;
+ this.form = form;
+ }
+ else
+ {
+ this.navigationalstate = query;
+ this.interactionState = null;
+ this.form = null;
+ }
+ }
+ else
+ {
+ // Decode the navigational state
+ String[] ns = (String[])queryParams.get(NAVIGATIONAL_STATE_PARAMETER);
+ if (ns != null)
+ {
+ navigationalstate = new OpaqueStateString(ns[0]);
+ }
+ else
+ {
+ navigationalstate = null;
+ }
+
+ // Decode more if we have an action
+ if (type == ACTION_TYPE)
+ {
+ // Decode the interaction state
+ String[] is = (String[])queryParams.get(INTERACTION_STATE_PARAMETER);
+ if (is != null)
+ {
+ interactionState = new OpaqueStateString(is[0]);
+ }
+ else
+ {
+ interactionState = null;
+ }
+
+ //
+ form = new ParameterMap();
+ if (bodyParams != null)
+ {
+ form.putAll(bodyParams);
+ }
+ }
+ else
+ {
+ interactionState = null;
+ form = null;
+ }
+ }
+ }
+ else
+ {
+ // Set to nav type
+ type = NAV_TYPE;
+
+ // Get the mode from the parameters if it exists
+ String[] modeParam = (String[])queryParams.get(MODE_PARAMETER);
+ if (modeParam != null)
+ {
+ mode = Mode.create(modeParam[0]);
+ }
+ else
+ {
+ mode = null;
+ }
+
+ // Get the window state from the parameters if it exists
+ String[] windowStateParam = (String[])queryParams.get(WINDOW_STATE_PARAMETER);
+ if (windowStateParam != null)
+ {
+ windowState = WindowState.create(windowStateParam[0]);
+ }
+ else
+ {
+ windowState = null;
+ }
+ }
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public StateString getNavigationalState()
+ {
+ return navigationalstate;
+ }
+
+ public StateString getInteractionState()
+ {
+ return interactionState;
+ }
+
+ public ParameterMap getForm()
+ {
+ return form;
+ }
+
+ public int getType()
+ {
+ return type;
+ }
+}
Property changes on:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRequestDecoder.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRequestEncoder.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRequestEncoder.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/PortletRequestEncoder.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,200 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.StateString;
+
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * This class is designed to provide the encoding in the query string of a URL of the
following state : <ul> <li>A set
+ * of parameters</li> <li>A mode value</li> <li>A window state
value</li> <li>A invocation type (action or render)</li>
+ * </ul>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletRequestEncoder
+{
+
+ /** . */
+ private ParameterMap queryParameters;
+
+ public PortletRequestEncoder(ParameterMap queryParameters)
+ {
+ if (queryParameters == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.queryParameters = queryParameters;
+ }
+
+ public PortletRequestEncoder()
+ {
+ this(new ParameterMap());
+ }
+
+ public void encodeAction(
+ StateString navigationalState,
+ StateString interactionState,
+ Mode mode,
+ WindowState windowState) throws IllegalArgumentException
+ {
+ queryParameters.clear();
+
+ //
+ int meta = PortletRequestDecoder.ACTION_MASK;
+
+ //
+ if (interactionState != null)
+ {
+ if (interactionState instanceof ParametersStateString)
+ {
+ // we don't need to encode the navigational state in the URL (stored in
session)
+ // but we shouldn't throw an exception here because it's needed for
template creation in WSRP
+ // so just discard it
+ navigationalState = null;
+
+ // Add the parameters
+ Map<String, String[]> parameters =
((ParametersStateString)interactionState).getParameters();
+ configure(parameters);
+ }
+ else
+ {
+ meta |= PortletRequestDecoder.OPAQUE_MASK;
+
+ // Set interaction state
+ queryParameters.setValue(PortletRequestDecoder.INTERACTION_STATE_PARAMETER,
interactionState.getStringValue());
+
+ // We may have navigational state
+ if (navigationalState != null)
+ {
+
queryParameters.setValue(PortletRequestDecoder.NAVIGATIONAL_STATE_PARAMETER,
navigationalState.getStringValue());
+ }
+ }
+ }
+
+ //
+ configure(meta, mode, windowState);
+ }
+
+ public void encodeRender(
+ StateString navigationalState,
+ Mode mode,
+ WindowState windowState)
+ {
+ queryParameters.clear();
+
+ //
+ if (navigationalState != null)
+ {
+ int meta = PortletRequestDecoder.RENDER_MASK;
+
+ //
+ if (navigationalState instanceof ParametersStateString)
+ {
+ // Add the parameters
+ Map<String, String[]> parameters =
((ParametersStateString)navigationalState).getParameters();
+ configure(parameters);
+ }
+ else
+ {
+ meta |= PortletRequestDecoder.OPAQUE_MASK;
+
+ //
+ queryParameters.setValue(PortletRequestDecoder.NAVIGATIONAL_STATE_PARAMETER,
navigationalState.getStringValue());
+ }
+
+ //
+ configure(meta, mode, windowState);
+ }
+ else
+ {
+ if (mode != null)
+ {
+ queryParameters.setValue(PortletRequestDecoder.MODE_PARAMETER,
mode.toString());
+ }
+
+ //
+ if (windowState != null)
+ {
+ queryParameters.setValue(PortletRequestDecoder.WINDOW_STATE_PARAMETER,
windowState.toString());
+ }
+ }
+ }
+
+ public ParameterMap getQueryParameters()
+ {
+ return queryParameters;
+ }
+
+ private void configure(Map<String, String[]> parameters)
+ {
+ for (Iterator i = parameters.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ String[] values = (String[])entry.getValue();
+ queryParameters.setValues(name, values);
+ }
+ }
+
+ private void configure(int meta, Mode mode, WindowState windowState)
+ {
+ if (mode != null)
+ {
+ meta |= PortletRequestDecoder.MODE_MASK;
+ setMetaParameter(PortletRequestDecoder.MODE_PARAMETER, mode.toString());
+ }
+ if (windowState != null)
+ {
+ meta |= PortletRequestDecoder.WINDOW_STATE_MASK;
+ setMetaParameter(PortletRequestDecoder.WINDOW_STATE_PARAMETER,
windowState.toString());
+ }
+ setMetaParameter(PortletRequestDecoder.META_PARAMETER, Integer.toHexString(meta));
+ }
+
+ private void setMetaParameter(String name, String value)
+ {
+ String[] values = queryParameters.getValues(name);
+ if (values == null)
+ {
+ values = new String[]{value};
+ }
+ else
+ {
+ String[] tmp = new String[values.length + 1];
+ System.arraycopy(values, 0, tmp, 1, values.length);
+ tmp[0] = value;
+ values = tmp;
+ }
+ queryParameters.setValues(name, values);
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/UIPortlet.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/UIPortlet.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/portlet/UIPortlet.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,669 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.portlet;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.component.UICommand;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.faces.util.ActionEventDispatcher;
+import org.jboss.portal.portlet.ParametersStateString;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.UpdateNavigationalStateResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 11168 $
+ * @todo: - add validation of initial mode and window state against the supported values
- add validation of mode and
+ * window state on portlet events against the supported values - add handling of non
expected results from render and
+ * process action - add handling when portlet does not exist (probably show the nested
content of the tag as markup)
+ * @todo but less important: - integrate user profile - clean up the facelet portlet
handler - make a JSP tag
+ * @todo later: - form rewriting so it can work in a JSF form
+ */
+public class UIPortlet extends UICommand
+{
+
+ /** . */
+ private final ActionEventDispatcher dispatcher = new ActionEventDispatcher(this);
+
+ /** The portlet invoker. */
+ private PortletInvoker portletInvoker;
+
+ /** The portlet id. */
+ private String portletId;
+
+ /** The event listener if not null. */
+ private MethodBinding portletListener;
+
+ /** The supported window states. */
+ private Set supportedWindowStates;
+
+ /** The supported modes. */
+ private Set supportedModes;
+
+ /** The initial window state value if not null, otherwise NORMAL is used. */
+ private String initialWindowState;
+
+ /** The initial mode value if not null, otherwise VIEW is used. */
+ private String initialMode;
+
+ /** . */
+ private String onClick;
+
+ /** The internal nav state. */
+ private Map<String, String[]> internalNavState;
+
+ /** The internal window state value. */
+ private WindowState internalWindowState;
+
+ /** The internal mode value. */
+ private Mode internalMode;
+
+ public PortletInvoker getPortletInvoker()
+ {
+ if (portletInvoker != null)
+ {
+ return portletInvoker;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("portletInvoker");
+ if (vb != null)
+ {
+ return (PortletInvoker)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setPortletInvoker(PortletInvoker portletInvoker)
+ {
+ this.portletInvoker = portletInvoker;
+ }
+
+ public String getPortletId()
+ {
+ if (portletId != null)
+ {
+ return portletId;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("portletId");
+ if (vb != null)
+ {
+ String id = (String)vb.getValue(getFacesContext());
+ if (id == null)
+ {
+ return null;
+ }
+ else
+ {
+ // getValue will return an empty string if the binding exists but is not
bound
+ return "".equals(id) ? null : id;
+ }
+ }
+
+ //
+ return null;
+ }
+
+ public void setPortletId(String portletId)
+ {
+ this.portletId = portletId;
+ }
+
+ public Set getSupportedModes()
+ {
+ if (supportedModes != null)
+ {
+ return supportedModes;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("supportedModes");
+ if (vb != null)
+ {
+ return (Set)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setSupportedModes(Set supportedModes)
+ {
+ this.supportedModes = supportedModes;
+ }
+
+ public Set getSupportedWindowStates()
+ {
+ if (supportedWindowStates != null)
+ {
+ return supportedWindowStates;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("supportedWindowStates");
+ if (vb != null)
+ {
+ return (Set)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setSupportedWindowStates(Set supportedWindowStates)
+ {
+ this.supportedWindowStates = supportedWindowStates;
+ }
+
+ public String getInitialWindowState()
+ {
+ if (initialWindowState != null)
+ {
+ return initialWindowState;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("initialWindowState");
+ if (vb != null)
+ {
+ return (String)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setInitialWindowState(String initialWindowState)
+ {
+ this.initialWindowState = initialWindowState;
+ }
+
+ public String getInitialMode()
+ {
+ if (initialMode != null)
+ {
+ return initialMode;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("initialMode");
+ if (vb != null)
+ {
+ return (String)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setInitialMode(String initialMode)
+ {
+ this.initialMode = initialMode;
+ }
+
+ public String getOnClick()
+ {
+ if (onClick != null)
+ {
+ return onClick;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("onClick");
+ if (vb != null)
+ {
+ onClick = (String)vb.getValue(getFacesContext());
+ return onClick;
+ }
+
+ //
+ return null;
+ }
+
+ public void setOnClick(String onClick)
+ {
+ this.onClick = onClick;
+ }
+
+ WindowState getInternalWindowState()
+ {
+ if (internalWindowState == null)
+ {
+ if (initialWindowState != null)
+ {
+ return WindowState.create(initialWindowState);
+ }
+ else
+ {
+ return WindowState.NORMAL;
+ }
+ }
+ else
+ {
+ return internalWindowState;
+ }
+ }
+
+ void setInternalWindowState(WindowState windowState)
+ {
+ this.internalWindowState = windowState;
+ }
+
+ Mode getInternalMode()
+ {
+ if (internalMode == null)
+ {
+ if (initialMode != null)
+ {
+ return Mode.create(initialMode);
+ }
+ else
+ {
+ return Mode.VIEW;
+ }
+ }
+ else
+ {
+ return internalMode;
+ }
+ }
+
+ void setInternalMode(Mode mode)
+ {
+ this.internalMode = mode;
+ }
+
+ void setInternalNavState(Map<String, String[]> navState)
+ {
+ ValueBinding vb = getValueBinding("renderParameters");
+ if (vb != null)
+ {
+ Map<String, String[]> renderParameters = (Map<String,
String[]>)vb.getValue(getFacesContext());
+ renderParameters.clear();
+ renderParameters.putAll(navState);
+ }
+ else
+ {
+ this.internalNavState = navState;
+ }
+ }
+
+ Map<String, String[]> getInternalNavState()
+ {
+ ValueBinding vb = getValueBinding("renderParameters");
+ if (vb != null)
+ {
+ Map<String, String[]> renderParameters = (Map<String,
String[]>)vb.getValue(getFacesContext());
+ return ParameterMap.wrap(renderParameters);
+ }
+ else
+ {
+ return internalNavState;
+ }
+ }
+
+ Portlet getPortlet()
+ {
+ String portletId = getPortletId();
+
+ //
+ if (portletId != null)
+ {
+ try
+ {
+ PortletInvoker portletInvoker = getPortletInvoker();
+ return
portletInvoker.getPortlet(PortletContext.createPortletContext(portletId));
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ //
+ return null;
+ }
+
+ @Override
+ public String getFamily()
+ {
+ return "org.jboss.portal.core.Portlet";
+ }
+
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException
+ {
+ if (event instanceof PortletEvent)
+ {
+ PortletEvent pevent = (PortletEvent)event;
+
+ //
+ FacesContext faces = getFacesContext();
+
+ //
+ dispatcher.dispatch(faces, pevent);
+
+ //
+ pevent.execute(faces);
+
+ if (pevent instanceof PortletActionEvent)
+ {
+ PortletActionEvent actionEvent = (PortletActionEvent)pevent;
+ if (actionEvent.pir instanceof UpdateNavigationalStateResponse)
+ {
+ UpdateNavigationalStateResponse response =
(UpdateNavigationalStateResponse)actionEvent.pir;
+
+ // This is a Hack
+ List<UpdateNavigationalStateResponse.Event> events =
response.getEvents();
+ for (UpdateNavigationalStateResponse.Event tmpEvent: events)
+ {
+ queueEvent(new PortletEventEvent(this,
ParameterMap.clone(actionEvent.getParameterMap()), tmpEvent));
+ }
+ }
+ }
+ }
+ else
+ {
+ super.broadcast(event);
+ }
+ }
+
+ @Override
+ public Object saveState(FacesContext faces)
+ {
+ String opaqueValue = null;
+ if (internalNavState != null)
+ {
+ opaqueValue = ParametersStateString.create(internalNavState).getStringValue();
+ }
+
+ //
+ Object values[] = new Object[11];
+ values[0] = super.saveState(faces);
+ values[1] = portletId;
+ values[2] = opaqueValue;
+ values[3] = saveAttachedState(faces, portletListener);
+ values[4] = supportedWindowStates;
+ values[5] = supportedModes;
+ values[6] = initialWindowState;
+ values[7] = initialMode;
+ values[8] = internalNavState;
+ values[9] = internalMode;
+ values[10] = onClick;
+ return values;
+ }
+
+ @Override
+ public void restoreState(FacesContext faces, Object state)
+ {
+ Object values[] = (Object[])state;
+ super.restoreState(faces, values[0]);
+ String serializedNavState = (String)values[2];
+
+ //
+ portletId = (String)values[1];
+// internalNavState = serializedNavState != null ?
ParametersStateString.create(serializedNavState).getParameters() : null;
+ portletListener = (MethodBinding)restoreAttachedState(faces, values[3]);
+ supportedWindowStates = (Set)values[4];
+ supportedModes = (Set)values[5];
+ initialWindowState = (String)values[6];
+ initialMode = (String)values[7];
+ internalNavState = (ParameterMap)values[8];
+ internalMode = (Mode)values[9];
+ onClick = (String)values[10];
+ }
+
+ @Override
+ public void decode(FacesContext faces)
+ {
+ String clientId = getClientId(faces);
+ ExternalContext externalContext = faces.getExternalContext();
+ String clientIdValue =
(String)externalContext.getRequestParameterMap().get(clientId);
+
+ // We have been targeted
+ if ("jbp".equals(clientIdValue))
+ {
+ @SuppressWarnings("unchecked")
+ Map<String, String[]> jsfParams =
externalContext.getRequestParameterValuesMap();
+ Map<String, String[]> portletParams = new HashMap<String,
String[]>();
+ for (Map.Entry<String, String[]> entry : jsfParams.entrySet())
+ {
+ String name = (String)entry.getKey();
+ if (clientId.equals(name))
+ {
+ // Skip the client id
+ }
+ else
+ {
+ String[] values = ((String[])entry.getValue()).clone();
+ portletParams.put(name, values);
+ }
+ }
+
+ faces.getExternalContext().getRequest();
+
+ // Decode the request
+ PortletRequestDecoder decoder = new PortletRequestDecoder();
+
+ decoder.decode(portletParams, null);
+ Mode mode = decoder.getMode();
+ WindowState windowState = decoder.getWindowState();
+
+ switch (decoder.getType())
+ {
+ case PortletRequestDecoder.RENDER_TYPE :
+
+ PortletRenderEvent prevent = new PortletRenderEvent(this,
((ParametersStateString) decoder
+ .getNavigationalState()).getParameters(), mode, windowState);
+ prevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ queueEvent(prevent);
+
+ break;
+ case PortletRequestDecoder.ACTION_TYPE :
+
+ if (mode == null)
+ {
+ mode = getInternalMode();
+ }
+ if (windowState == null)
+ {
+ windowState = getInternalWindowState();
+ }
+ PortletActionEvent paevent = new PortletActionEvent(this,
((ParametersStateString) decoder
+ .getInteractionState()).getParameters(), mode, windowState);
+ paevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ queueEvent(paevent);
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void encodeBegin(FacesContext faces) throws IOException
+ {
+ Portlet portlet = getPortlet();
+
+ //
+ if (portlet != null)
+ {
+ //
+ JSFInvocation invocation = new JSFInvocation(faces, this);
+
+ //
+ try
+ {
+ PortletInvocationResponse pir = invocation.render(
+ portlet,
+ getInternalMode(),
+ getInternalWindowState(),
+ getInternalNavState());
+
+ //
+ if (pir instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)pir;
+ ResponseWriter writer = faces.getResponseWriter();
+ writer.startElement("div", this);
+ writer.writeAttribute("id", "bilto", null);
+ writer.write(fragment.getContent());
+ writer.endElement("div");
+
+ writer.startElement("script", this);
+ writer.write(
+
+ "var isIE = /msie/i.test(navigator.userAgent);\n" +
+
+ "function attachEvent(elm, eventName, eventHandler) {\n"
+
+ " if (isIE) {\n" +
+ " elm.attachEvent(\"on\" + eventName,
eventHandler);\n" +
+ " } else {\n" +
+ " elm.addEventListener(eventName, eventHandler,
false);\n" +
+ " }\n" +
+ "}\n" +
+
+ "function getEventTarget(event) {\n" +
+ " var targetElement = isIE ? event.srcElement :
event.target;\n" +
+ " while (targetElement.nodeType == 3 &&
targetElement.parentNode != null) {\n" +
+ " targetElement = targetElement.parentNode;\n" +
+ " }\n" +
+ " return targetElement;\n" +
+ "}\n" +
+
+ "\n" +
+
+ "function PortletURL(url) {\n" +
+ " this.params = new Object();\n" +
+ " this.url = url;\n" +
+ " this.setParameter = function(name, value) {;\n" +
+ " this.params[name] = value;\n" +
+ " return this;\n" +
+ " }\n" +
+ " this.renderURL = function() {;\n" +
+ " var tmp = this.url;\n" +
+ " for (var i in this.params) {\n" +
+ " tmp = tmp + ('&' + i + '=' +
this.params[i]);\n" +
+ " };\n" +
+ " return tmp;\n" +
+ " }\n" +
+
+ // Temporary hack for Sun RI which encodes contextual state on the
page
+ " var viewStateId =
document.getElementById('javax.faces.ViewState')\n" +
+ " if (viewStateId != null) {\n" +
+ " this.params['javax.faces.ViewState'] =
viewStateId.value\n" +
+ " }\n" +
+
+ "}\n" +
+
+ "function fx(event) {\n" +
+ " var target = getEventTarget(event);\n" +
+ " if (target.nodeName == 'INPUT' &&
target.type == 'submit') {\n" +
+ " var current = target.parentNode;\n" +
+ " while (current.nodeName != 'FORM' &&
current.nodeName != 'BODY') {\n" +
+ " current = current.parentNode;\n" +
+ " }\n" +
+ " if (current.nodeName == 'FORM') {\n" +
+ " var action = current.action;\n" +
+ " var portletURL = new PortletURL(action);\n" +
+ " (function(url){" + onClick +
"})(portletURL);\n" +
+ " current.action = portletURL.renderURL();\n" +
+ " } else {\n" +
+ " // Really can't do nothing for now\n" +
+ " }\n" +
+ " }\n" +
+ " else if (target.nodeName == 'A') {\n" +
+ " var href = target.href;\n" +
+ " var portletURL = new PortletURL(href);\n" +
+ " (function(url){" + onClick +
"})(portletURL);\n" +
+ " target.href = portletURL.renderURL();\n" +
+ " }\n" +
+ " \n" +
+ "}\n" +
+
+ "var elt = document.getElementById('bilto');\n" +
+ "attachEvent(elt, 'click', fx);\n"
+ );
+ writer.endElement("script");
+ writer.flush();
+ }
+ else if (pir instanceof InsufficientPrivilegesResponse){
+ ResponseWriter writer = faces.getResponseWriter();
+ writer.startElement("div", this);
+ writer.write("<p class=\"portlet-msg-error\">You
don't have the privileges to access this resource.</p>");
+ writer.endElement("div");
+ writer.flush();
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ System.out.println("Portlet not found: " + portletId);
+ }
+ }
+
+ @Override
+ public void encodeChildren(FacesContext facesContext) throws IOException
+ {
+ }
+
+ @Override
+ public void encodeEnd(FacesContext facesContext) throws IOException
+ {
+ }
+
+ @Override
+ public String getRendererType()
+ {
+ // Returns null as we handle rendering ourselves
+ return null;
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,248 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.scroller;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.component.UIForm;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.ValueBinding;
+import javax.faces.render.Renderer;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 8784 $
+ */
+public class ScrollerRenderer extends Renderer
+{
+
+ private final String PREVIOUS = "Previous";
+ private final String NEXT = "Next";
+ private final String FIRST = "First";
+ private final String LAST = "Last";
+
+
+ public void encodeBegin(FacesContext facesContext, UIComponent component) throws
IOException
+ {
+ // Get Attributes
+ String styleClass = (String)getAttribute(facesContext, component,
"styleClass");
+ String datatableId = (String)getAttribute(facesContext, component,
"for");
+
+ // Get Form Component
+ UIComponent formComponent = component;
+ while (!(formComponent instanceof UIForm))
+ {
+ formComponent = formComponent.getParent();
+ }
+ String formComponentId = formComponent.getClientId(facesContext);
+
+ // Get Writer
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ // Get UIData
+ String id = getId(datatableId, component.getClientId(facesContext));
+ UIData data = (UIData)findComponent(facesContext.getViewRoot(), facesContext, id);
+
+ int first = data.getFirst();
+ int rowCount = data.getRowCount();
+ int pageSize = data.getRows();
+ if (pageSize <= 0)
+ {
+ pageSize = rowCount;
+ }
+
+ int pages = rowCount / pageSize;
+ if (rowCount % pageSize != 0)
+ {
+ pages++;
+ }
+
+ int currentPage = first / pageSize;
+ if (first >= rowCount - pageSize)
+ {
+ currentPage = pages - 1;
+ }
+
+ int startPage = 0;
+ int endPage = pages;
+
+ if (currentPage > 0)
+ {
+ writeLink(writer, component, formComponentId,
component.getClientId(facesContext), PREVIOUS, styleClass);
+ }
+ if (first < rowCount - pageSize)
+ {
+ writeLink(writer, component, formComponentId,
component.getClientId(facesContext), NEXT, styleClass);
+ }
+
+ writeHiddenField(writer, component, component.getClientId(facesContext));
+ }
+
+ public void decode(FacesContext facesContext, UIComponent component)
+ {
+ String id = component.getClientId(facesContext);
+ Map parameters = facesContext.getExternalContext().getRequestParameterMap();
+ String response = (String)parameters.get(id);
+
+ String datatableId = (String)getAttribute(facesContext, component,
"for");
+
+ // Get UIData
+ String dataId = getId(datatableId, component.getClientId(facesContext));
+ UIData data = (UIData)findComponent(facesContext.getViewRoot(), facesContext,
dataId);
+
+ int first = data.getFirst();
+ int rowCount = data.getRowCount();
+ int pageSize = data.getRows();
+ if (pageSize <= 0)
+ {
+ pageSize = rowCount;
+ }
+
+ if (response.equals(PREVIOUS))
+ {
+ first -= pageSize;
+ }
+ else if (response.equals(NEXT))
+ {
+ first += pageSize;
+ }
+
+ if (first < 0)
+ {
+ first = 0;
+ }
+ data.setFirst(first);
+ }
+
+
+ private Object getAttribute(FacesContext facesContext, UIComponent component, String
name)
+ {
+ ValueBinding vb = component.getValueBinding(name);
+ if (vb != null)
+ {
+ return vb.getValue(facesContext);
+ }
+ else
+ {
+ return component.getAttributes().get(name);
+ }
+ }
+
+ public String getId(String id, String base)
+ {
+ String separator = "" + NamingContainer.SEPARATOR_CHAR;
+ String[] idSplitted = id.split(separator);
+ String[] baseSplitted = base.split(separator);
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < (baseSplitted.length - idSplitted.length); i++)
+ {
+ buffer.append(baseSplitted[i]);
+ buffer.append(separator);
+ }
+ buffer.append(id);
+ return buffer.toString();
+ }
+
+ private UIComponent findComponent(UIComponent component, FacesContext facesContext,
String id)
+ {
+ String componentId = component.getClientId(facesContext);
+ if (componentId.equals(id))
+ {
+ return component;
+ }
+ Iterator it = component.getChildren().iterator();
+ while (it.hasNext())
+ {
+ UIComponent comp = (UIComponent)it.next();
+ UIComponent found = findComponent(comp, facesContext, id);
+ if (found != null)
+ {
+ return found;
+ }
+
+ }
+ return null;
+ }
+
+ private void writeHiddenField(ResponseWriter writer, UIComponent component, String id)
throws IOException
+ {
+ writer.startElement("input", component);
+ writer.writeAttribute("type", "hidden", null);
+ writer.writeAttribute("name", id, null);
+ writer.endElement("input");
+ }
+
+ private void writeLink(ResponseWriter writer, UIComponent component, String
formComponentId, String id, String value, String styleClass) throws IOException
+ {
+ writer.writeText(" ", null);
+ writer.startElement("input", component);
+ writer.writeAttribute("value", value, null);
+ writer.writeAttribute("type", "submit", null);
+ writer.writeAttribute("onclick", onclickCode(formComponentId, id, value),
null);
+ if (styleClass != null)
+ {
+ writer.writeAttribute("class", styleClass, "styleClass");
+ }
+ writer.endElement("input");
+
+ /*
+ writer.writeText(" ", null);
+ writer.startElement("a", component);
+ writer.writeAttribute("href", "#", null);
+ writer.writeAttribute("onclick", onclickCode(formComponentId, id, value),
null);
+ if (styleClass != null)
+ {
+ writer.writeAttribute("class", styleClass, "styleClass");
+ }
+ writer.writeText(value, null);
+ writer.endElement("a");
+ */
+ }
+
+ private String onclickCode(String formComponentId, String id, String value)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("document.forms[");
+ buffer.append("'");
+ buffer.append(formComponentId);
+ buffer.append("']");
+ buffer.append(".elements['");
+ buffer.append(id);
+ buffer.append("'].value='");
+ buffer.append(value);
+ buffer.append("';");
+ buffer.append(" document.forms[");
+ buffer.append("'");
+ buffer.append(formComponentId);
+ buffer.append("'");
+ buffer.append("].submit()");
+ buffer.append("; return false;");
+ return buffer.toString();
+ }
+
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/ScrollerTag.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/ScrollerTag.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/ScrollerTag.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.scroller;
+
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.webapp.UIComponentTag;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 8784 $
+ */
+public class ScrollerTag extends UIComponentTag
+{
+
+ private String _for;
+ private String styleClass;
+
+ public String getComponentType()
+ {
+ return "com.jboss.portal.Scroller";
+ }
+
+ public String getRendererType()
+ {
+ return "default";
+ }
+
+ public void setFor(String _for)
+ {
+ this._for = _for;
+ }
+
+ public void setStyleClass(String styleClass)
+ {
+ this.styleClass = styleClass;
+ }
+
+ public void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setString(component, "for", _for);
+ setString(component, "styleClass", styleClass);
+ }
+
+ private void setString(UIComponent component, String attributeName, String
attributeValue)
+ {
+ if (attributeValue == null)
+ {
+ return;
+ }
+ if (isValueReference(attributeValue))
+ {
+ setValueBinding(component, attributeName, attributeValue);
+ }
+ else
+ {
+ component.getAttributes().put(attributeName, attributeValue);
+ }
+ }
+
+ private void setValueBinding(UIComponent component, String attributeName, String
attributeValue)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Application app = facesContext.getApplication();
+ ValueBinding vb = app.createValueBinding(attributeValue);
+ component.setValueBinding(attributeName, vb);
+ }
+
+ public void release()
+ {
+ super.release();
+ _for = null;
+ styleClass = null;
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/UIScroller.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/UIScroller.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/component/scroller/UIScroller.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.component.scroller;
+
+import javax.faces.component.UIInput;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 8784 $
+ */
+public class UIScroller extends UIInput
+{
+ public UIScroller()
+ {
+ setRendererType("default");
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/ClassConstantPublisherBean.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/ClassConstantPublisherBean.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/ClassConstantPublisherBean.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,149 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el;
+
+import org.jboss.portal.faces.el.dynamic.DynamicBean;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * An implementation of <code>DynamicBean</code> which exposes all the fields
on a class which are public and static.
+ * The properties are read only and cannot be modified. It allows to use constant names
from expression language rather
+ * than the constant values directly.
+ * <p/>
+ * <ul> <li>Class objects of type class or interface are
supported.</li> <li>Class inheritence is supported, Class
+ * object returned from <code>Class.getSuperClass()</code> is
examined.</li> <li>Interface implementation is not yet
+ * supported, Class objects returned from <code>Class.getInterfaces()</code>
are not examined.</li> </ul>
+ * <p/>
+ * todo: implement and test interfaces returned by
<code>Class.getInterfaces()</code>.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class ClassConstantPublisherBean implements DynamicBean
+{
+
+ /** The class name. */
+ private String className;
+
+ /** The cached entries. */
+ private volatile Map entries;
+
+ private static Map getEntries(Class clazz)
+ {
+ Class superClazz = clazz.getSuperclass();
+ Map entries = clazz.getSuperclass() == null ? new HashMap() :
getEntries(superClazz);
+
+ //
+ try
+ {
+ Field[] fields = clazz.getDeclaredFields();
+ for (int i = 0; i < fields.length; i++)
+ {
+ Field field = fields[i];
+ final int modifiers = field.getModifiers();
+ if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers))
+ {
+ Object value = field.get(null);
+ entries.put(field.getName(), value);
+ }
+ }
+ }
+ catch (IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+
+ //
+ return entries;
+ }
+
+ private Map getEntries()
+ {
+ if (entries == null)
+ {
+ try
+ {
+ Class clazz =
Thread.currentThread().getContextClassLoader().loadClass(className);
+ this.entries = getEntries(clazz);
+ }
+ catch (ClassNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return entries;
+ }
+
+ public Class getType(Object propertyName) throws IllegalArgumentException
+ {
+ if ("className".equals(propertyName))
+ {
+ return String.class;
+ }
+
+ //
+ Map entries = getEntries();
+ Object value = entries.get(propertyName);
+ return value != null ? value.getClass() : null;
+ }
+
+ public PropertyValue getValue(Object propertyName) throws IllegalArgumentException
+ {
+ if ("className".equals(propertyName))
+ {
+ return new PropertyValue(className);
+ }
+
+ //
+ Map entries = getEntries();
+ Object value = entries.get(propertyName);
+ return new PropertyValue(value);
+ }
+
+ public boolean setValue(Object propertyName, Object value) throws
IllegalArgumentException
+ {
+ if ("className".equals(propertyName))
+ {
+ this.className = (String)value;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/DelegatingPropertyResolver.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/DelegatingPropertyResolver.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/DelegatingPropertyResolver.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,402 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.reflect.Modifier;
+import org.jboss.portal.faces.el.decorator.BeanDecorator;
+import org.jboss.portal.faces.el.dynamic.DynamicBean;
+
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.PropertyResolver;
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A property resolver that provide fine grained configuration of the resolution
mechanism.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class DelegatingPropertyResolver extends PropertyResolver
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(DelegatingPropertyResolver.class);
+
+ /** . */
+ private final PropertyResolver delegate;
+
+ /** . */
+ private volatile Map decoratorMap = new HashMap();
+
+ public DelegatingPropertyResolver(PropertyResolver delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public DelegatingPropertyResolver()
+ {
+ this(null);
+ }
+
+ public Class getType(Object base, Object property) throws EvaluationException,
PropertyNotFoundException
+ {
+ // See if the object can handle itself the property
+ if (base instanceof DynamicBean)
+ {
+ DynamicBean dynamicBean = (DynamicBean)base;
+ Class type = dynamicBean.getType(property);
+ if (type != null)
+ {
+ return type;
+ }
+ }
+
+ //
+ GetTypeBeanAction beanAction = new GetTypeBeanAction(base, property);
+ if (resolveAction(base.getClass(), beanAction))
+ {
+ return beanAction.type;
+ }
+
+ //
+ if (property instanceof String)
+ {
+ try
+ {
+ Field f = base.getClass().getField((String)property);
+ if (Modifier.isReadableProperty(f))
+ {
+ return f.getType();
+ }
+ }
+ catch (NoSuchFieldException ignore)
+ {
+ }
+ }
+
+ //
+ if (delegate != null)
+ {
+ return delegate.getType(base, property);
+ }
+
+ //
+ throw createPNFE(base, property);
+ }
+
+ public boolean isReadOnly(Object base, Object property) throws EvaluationException,
PropertyNotFoundException
+ {
+ //
+ if (delegate != null)
+ {
+ return delegate.isReadOnly(base, property);
+ }
+
+ //
+ throw createPNFE(base, property);
+ }
+
+ public Object getValue(final Object base, final Object property) throws
EvaluationException, PropertyNotFoundException
+ {
+ // See if the object can handle itself the property
+ if (base instanceof DynamicBean)
+ {
+ DynamicBean dynamicBean = (DynamicBean)base;
+ PropertyValue value = dynamicBean.getValue(property);
+ if (value != null)
+ {
+ return value.getObject();
+ }
+ }
+
+ //
+ GetValueBeanAction beanAction = new GetValueBeanAction(base, property);
+ if (resolveAction(base.getClass(), beanAction))
+ {
+ return beanAction.value.getObject();
+ }
+
+ //
+ if (property instanceof String)
+ {
+ try
+ {
+ Field f = base.getClass().getField((String)property);
+ if (Modifier.isReadableProperty(f))
+ {
+ return f.get(base);
+ }
+ }
+ catch (NoSuchFieldException ignore)
+ {
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error("Was not able to read the field " + property + " of
object " + base + " with class " + base.getClass().getName());
+ }
+ }
+
+ //
+ if (delegate != null)
+ {
+ return delegate.getValue(base, property);
+ }
+
+ //
+ throw createPNFE(base, property);
+ }
+
+ public void setValue(Object base, Object property, Object value) throws
EvaluationException, PropertyNotFoundException
+ {
+ // See if the object can handle itself the property
+ if (base instanceof DynamicBean)
+ {
+ DynamicBean dynamic = (DynamicBean)base;
+ if (dynamic.setValue(property, value))
+ {
+ return;
+ }
+ }
+
+ //
+ SetValueBeanAction beanAction = new SetValueBeanAction(base, property, value);
+ if (resolveAction(base.getClass(), beanAction))
+ {
+ return;
+ }
+
+ //
+ if (property instanceof String)
+ {
+ try
+ {
+ Field f = base.getClass().getField((String)property);
+ if (Modifier.isWritableProperty(f))
+ {
+ f.set(base, value);
+ return;
+ }
+ }
+ catch (NoSuchFieldException ignore)
+ {
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error("Was not able to write the field " + property + " of
object " + base + " with class " + base.getClass().getName());
+ }
+ }
+
+ //
+ if (delegate != null)
+ {
+ delegate.setValue(base, property, value);
+ return;
+ }
+
+ //
+ throw createPNFE(base, property);
+ }
+
+ public Class getType(Object base, int index) throws EvaluationException,
PropertyNotFoundException
+ {
+ if (delegate != null)
+ {
+ return delegate.getType(base, index);
+ }
+
+ //
+ throw createPNFE(base, index);
+ }
+
+ public boolean isReadOnly(Object base, int index) throws EvaluationException,
PropertyNotFoundException
+ {
+ //
+ if (delegate != null)
+ {
+ return delegate.isReadOnly(base, index);
+ }
+
+ //
+ throw createPNFE(base, index);
+ }
+
+ public Object getValue(Object base, int index) throws EvaluationException,
PropertyNotFoundException
+ {
+ //
+ if (delegate != null)
+ {
+ return delegate.getValue(base, index);
+ }
+
+ //
+ throw createPNFE(base, index);
+ }
+
+ public void setValue(Object base, int index, Object value) throws EvaluationException,
PropertyNotFoundException
+ {
+ //
+ if (delegate != null)
+ {
+ delegate.setValue(base, index, value);
+ }
+
+ //
+ throw createPNFE(base, index);
+ }
+
+ public final synchronized void registerDecorator(Class clazz, BeanDecorator
decorator)
+ {
+ if (clazz == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (decorator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Map copy = new HashMap(decoratorMap);
+ copy.put(clazz.getName(), decorator);
+ decoratorMap = copy;
+ log.debug("Added bean decorator " + clazz.getName() + " in resolver
map");
+ }
+
+ private static interface BeanAction
+ {
+ boolean execute(BeanDecorator decorator);
+ }
+
+ private abstract static class AbstractBeanAction implements BeanAction
+ {
+
+ /** . */
+ protected final Object base;
+
+ /** . */
+ protected final Object property;
+
+ public AbstractBeanAction(Object base, Object property)
+ {
+ this.base = base;
+ this.property = property;
+ }
+ }
+
+ private static class GetTypeBeanAction extends AbstractBeanAction
+ {
+
+ /** . */
+ private Class type;
+
+ public GetTypeBeanAction(Object base, Object property)
+ {
+ super(base, property);
+ }
+
+ public boolean execute(BeanDecorator decorator)
+ {
+ type = decorator.getType(base, property);
+ return type != null;
+ }
+ }
+
+ private static class GetValueBeanAction extends AbstractBeanAction
+ {
+
+ /** . */
+ private PropertyValue value;
+
+ public GetValueBeanAction(Object base, Object property)
+ {
+ super(base, property);
+ }
+
+ public boolean execute(BeanDecorator decorator)
+ {
+ value = decorator.getValue(base, property);
+ return value != null;
+ }
+ }
+
+ private static class SetValueBeanAction extends AbstractBeanAction
+ {
+
+ /** . */
+ private Object value;
+
+ public SetValueBeanAction(Object base, Object property, Object value)
+ {
+ super(base, property);
+ this.value = value;
+ }
+
+ public boolean execute(BeanDecorator decorator)
+ {
+ return decorator.setValue(base, property, value);
+ }
+ }
+
+ private boolean resolveAction(Class clazz, BeanAction action)
+ {
+ BeanDecorator decorator = (BeanDecorator)decoratorMap.get(clazz.getName());
+ if (decorator != null)
+ {
+ if (action.execute(decorator))
+ {
+ return true;
+ }
+ }
+ Class[] itfs = clazz.getInterfaces();
+ for (int i = 0; i < itfs.length; i++)
+ {
+ Class itf = clazz.getInterfaces()[i];
+ if (resolveAction(itf, action))
+ {
+ return true;
+ }
+ }
+ Class superClass = clazz.getSuperclass();
+ if (superClass != null)
+ {
+ if (resolveAction(superClass, action))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private PropertyNotFoundException createPNFE(Object base, int index)
+ {
+ return createPNFE(base, "[" + index + "]");
+ }
+
+ private PropertyNotFoundException createPNFE(Object base, Object propertyName)
+ {
+ return new PropertyNotFoundException("Property " + propertyName + "
on object " + base + " was not found");
+ }
+}
Property changes on:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/DelegatingPropertyResolver.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/PropertyValue.java
===================================================================
--- modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/PropertyValue.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/PropertyValue.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class PropertyValue
+{
+
+ /** . */
+ private final Object object;
+
+ public PropertyValue(Object object)
+ {
+ this.object = object;
+ }
+
+ public Object getObject()
+ {
+ return object;
+ }
+
+ public int hashCode()
+ {
+ return object == null ? 0 : object.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof PropertyValue)
+ {
+ PropertyValue that = (PropertyValue)obj;
+ return object == null ? that.object == null : object.equals(that.object);
+ }
+ return false;
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/AbstractBeanDecorator.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/AbstractBeanDecorator.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/AbstractBeanDecorator.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el.decorator;
+
+import org.jboss.portal.faces.el.PropertyValue;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public abstract class AbstractBeanDecorator implements BeanDecorator
+{
+
+ public Class getType(Object bean, Object propertyName) throws
IllegalArgumentException
+ {
+ if (bean == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ PropertyDecorator property = getProperty(propertyName);
+ if (property != null)
+ {
+ return property.getType(bean);
+ }
+
+ //
+ return null;
+ }
+
+ public PropertyValue getValue(Object bean, Object propertyName) throws
IllegalArgumentException
+ {
+ if (bean == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ PropertyDecorator property = getProperty(propertyName);
+ if (property != null)
+ {
+ return new PropertyValue(property.getValue(bean));
+ }
+
+ //
+ return null;
+ }
+
+ public boolean setValue(Object bean, Object propertyName, Object propertyValue) throws
IllegalArgumentException
+ {
+ if (bean == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ PropertyDecorator property = getProperty(propertyName);
+ if (property != null)
+ {
+ property.setValue(bean, propertyValue);
+ return true;
+ }
+
+ //
+ return false;
+ }
+
+ protected abstract PropertyDecorator getProperty(Object propertyName);
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/AbstractPropertyDecorator.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/AbstractPropertyDecorator.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/AbstractPropertyDecorator.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el.decorator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public abstract class AbstractPropertyDecorator implements PropertyDecorator
+{
+
+ /** . */
+ private final Class type;
+
+ public AbstractPropertyDecorator(Class type)
+ {
+ if (type == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.type = type;
+ }
+
+ public final Class getType(Object bean) throws IllegalArgumentException
+ {
+ return type;
+ }
+
+ public boolean setValue(Object bean, Object value) throws IllegalArgumentException
+ {
+ return false;
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/BeanDecorator.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/BeanDecorator.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/BeanDecorator.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el.decorator;
+
+import org.jboss.portal.faces.el.PropertyValue;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface BeanDecorator
+{
+ /**
+ * Return the type of the specified property.
+ *
+ * @param bean the decorated bean
+ * @param propertyName the property name
+ * @return the type of the specified property or null
+ * @throws IllegalArgumentException if the bean is null or the property name is null
+ */
+ Class getType(Object bean, Object propertyName) throws IllegalArgumentException;
+
+ /**
+ * Return the value of the specified property.
+ *
+ * @param bean the decorated bean
+ * @param propertyName the property name
+ * @return the property value
+ * @throws IllegalArgumentException if the bean is null or the property is null
+ */
+ PropertyValue getValue(Object bean, Object propertyName) throws
IllegalArgumentException;
+
+ /**
+ * Set the value of the specified property.
+ *
+ * @param bean the decorated bean
+ * @param propertyName the property name
+ * @param value the new property value
+ * @return true if the property was succesfully set
+ * @throws IllegalArgumentException if the bean is null or the property name is null
+ */
+ boolean setValue(Object bean, Object propertyName, Object value) throws
IllegalArgumentException;
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/PropertyDecorator.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/PropertyDecorator.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/PropertyDecorator.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el.decorator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface PropertyDecorator
+{
+ /**
+ * Return the type of the specified property.
+ *
+ * @param bean the decorated bean
+ * @return the type of the specified property or null
+ * @throws IllegalArgumentException if the bean is null
+ */
+ Class getType(Object bean) throws IllegalArgumentException;
+
+ /**
+ * Return the value of the specified property.
+ *
+ * @param bean the decorated bean
+ * @return the property value
+ * @throws IllegalArgumentException if the bean is null
+ */
+ Object getValue(Object bean) throws IllegalArgumentException;
+
+ /**
+ * Set the value of the specified property.
+ *
+ * @param bean the decorated bean
+ * @param value the new property value
+ * @return true if the property was succesfully set
+ * @throws IllegalArgumentException if the bean is null
+ */
+ boolean setValue(Object bean, Object value) throws IllegalArgumentException;
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/SimpleBeanDecorator.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/SimpleBeanDecorator.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/decorator/SimpleBeanDecorator.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el.decorator;
+
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class SimpleBeanDecorator extends AbstractBeanDecorator
+{
+
+ private Map properties;
+
+ public SimpleBeanDecorator()
+ {
+ properties = new ConcurrentHashMap();
+ }
+
+ protected PropertyDecorator getProperty(Object propertyName)
+ {
+ return (PropertyDecorator)properties.get(propertyName);
+ }
+
+ public void setProperty(Object propertyName, PropertyDecorator decorator)
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (decorator == null)
+ {
+ properties.remove(propertyName);
+ }
+ else
+ {
+ properties.put(propertyName, decorator);
+ }
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/AbstractDynamicBean.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/AbstractDynamicBean.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/AbstractDynamicBean.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el.dynamic;
+
+import org.jboss.portal.faces.el.PropertyValue;
+
+/**
+ * Base implementation.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class AbstractDynamicBean implements DynamicBean
+{
+
+ /** @return always null */
+ public Class getType(Object propertyName)
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return null;
+ }
+
+ /** @return always null */
+ public PropertyValue getValue(Object propertyName)
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return null;
+ }
+
+ /** @return always false */
+ public boolean setValue(Object propertyName, Object value)
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return false;
+ }
+}
Property changes on:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/AbstractDynamicBean.java
___________________________________________________________________
Name: svn:executable
+ *
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/AbstractDynamicProperty.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/AbstractDynamicProperty.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/AbstractDynamicProperty.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el.dynamic;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public abstract class AbstractDynamicProperty implements DynamicProperty
+{
+
+ /** . */
+ private Class type;
+
+ public AbstractDynamicProperty(Class type)
+ {
+ if (type == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.type = type;
+ }
+
+ public final Class getType() throws IllegalArgumentException
+ {
+ return type;
+ }
+
+ public boolean setValue(Object value) throws IllegalArgumentException
+ {
+ return false;
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/DynamicBean.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/DynamicBean.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/DynamicBean.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el.dynamic;
+
+import org.jboss.portal.faces.el.PropertyValue;
+
+/**
+ * Defines an interface that an object can implement when that object wants to manage
itself the resolution of its
+ * properties.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface DynamicBean
+{
+ /**
+ * Return the type of the specified property.
+ *
+ * @param propertyName the property name
+ * @return the type of the specified property or null
+ * @throws IllegalArgumentException if the property name is null
+ */
+ Class getType(Object propertyName) throws IllegalArgumentException;
+
+ /**
+ * Return the value of the specified property.
+ *
+ * @param propertyName the property name
+ * @return the property value
+ * @throws IllegalArgumentException if the property is null
+ */
+ PropertyValue getValue(Object propertyName) throws IllegalArgumentException;
+
+ /**
+ * Set the value of the specified property.
+ *
+ * @param propertyName the property name
+ * @param value the new property value
+ * @return true if the property was succesfully set
+ * @throws IllegalArgumentException if the property name is null
+ */
+ boolean setValue(Object propertyName, Object value) throws IllegalArgumentException;
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/DynamicProperty.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/DynamicProperty.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/DynamicProperty.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el.dynamic;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface DynamicProperty
+{
+ /**
+ * Return the type of the specified property.
+ *
+ * @return the type of the specified property or null
+ * @throws IllegalArgumentException if the property name is null
+ */
+ Class getType() throws IllegalArgumentException;
+
+ /**
+ * Return the value of the specified property.
+ *
+ * @return the property value
+ * @throws IllegalArgumentException if the property is null
+ */
+ Object getValue() throws IllegalArgumentException;
+
+ /**
+ * Set the value of the specified property.
+ *
+ * @param value the new property value
+ * @throws IllegalArgumentException if the property name is null
+ */
+ boolean setValue(Object value) throws IllegalArgumentException;
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/SimpleDynamicBean.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/SimpleDynamicBean.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/el/dynamic/SimpleDynamicBean.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.el.dynamic;
+
+import org.jboss.portal.faces.el.PropertyValue;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public abstract class SimpleDynamicBean implements DynamicBean
+{
+
+ public SimpleDynamicBean()
+ {
+ }
+
+ public Class getType(Object propertyName) throws IllegalArgumentException
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ DynamicProperty property = getProperty(propertyName);
+ if (property != null)
+ {
+ return property.getType();
+ }
+ return null;
+ }
+
+ public PropertyValue getValue(Object propertyName) throws IllegalArgumentException
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ DynamicProperty property = getProperty(propertyName);
+ if (property != null)
+ {
+ return new PropertyValue(property.getValue());
+ }
+ return null;
+ }
+
+ public boolean setValue(Object propertyName, Object value) throws
IllegalArgumentException
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ DynamicProperty property = getProperty(propertyName);
+ if (property != null)
+ {
+ return property.setValue(value);
+ }
+ return false;
+ }
+
+ /**
+ * Return a dynamic property or null if not found.
+ *
+ * @param propertyName the property name
+ * @return a dynamic property
+ */
+ protected abstract DynamicProperty getProperty(Object propertyName);
+
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/facelet/ContextTagHandler.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/facelet/ContextTagHandler.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/facelet/ContextTagHandler.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.facelet;
+
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.FaceletException;
+import com.sun.facelets.tag.TagConfig;
+import com.sun.facelets.tag.TagHandler;
+
+import javax.el.ELException;
+import javax.el.VariableMapper;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import java.io.IOException;
+
+/**
+ * Defines a context tag which allow to create use the ui:param tag without requiring to
include content. It can be seen
+ * as an immediate ui:include facility which allow to define aliases for the nested
content of the tag.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class ContextTagHandler extends TagHandler
+{
+
+ public ContextTagHandler(TagConfig tagConfig)
+ {
+ super(tagConfig);
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException,
FacesException, FaceletException, ELException
+ {
+ VariableMapper orig = ctx.getVariableMapper();
+ try
+ {
+ this.nextHandler.apply(ctx, parent);
+ }
+ finally
+ {
+ ctx.setVariableMapper(orig);
+ }
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/BeanContext.java
===================================================================
--- modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/BeanContext.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/BeanContext.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,287 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.faces.gui;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.util.ParameterValidation;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 13374 $
+ * @since 2.6
+ */
+public abstract class BeanContext
+{
+ protected final static Logger log = Logger.getLogger(BeanContext.class);
+
+ public static final String STATUS = "status";
+ private static final String DEFAULT_RESOURCE_NAME = "Resource";
+ private static final String UNEXPECTED_ERROR =
"bean_support_unexpected_error";
+ private static final String CAUSE = "bean_support_cause";
+ private static final String CURRENT_PLACEHOLDER = "###";
+
+ private String resourceName = DEFAULT_RESOURCE_NAME;
+
+ public void setResourceName(String resourceName)
+ {
+ this.resourceName = resourceName;
+ }
+
+ public String getResourceName()
+ {
+ return resourceName;
+ }
+
+ /**
+ * Retrieves the value of the parameter which name is given from the JSF request.
+ *
+ * @param key name of the parameter which value we want to retrieve
+ * @return
+ */
+ public abstract String getParameter(String key);
+
+ /**
+ * @param target
+ * @param message
+ * @param severity
+ */
+ protected abstract void createMessage(String target, String message, Object
severity);
+
+ protected abstract Object getErrorSeverity();
+
+ protected abstract Object getInfoSeverity();
+
+ protected abstract Locale getLocale();
+
+ public void createErrorMessage(String localizedMessageId, Object... params)
+ {
+ createLocalizedMessage(STATUS, localizedMessageId, getErrorSeverity(), params);
+ }
+
+ public void createTargetedErrorMessage(String target, String localizedMessageId,
Object... params)
+ {
+ createLocalizedMessage(target, localizedMessageId, getErrorSeverity(), params);
+ }
+
+ /**
+ * Adds a localized message using the appropriate severity to the identified target in
the context. This method
+ * accepts an arbitrary number of arguments to be passed as parameters of localized
strings.
+ *
+ * @param target the target in this context that will receive the new
message
+ * @param localizedMessageId a resource bundle identifier identifying which the
localized string to use as a message
+ * @param severity an object representing the severity of the message
(typically FacesMessage.Severity)
+ * @param params additional parameters to be passed to replace tokens in
localized strings
+ */
+ protected void createLocalizedMessage(String target, String localizedMessageId, Object
severity, Object... params)
+ {
+ createMessage(target, getMessageFromBundle(localizedMessageId, params), severity);
+ }
+
+ public String getMessageFromBundle(String localizedMessageId, Object... params)
+ {
+ return getLocalizedMessage(localizedMessageId, getLocale(), resourceName, params);
+ }
+
+ public static String getLocalizedMessage(String localizationKey, Locale locale,
Object... params)
+ {
+ return getLocalizedMessage(localizationKey, locale, DEFAULT_RESOURCE_NAME,
params);
+ }
+
+ public static String getLocalizedMessage(String localizationKey, Locale locale, String
resourceName, Object... params)
+ {
+ ResourceBundle rb = ResourceBundle.getBundle(resourceName, locale);
+
+ String message;
+ try
+ {
+ message = rb.getString(localizationKey);
+ }
+ catch (MissingResourceException e)
+ {
+ // if the key doesn't exist, return it instead of failing
+ log.info("Couldn't find localization message for key '" +
localizationKey + "' in bundle " + resourceName
+ + " for locale " + locale.getDisplayName());
+ return localizationKey;
+ }
+
+ return MessageFormat.format(message, params);
+ }
+
+ public void createErrorMessageFrom(Exception e)
+ {
+ createErrorMessageFrom(STATUS, e);
+ }
+
+ /**
+ * Creates a localized error message targeting the specified object in the context and
using the specified error
+ * information. This method looks for two specific resource bundle entries to localize
the message, {@link
+ * #UNEXPECTED_ERROR} and {@link #CAUSE}, using the following format for the message:
<code>result of {@link
+ * #getLocalizedMessageOrExceptionName(Throwable)} for the exception\n[localized value
associated with {@link
+ * #CAUSE}result of {@link #getLocalizedMessageOrExceptionName(Throwable)} for the
exception's cause if the cause
+ * exists]
+ *
+ * @param target the contextual object target by the message to be created
+ * @param e the exception that we want to display as an error message
+ */
+ public void createErrorMessageFrom(String target, Exception e)
+ {
+ Throwable cause = e.getCause();
+ String localizedMessage = getLocalizedMessageOrExceptionName(e);
+ String message = localizedMessage + (cause != null ? "\n" +
getMessageFromBundle(CAUSE) + getLocalizedMessageOrExceptionName(cause) : "");
+ createMessage(target, message, getErrorSeverity());
+ }
+
+ /**
+ * Retrieves a localized message associated with the specified Throwable.
+ *
+ * @param e the Throwable for which a localized message is to be retrieved
+ * @return the localized message associated with the specified Throwable if it exists
or the localized value
+ * associated with the {@link #UNEXPECTED_ERROR} resource bundle entry to
which is appended the Throwable
+ * class name.
+ */
+ private String getLocalizedMessageOrExceptionName(Throwable e)
+ {
+ String localizedMessage = e.getLocalizedMessage();
+ if (localizedMessage == null)
+ {
+ localizedMessage = getMessageFromBundle(UNEXPECTED_ERROR) +
e.getClass().getName();
+ }
+ return localizedMessage;
+ }
+
+ protected void createInfoMessage(String target, String localizedMessageId)
+ {
+ createLocalizedMessage(target, localizedMessageId, getInfoSeverity());
+ }
+
+ public void createInfoMessage(String localizedMessageId)
+ {
+ createInfoMessage(STATUS, localizedMessageId);
+ }
+
+ /**
+ * Removes the object identified by the specified name(s) from the session. For a JSF
backed implementation, this
+ * will allow for the object/bean (defined as session-scoped in
<code>faces-config.xml</code>) to be recreated by JSF
+ * when needed.
+ *
+ * @param name name of the object to be removed
+ * @param otherNames additional names of objects to be removed
+ */
+ public void removeFromSession(String name, String... otherNames)
+ {
+ Map<String, Object> sessionMap = getSessionMap();
+ sessionMap.remove(name);
+ if (otherNames != null)
+ {
+ for (String other : otherNames)
+ {
+ sessionMap.remove(other);
+ }
+ }
+ }
+
+ /**
+ * Retrieves the session map where "session" is a concept left up to
implementations (for JSF, the session
+ * corresponds quite logically to the HTTP session)
+ *
+ * @return the session map
+ */
+ public abstract Map<String, Object> getSessionMap();
+
+ /**
+ * Replaces the session object identified by the given name by the specified new one.
Passing <code>null</code> for
+ * the new value will remove the object reference from the session. If an object was
previously assigned to this
+ * name, then only an object of the same type (as defined by {@link
Class#isAssignableFrom(Class)}) can be assigned
+ * to this name.
+ *
+ * @param name the name identifying the object to be replaced
+ * @param newValue the new value for the object to be replaced or
<code>null</code> if the object is to be removed
+ * @param <T> the type of the object to be replaced
+ * @return the new value for the object or <code>null</code> if the remove
semantics is used
+ * @throws IllegalArgumentException if the new value for the identified object is not
compatible with the currently
+ * stored value
+ */
+ public <T> T replaceInSession(String name, T newValue)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "name",
"replaceInSession");
+ Map<String, Object> sessionMap = getSessionMap();
+
+ // if we passed null, use the remove semantics
+ if (newValue == null)
+ {
+ sessionMap.remove(name);
+ return null;
+ }
+
+ getFromSession(name, newValue.getClass(), sessionMap, "Provided object: "
+ newValue
+ + " is not compatible with previously assigned '" + name +
"' object: " + CURRENT_PLACEHOLDER);
+ sessionMap.put(name, newValue);
+ return newValue;
+ }
+
+ /**
+ * Retrieves the session object associated with the specified name and the expected
type.
+ *
+ * @param name name of the session object to be retrieved
+ * @param expectedClass expected class of the object
+ * @param <T> type of the object to be retrieved
+ * @return the session object associated with the specified name
+ * @throws IllegalArgumentException if the value associated with the specified name is
not <code>null</code> and does
+ * not match the specified expected class
+ */
+ public <T> T getFromSession(String name, Class<T> expectedClass)
+ {
+ return getFromSession(name, expectedClass, getSessionMap(), "Current
object:" + CURRENT_PLACEHOLDER
+ + " is not compatible with expected class " + expectedClass + "
for '" + name + "'");
+ }
+
+ /**
+ * @param name name of the session attribute to retrieve
+ * @param expectedClass expected class of the attribute
+ * @param sessionMap the session map to retrieve the attribute from
+ * @param errorMessage the error message that will be used if the attribute value is
not of the expected class, in
+ * which {@link #CURRENT_PLACEHOLDER} will be substituted by the
current value of the attribute
+ * at runtime
+ * @param <T> the type of the object to be retrieved
+ * @return the value associated with the specified name
+ * @throws IllegalArgumentException if the value associated with the specified name is
not <code>null</code> and does
+ * not match the specified expected class
+ */
+ private <T> T getFromSession(String name, Class<T> expectedClass,
Map<String, Object> sessionMap, String errorMessage)
+ {
+ Object result = sessionMap.get(name);
+ if (result != null && !expectedClass.isAssignableFrom(result.getClass()))
+ {
+ throw new IllegalArgumentException(errorMessage.replace(CURRENT_PLACEHOLDER,
result.toString()));
+ }
+
+ return expectedClass.cast(result);
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/JSFBeanContext.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/JSFBeanContext.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/JSFBeanContext.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,132 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.faces.gui;
+
+import org.jboss.portal.common.util.ParameterValidation;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 13413 $
+ * @since 2.6
+ */
+public class JSFBeanContext extends BeanContext
+{
+ public String getParameter(String key)
+ {
+ return getParameter(key, FacesContext.getCurrentInstance());
+ }
+
+ public static String getParameter(String key, FacesContext facesContext)
+ {
+ Map pmap = facesContext.getExternalContext().getRequestParameterMap();
+ return (String)pmap.get(key);
+ }
+
+ public Map<String, Object> getSessionMap()
+ {
+ return JSFBeanContext.getSessionMap(FacesContext.getCurrentInstance());
+ }
+
+ public static Map<String, Object> getSessionMap(FacesContext facesContext)
+ {
+ return facesContext.getExternalContext().getSessionMap();
+ }
+
+ protected void createMessage(String target, String message, Object severity)
+ {
+ outputMessage(target, message, severity);
+ }
+
+ public static void outputMessage(String target, String message, Object severity)
+ {
+ if (ParameterValidation.isNullOrEmpty(target))
+ {
+ target = STATUS;
+ }
+
+ FacesMessage.Severity jsfSeverity;
+ if (severity instanceof FacesMessage.Severity)
+ {
+ jsfSeverity = (FacesMessage.Severity)severity;
+ }
+ else
+ {
+ jsfSeverity = FacesMessage.SEVERITY_ERROR;
+ }
+
+ // Get the component id from the target
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ UIComponent component = viewRoot.findComponent(target);
+ if (component != null)
+ {
+ target = component.getClientId(facesContext);
+ }
+ else
+ {
+ // todo: do something better here
+ log.info("Couldn't resolve component target: " + target);
+ }
+
+ FacesMessage msg = new FacesMessage(jsfSeverity, message, message);
+ facesContext.addMessage(target, msg);
+ }
+
+ public static void outputLocalizedMessage(String target, String localizationKey,
Object severity, String resourceName, Object... params)
+ {
+ if(severity == null)
+ {
+ severity = FacesMessage.SEVERITY_ERROR;
+ }
+
+ outputMessage(target, getLocalizedMessage(localizationKey, getRequestLocale(),
resourceName, params), severity);
+ }
+
+ protected Object getErrorSeverity()
+ {
+ return FacesMessage.SEVERITY_ERROR;
+ }
+
+ protected Object getInfoSeverity()
+ {
+ return FacesMessage.SEVERITY_INFO;
+ }
+
+ protected Locale getLocale()
+ {
+ return getRequestLocale();
+ }
+
+ public static Locale getRequestLocale()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/ManagedBean.java
===================================================================
--- modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/ManagedBean.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/gui/ManagedBean.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,240 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.faces.gui;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.util.ParameterValidation;
+
+import java.util.regex.Pattern;
+
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision: 13413 $
+ * @since 2.6
+ */
+public abstract class ManagedBean
+{
+ protected Logger log = Logger.getLogger(getClass());
+
+ protected BeanContext beanContext;
+ public static final String INVALID_NAME = "INVALID_NAME_ERROR";
+ public static final String INVALID_PATH = "INVALID_PATH_ERROR";
+ public static final String DUPLICATE = "DUPLICATE_ERROR";
+
+ public static interface PropertyValidator
+ {
+ boolean checkForDuplicates();
+
+ String getObjectTypeName();
+
+ boolean isAlreadyExisting(String propertyName);
+
+ String doSimpleChecks(String name);
+
+ ParameterValidation.ValidationErrorHandler getValidationErrorHandler(String name,
String targetForErrorMessage);
+
+ Pattern getValidationPattern();
+ }
+
+ private PropertyValidator validator = new DefaultPropertyValidator();
+
+ protected void setValidator(PropertyValidator validator)
+ {
+ this.validator = validator;
+ }
+
+ public void setBeanContext(BeanContext beanContext)
+ {
+ this.beanContext = beanContext;
+ }
+
+ public String checkNameValidity(String name, String targetForErrorMessage)
+ {
+ return checkNameValidity(name, targetForErrorMessage, validator);
+ }
+
+ public String checkNameValidity(String name, String targetForErrorMessage,
PropertyValidator validator)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(validator,
"PropertyValidator");
+
+ String objectTypeName = validator.getObjectTypeName();
+ if (ParameterValidation.isNullOrEmpty(name))
+ {
+ beanContext.createTargetedErrorMessage(targetForErrorMessage, INVALID_NAME,
name, getLocalizedType(objectTypeName));
+ return null;
+ }
+ else
+ {
+ String original = name;
+ name = validator.doSimpleChecks(name);
+
+ // we got an invalid name after simple checks, fail!
+ if (name == null)
+ {
+ beanContext.createTargetedErrorMessage(targetForErrorMessage, INVALID_NAME,
original, getLocalizedType(objectTypeName));
+ return null;
+ }
+
+ // Trim name
+ name = name.trim();
+
+ // "sanitize" name: if it's invalid, return null and output
message
+ name = ParameterValidation.sanitizeFromPatternWithHandler(name,
validator.getValidationPattern(),
+ validator.getValidationErrorHandler(name, targetForErrorMessage));
+
+ // we got an invalid name, fail!
+ if (name == null)
+ {
+ return null;
+ }
+
+ // Check for duplicate
+ if (validator.checkForDuplicates() &&
validator.isAlreadyExisting(name))
+ {
+ getDuplicateErrorMessage(name, targetForErrorMessage, objectTypeName);
+ return null;
+ }
+
+ return name;
+ }
+ }
+
+ protected void getDuplicateErrorMessage(String name, String targetForErrorMessage,
String objectTypeName)
+ {
+ beanContext.createTargetedErrorMessage(targetForErrorMessage, DUPLICATE, name,
getLocalizedType(objectTypeName));
+ }
+
+ private String getLocalizedType(String objectTypeName)
+ {
+ return beanContext.getMessageFromBundle(objectTypeName);
+ }
+
+ protected abstract String getObjectTypeName();
+
+ public abstract boolean isAlreadyExisting(String objectName);
+
+ /**
+ * @param oldValue
+ * @param newValue
+ * @return
+ * @todo public for test cases
+ */
+ public boolean isOldAndNewDifferent(Object oldValue, Object newValue)
+ {
+ oldValue = normalizeStringIfNeeded(oldValue);
+ newValue = normalizeStringIfNeeded(newValue);
+
+ return (oldValue != null && !oldValue.equals(newValue)) || (oldValue ==
null && newValue != null);
+ }
+
+ /**
+ * Normalizes String by considering empty String as null as JSF would give either and
trim non-null Strings.
+ *
+ * @param value
+ * @return
+ * @todo public for test cases
+ */
+ public Object normalizeStringIfNeeded(Object value)
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ else
+ {
+ if (value instanceof String)
+ {
+ String stringValue = (String)value;
+ return stringValue.length() == 0 ? null : stringValue.trim();
+ }
+ else
+ {
+ return value;
+ }
+ }
+ }
+
+ protected class MessageValidationHandler extends
ParameterValidation.ValidationErrorHandler
+ {
+ private String targetForErrorMessage;
+ private String validatedName;
+ private String objectTypeName;
+ private String errorMessageKey;
+
+ public MessageValidationHandler(String defaultValue, String targetForErrorMessage,
String validatedName, String objectTypeName)
+ {
+ this(defaultValue, targetForErrorMessage, validatedName, objectTypeName,
INVALID_NAME);
+ }
+
+ public MessageValidationHandler(String defaultValue, String targetForErrorMessage,
String validatedName, String objectTypeName, String errorMessageKey)
+ {
+ super(defaultValue);
+ this.targetForErrorMessage = targetForErrorMessage;
+ this.validatedName = validatedName;
+ this.objectTypeName = objectTypeName;
+ this.errorMessageKey = errorMessageKey;
+ }
+
+ protected String internalValidationErrorHandling(String s)
+ {
+ beanContext.createTargetedErrorMessage(targetForErrorMessage, errorMessageKey,
validatedName, getLocalizedType(objectTypeName));
+ return null;
+ }
+ }
+
+ protected class DefaultPropertyValidator implements PropertyValidator
+ {
+ public boolean checkForDuplicates()
+ {
+ return true;
+ }
+
+ public String getObjectTypeName()
+ {
+ return ManagedBean.this.getObjectTypeName();
+ }
+
+ public boolean isAlreadyExisting(String propertyName)
+ {
+ return ManagedBean.this.isAlreadyExisting(propertyName);
+ }
+
+ public String doSimpleChecks(String name)
+ {
+ // if name contains . or /, it's invalid for a Portal object
+ return (name.indexOf('.') != -1 || name.indexOf('/') != -1) ?
null : name;
+ }
+
+ public ParameterValidation.ValidationErrorHandler getValidationErrorHandler(String
name, String targetForErrorMessage)
+ {
+ return new MessageValidationHandler(null, targetForErrorMessage, name,
getObjectTypeName());
+ }
+
+ public Pattern getValidationPattern()
+ {
+ return ParameterValidation.XSS_CHECK;
+ }
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesClassLoader.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesClassLoader.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesClassLoader.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.loader;
+
+import org.apache.log4j.Logger;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class FacesClassLoader extends URLClassLoader
+{
+
+ /** . */
+ private final Logger log = Logger.getLogger(FacesClassLoader.class);
+
+ public FacesClassLoader(URL[] urls, ClassLoader classLoader)
+ {
+ super(urls, classLoader);
+ }
+
+ private final Map cache = new HashMap();
+
+ protected synchronized Class loadClass(String name, boolean resolve) throws
ClassNotFoundException
+ {
+ if (name.startsWith("javax.faces") ||
name.startsWith("org.apache.myfaces"))
+ {
+ log.debug("Want to load " + name + " locally");
+ return locateClass(name);
+ }
+
+ //
+ try
+ {
+ log.debug("Want to load " + name + " will delegate");
+ return super.loadClass(name, resolve);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.debug("Not found in the parent will try to load " + name + "
locally");
+ return locateClass(name);
+ }
+ }
+
+ private Class locateClass(String name) throws ClassNotFoundException
+ {
+ //
+ Class clazz = (Class)cache.get(name);
+
+ //
+ if (clazz == null)
+ {
+ clazz = findClass(name);
+ cache.put(name, clazz);
+ }
+
+ //
+ return clazz;
+ }
+
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesLoaderServlet.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesLoaderServlet.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesLoaderServlet.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,195 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.loader;
+
+import org.apache.log4j.Logger;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class FacesLoaderServlet extends HttpServlet
+{
+
+ /** . */
+ private final static Logger log = Logger.getLogger(FacesLoaderServlet.class);
+
+ /** . */
+ private final String servletContextListenerClassName =
"org.apache.myfaces.webapp.StartupServletContextListener";
+
+ /** . */
+ private FacesClassLoader loader;
+
+ /** . */
+ private ServletContextListener listener;
+
+ /** . */
+ private Servlet servlet;
+
+ public void init() throws ServletException
+ {
+ try
+ {
+ ServletContext ctx = getServletConfig().getServletContext();
+
+ ArrayList tmp = new ArrayList();
+ File f = new File(ctx.getRealPath("/WEB-INF/lib2/"));
+ File[] libs = f.listFiles();
+ for (int i = 0; i < libs.length; i++)
+ {
+ File lib = libs[i];
+ URL libURL = lib.toURL();
+ log.debug("Added " + libURL + " to faces class loader");
+ tmp.add(libURL);
+ }
+ URL[] urls = (URL[])tmp.toArray(new URL[tmp.size()]);
+
+ //
+ loader = new FacesClassLoader(urls,
Thread.currentThread().getContextClassLoader());
+ }
+ catch (Exception e)
+ {
+ throw new ServletException("Cannot find WEB-INF/lib2 directory to load
libraries from", e);
+ }
+
+ //
+ if (loader != null)
+ {
+
getServletConfig().getServletContext().setAttribute("FACESCLASSLOADER",
loader);
+ ClassLoader containerLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(loader);
+
+ //
+ try
+ {
+ // Perform myfaces bootstrap
+ initMyFaces();
+
+ //
+ initFacesServlet();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(containerLoader);
+ }
+ }
+ }
+
+ public void destroy()
+ {
+ if (loader != null)
+ {
+ ClassLoader containerLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(loader);
+
+ //
+ try
+ {
+ //
+ destroyFacesServlet();
+
+ //
+ destroyMyFaces();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(containerLoader);
+ }
+ }
+ }
+
+
+ private void initFacesServlet()
+ {
+ try
+ {
+ Class facesServletClass =
loader.loadClass("javax.faces.webapp.FacesServlet");
+ servlet = (Servlet)facesServletClass.newInstance();
+ servlet.init(getServletConfig());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ private void destroyFacesServlet()
+ {
+ if (servlet != null)
+ {
+ servlet.destroy();
+ }
+ }
+
+ private void initMyFaces()
+ {
+ try
+ {
+ Class bridgeClass =
Thread.currentThread().getContextClassLoader().loadClass(servletContextListenerClassName);
+ log.debug("Obtain bridge bootstrap class " + bridgeClass.getName());
+ listener = (ServletContextListener)bridgeClass.newInstance();
+ }
+ catch (ClassNotFoundException e)
+ {
+ // It is not an error, this happens when we run with Sun RI
+ log.debug("Bridge bootstrap not available " +
servletContextListenerClassName, e);
+ }
+ catch (IllegalAccessException e)
+ {
+ log.error("Bridge bootstrap not accessible " +
servletContextListenerClassName, e);
+ }
+ catch (InstantiationException e)
+ {
+ log.error("Bridge bootstrap not instantiable " +
servletContextListenerClassName, e);
+ }
+
+ //
+ if (listener != null)
+ {
+ log.debug("About to initialize the bridge bootstrap");
+ ServletContextEvent event = new
ServletContextEvent(getServletConfig().getServletContext());
+ listener.contextInitialized(event);
+ }
+ }
+
+ private void destroyMyFaces()
+ {
+ if (listener != null)
+ {
+ log.debug("About to destroy the bridge bootstrap");
+ ServletContextEvent event = new
ServletContextEvent(getServletConfig().getServletContext());
+ listener.contextDestroyed(event);
+ }
+ }
+
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesPortlet.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesPortlet.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/loader/FacesPortlet.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.loader;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.Portlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class FacesPortlet implements Portlet
+{
+
+ /** . */
+ private Portlet portlet;
+
+ /** . */
+ private ClassLoader loader;
+
+ public void init(PortletConfig config) throws PortletException
+ {
+ try
+ {
+ loader =
(ClassLoader)config.getPortletContext().getAttribute("FACESCLASSLOADER");
+ if (loader != null)
+ {
+ ClassLoader containerLoader =
Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(loader);
+ try
+ {
+ Class facesServletClass =
loader.loadClass("org.apache.myfaces.portlet.MyFacesGenericPortlet");
+ portlet = (Portlet)facesServletClass.newInstance();
+ portlet.init(config);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(containerLoader);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void processAction(ActionRequest request, ActionResponse response) throws
PortletException, PortletSecurityException, IOException
+ {
+ if (portlet != null)
+ {
+ ClassLoader containerLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(loader);
+ try
+ {
+ portlet.processAction(request, response);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(containerLoader);
+ }
+ }
+ }
+
+ public void render(RenderRequest request, RenderResponse response) throws
PortletException, PortletSecurityException, IOException
+ {
+ if (portlet != null)
+ {
+ ClassLoader containerLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(loader);
+ try
+ {
+ portlet.render(request, response);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(containerLoader);
+ }
+ }
+ }
+
+ public void destroy()
+ {
+ if (portlet != null)
+ {
+ portlet.destroy();
+ portlet = null;
+ loader = null;
+ }
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/util/ActionEventDispatcher.java
===================================================================
---
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/util/ActionEventDispatcher.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/util/ActionEventDispatcher.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,109 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.faces.util;
+
+import org.apache.log4j.Logger;
+
+import javax.faces.component.UICommand;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+/**
+ * The purpose of this class is to dispatch an event to the action listeners attached to
an instance of
+ * <code>UICommand</code> object. It will iterate the set of listeners
returned by the method
+ * <code>UICommand.getActionListeners()</code> (SunRI) and the listener
evaluated by the method binding returned by the
+ * method <code>getActionListener()</code> (MyFaces). So overally we try to
encapsulate the delivery of an action event
+ * in a portable way accross JSF implementations.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class ActionEventDispatcher
+{
+
+ /** . */
+ private static final ActionListener[] EMPTY_LISTENERS = new ActionListener[0];
+
+ /** . */
+ private static final Logger log = Logger.getLogger(ActionEventDispatcher.class);
+
+ /** . */
+ private final UICommand command;
+
+ public ActionEventDispatcher(UICommand command)
+ {
+ this.command = command;
+ }
+
+ public void dispatch(final FacesContext faces, final ActionEvent event) throws
AbortProcessingException
+ {
+ //
+ ArrayList listeners = new ArrayList();
+
+ if (command.getActionListeners() != null)
+ {
+ listeners.addAll(Arrays.asList(command.getActionListeners()));
+ }
+
+ //
+ if (command.getActionListener() != null)
+ {
+ ActionListener listener = new ActionListener()
+ {
+ public void processAction(ActionEvent actionEvent) throws
AbortProcessingException
+ {
+ try
+ {
+ command.getActionListener().invoke(faces, new Object[]{event});
+ }
+ catch (EvaluationException e)
+ {
+ Throwable cause = e.getCause();
+ if (cause != null && cause instanceof
AbortProcessingException)
+ {
+ throw (AbortProcessingException)cause;
+ }
+ else
+ {
+ log.error("Was not able to evaluate the method binding",
e);
+ }
+ }
+ }
+ };
+ listeners.add(listener);
+ }
+
+ //
+ for (Iterator i = listeners.iterator(); i.hasNext();)
+ {
+ ActionListener listener = (ActionListener)i.next();
+ listener.processAction(event);
+ }
+ }
+}
Added:
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/util/JSFFunctor.java
===================================================================
--- modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/util/JSFFunctor.java
(rev 0)
+++
modules/faces/trunk/faces/src/main/java/org/jboss/portal/faces/util/JSFFunctor.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,126 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This 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 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.faces.util;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Allows to call a parameterized function in JSF EL expressions. See <a
href="http://wiki.apache.org/myfaces/Parameters_In_EL_Functions"...
+ * for more details. A better alternative would be to use JBoss-EL if it was available
from the standard JBoss
+ * repository...
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public abstract class JSFFunctor implements Map<String, Object>
+{
+
+ /** Removes white spaces and periods from identifiers so that we can assign them to
HTML id attributes. */
+ public static final JSFFunctor ID_SANITIZER = new JSFFunctor()
+ {
+ private String recent;
+ private String recentSanitized;
+
+ @Override
+ public Object get(Object parameter)
+ {
+ if (parameter instanceof String)
+ {
+ if (parameter.equals(recent))
+ {
+ return recentSanitized;
+ }
+
+ String id = (String)parameter;
+ recent = id;
+ recentSanitized = id.replace(' ', '_').replace('.',
'_');
+ return recentSanitized;
+ }
+ return null;
+ }
+ };
+
+ public int size()
+ {
+ return 0;
+ }
+
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
+ public boolean containsKey(Object key)
+ {
+ return false;
+ }
+
+ public boolean containsValue(Object value)
+ {
+ return false;
+ }
+
+ /**
+ * This is where the functor works. Subclasses need to implement the function logic
here, the parameter being the
+ * specified parameter.
+ *
+ * @param parameter the value that will be used to compute the result of the function
we want to implement
+ * @return the result of the funtion for the specified value
+ */
+ public abstract Object get(Object parameter);
+
+ public Object put(String key, Object value)
+ {
+ return null;
+ }
+
+ public Object remove(Object key)
+ {
+ return null;
+ }
+
+ public void putAll(Map<? extends String, ? extends Object> m)
+ {
+ }
+
+ public void clear()
+ {
+ }
+
+ public Set<String> keySet()
+ {
+ return null;
+ }
+
+ public Collection<Object> values()
+ {
+ return null;
+ }
+
+ public Set<Entry<String, Object>> entrySet()
+ {
+ return null;
+ }
+}
Added:
modules/faces/trunk/faces/src/main/resources/portal-faces-lib-jar/META-INF/portal.taglib.xml
===================================================================
---
modules/faces/trunk/faces/src/main/resources/portal-faces-lib-jar/META-INF/portal.taglib.xml
(rev 0)
+++
modules/faces/trunk/faces/src/main/resources/portal-faces-lib-jar/META-INF/portal.taglib.xml 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,11 @@
+<!DOCTYPE facelet-taglib PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
+ "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
+<facelet-taglib>
+ <
namespace>http://www.jboss.com/portal/facelet/common</namespace>
+ <tag>
+ <tag-name>context</tag-name>
+
<handler-class>org.jboss.portal.faces.facelet.ContextTagHandler</handler-class>
+ </tag>
+
+</facelet-taglib>
\ No newline at end of file
Added:
modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/faces-config.xml
===================================================================
---
modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/faces-config.xml
(rev 0)
+++
modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/faces-config.xml 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,46 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This 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 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE faces-config PUBLIC
+ "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+<faces-config>
+ <component>
+ <component-type>custom1</component-type>
+
<component-class>org.jboss.portal.test.faces.example.UICustom1</component-class>
+ </component>
+ <component>
+ <component-type>custom2</component-type>
+
<component-class>org.jboss.portal.test.faces.example.UICustom2</component-class>
+ </component>
+ <component>
+ <component-type>custom3</component-type>
+
<component-class>org.jboss.portal.test.faces.example.UICustom3</component-class>
+ </component>
+ <managed-bean>
+ <managed-bean-name>custombean</managed-bean-name>
+
<managed-bean-class>org.jboss.portal.test.faces.example.CustomBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+</faces-config>
Property changes on:
modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/faces-config.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/web.xml
===================================================================
--- modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/web.xml
(rev 0)
+++
modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/web.xml 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This 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 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software 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 ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<web-app version="2.4"
+
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <listener>
+
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
+ </listener>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>client</param-value>
+ </context-param>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+</web-app>
Property changes on:
modules/faces/trunk/faces/src/main/resources/portal-faces-war/WEB-INF/web.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: modules/faces/trunk/faces/src/main/resources/portal-faces-war/index.jsp
===================================================================
--- modules/faces/trunk/faces/src/main/resources/portal-faces-war/index.jsp
(rev 0)
+++ modules/faces/trunk/faces/src/main/resources/portal-faces-war/index.jsp 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,31 @@
+<%@ page contentType="text/html;charset=UTF-8" language="java"
%>
+<%@ taglib prefix="h"
uri="http://java.sun.com/jsf/html" %>
+<%@ taglib prefix="f"
uri="http://java.sun.com/jsf/core" %>
+<%@ taglib prefix="j"
uri="http://www.jboss.org/jsf/component/tags" %>
+<html>
+<head><title>Samples</title></head>
+
+<body>
+<f:view>
+ <h:form>
+ <j:composite
+ type="custom1"
+ data_value="#{custombean.rows}"/>
+ <j:composite
+ type="custom2"
+ input_value="#{custombean.in}"
+ output_value="#{custombean.out}"
+ listener="#{custombean.action}"/>
+ </h:form>
+ <h:form>
+ <j:composite
+ id="abc"
+ type="custom3"
+ data_value="#{custombean.rows}"
+ input_value="#{custombean.in}"
+ output_value="#{custombean.out}"
+ listener="#{custombean.action}"/>
+ </h:form>
+</f:view>
+</body>
+</html>
\ No newline at end of file
Property changes on:
modules/faces/trunk/faces/src/main/resources/portal-faces-war/index.jsp
___________________________________________________________________
Name: svn:executable
+ *
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/ManagedBeanTestCase.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/ManagedBeanTestCase.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/ManagedBeanTestCase.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.test.faces;
+
+import junit.framework.TestCase;
+import org.jboss.portal.faces.gui.ManagedBean;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ManagedBeanTestCase extends TestCase
+{
+ private ManagedBean bean;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ bean = new ManagedBean()
+ {
+ @Override
+ protected String getObjectTypeName()
+ {
+ return "test";
+ }
+
+ @Override
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return false;
+ }
+ };
+ }
+
+ public void testNormalizeStringIfNeeded()
+ {
+ assertEquals("foo", bean.normalizeStringIfNeeded("foo"));
+ assertEquals("foo", bean.normalizeStringIfNeeded(" foo "));
+ assertEquals("foo",
bean.normalizeStringIfNeeded("\t\nfoo\t"));
+ assertNull(bean.normalizeStringIfNeeded(null));
+ assertEquals(bean, bean.normalizeStringIfNeeded(bean));
+ }
+
+ public void testIsOldAndNewDifferent()
+ {
+ assertTrue(bean.isOldAndNewDifferent("foo", null));
+ assertTrue(bean.isOldAndNewDifferent(null, "foo"));
+ assertFalse(bean.isOldAndNewDifferent(null, null));
+ }
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/MessageFormatTestCase.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/MessageFormatTestCase.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/MessageFormatTestCase.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,51 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This 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 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.test.faces;
+
+import junit.framework.TestCase;
+
+import java.text.MessageFormat;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class MessageFormatTestCase extends TestCase
+{
+ public void testFormat()
+ {
+ String input = "''{0}'' is not a valid URL: {1}";
+ String output = "'foo' is not a valid URL: bar";
+ assertEquals(output, MessageFormat.format(input, new String[] {"foo",
"bar"}));
+
+
+ // Don't forget to escape single quotes in localization files if there are
parameters to be interpreted
+ input = "Couldn't reload producer configuration. Cause: {0}";
+ output = "Couldnt reload producer configuration. Cause: {0}";
+ assertEquals(output, MessageFormat.format(input, new String[]{"foo"}));
+
+ input = "Couldn''t reload producer configuration. Cause: {0}";
+ output = "Couldn't reload producer configuration. Cause: foo";
+ assertEquals(output, MessageFormat.format(input, new String[]{"foo"}));
+ }
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/AbstractBeanDecoratorTestCase.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,132 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+import junit.framework.TestCase;
+import org.jboss.portal.faces.el.PropertyValue;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class AbstractBeanDecoratorTestCase extends TestCase
+{
+
+ /** . */
+ private TestBean testBean;
+
+ /** . */
+ private TestBeanDecorator testBeanDecorator;
+
+ protected void setUp() throws Exception
+ {
+ testBean = new TestBean();
+ testBeanDecorator = new TestBeanDecorator(testBean.property);
+ }
+
+
+ protected void tearDown() throws Exception
+ {
+ testBean = null;
+ testBeanDecorator = null;
+ }
+
+ public void testGetType()
+ {
+ try
+ {
+ testBeanDecorator.getType(null, testBeanDecorator.property.name);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ try
+ {
+ testBeanDecorator.getType(testBean, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ assertEquals(Value.class, testBeanDecorator.getType(testBean,
testBeanDecorator.property.name));
+ }
+
+ public void testGetValue()
+ {
+ try
+ {
+ testBeanDecorator.getValue(testBean, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ try
+ {
+ testBeanDecorator.getValue(null, testBeanDecorator.property.name);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ assertEquals(null, testBeanDecorator.getValue(testBean, new Object()));
+ assertEquals(new PropertyValue(testBean.property.value),
testBeanDecorator.getValue(testBean, testBeanDecorator.property.name));
+ }
+
+ public void testSetValue()
+ {
+ try
+ {
+ testBeanDecorator.setValue(null, testBeanDecorator.property.name, new
Object());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ try
+ {
+ testBeanDecorator.setValue(testBean, null, new Object());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ Value expectedValue = new Value();
+ assertEquals(true, testBeanDecorator.setValue(testBean,
testBeanDecorator.property.name, expectedValue));
+ assertEquals(expectedValue, testBean.property.value);
+
+ //
+ assertEquals(true, testBeanDecorator.setValue(testBean,
testBeanDecorator.property.name, null));
+ assertEquals(null, testBean.property.value);
+ }
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/AbstractDynamicBeanTestCase.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/AbstractDynamicBeanTestCase.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/AbstractDynamicBeanTestCase.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,100 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+import junit.framework.TestCase;
+import org.jboss.portal.faces.el.PropertyValue;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class AbstractDynamicBeanTestCase extends TestCase
+{
+
+ /** . */
+ private TestDynamicBean testDynamicBean;
+
+ protected void setUp() throws Exception
+ {
+ testDynamicBean = new TestDynamicBean();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ testDynamicBean = null;
+ }
+
+ public void testGetType()
+ {
+ try
+ {
+ testDynamicBean.getType(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ assertEquals(null, testDynamicBean.getType(new Object()));
+ assertEquals(Value.class, testDynamicBean.getType(testDynamicBean.propertyName));
+ }
+
+ public void testGetValue()
+ {
+ try
+ {
+ testDynamicBean.getValue(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ assertEquals(null, testDynamicBean.getValue(new Object()));
+ assertEquals(new PropertyValue(testDynamicBean.propertyValue),
testDynamicBean.getValue(testDynamicBean.propertyName));
+ }
+
+ public void testSetValue()
+ {
+ try
+ {
+ testDynamicBean.setValue(null, new Object());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ Value expectedValue = new Value();
+ assertFalse(testDynamicBean.setValue(new Object(), new Object()));
+ assertTrue(testDynamicBean.setValue(testDynamicBean.propertyName, expectedValue));
+ assertEquals(expectedValue, testDynamicBean.propertyValue);
+ assertTrue(testDynamicBean.setValue(testDynamicBean.propertyName, null));
+ assertEquals(null, testDynamicBean.propertyValue);
+ }
+
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant1.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant1.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant1.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class ClassConstant1
+{
+
+ private String PRIVATE_1;
+ private final String PRIVATE_FINAL_1 = "";
+ protected String PROTECTED_1;
+ protected final String PROTECTED_FINAL_1 = "";
+ String PACKAGE_PROTECTED_1;
+ final String PACKAGE_PROTECTED_FINAL_1 = "";
+ public String PUBLIC_1;
+ public final String PUBLIC_FINAL_1 = "";
+
+ static private String STATIC_PRIVATE_1;
+ static private final String STATIC_PRIVATE_FINAL_1 = "";
+ static protected String STATIC_PROTECTED_1;
+ static protected final String STATIC_PROTECTED_FINAL_1 = "";
+ static String STATIC_PACKAGE_PROTECTED_1;
+ static final String STATIC_PACKAGE_PROTECTED_FINAL_1 = "";
+ static public String STATIC_PUBLIC_1 = "CT1_STATIC_PUBLIC_1_VALUE";
+ static public final String STATIC_PUBLIC_FINAL_1 =
"CT1_STATIC_PUBLIC_FINAL_1_VALUE";
+
+ private String PRIVATE_2;
+ private final String PRIVATE_FINAL_2 = "";
+ protected String PROTECTED_2;
+ protected final String PROTECTED_FINAL_2 = "";
+ String PACKAGE_PROTECTED_2;
+ final String PACKAGE_PROTECTED_FINAL_2 = "";
+ public String PUBLIC_2;
+ public final String PUBLIC_FINAL_2 = "";
+
+ static private String STATIC_PRIVATE_2;
+ static private final String STATIC_PRIVATE_FINAL_2 = "";
+ static protected String STATIC_PROTECTED_2;
+ static protected final String STATIC_PROTECTED_FINAL_2 = "";
+ static String STATIC_PACKAGE_PROTECTED_2;
+ static final String STATIC_PACKAGE_PROTECTED_FINAL_2 = "";
+ static public String STATIC_PUBLIC_2 = "CT1_STATIC_PUBLIC_2_VALUE";
+ static public final String STATIC_PUBLIC_FINAL_2 =
"CT1_STATIC_PUBLIC_FINAL_2_VALUE";
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant2.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant2.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant2.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class ClassConstant2 extends ClassConstant1
+{
+
+ private String PRIVATE_2;
+ private final String PRIVATE_FINAL_2 = "";
+ protected String PROTECTED_2;
+ protected final String PROTECTED_FINAL_2 = "";
+ String PACKAGE_PROTECTED_2;
+ final String PACKAGE_PROTECTED_FINAL_2 = "";
+ public String PUBLIC_2;
+ public final String PUBLIC_FINAL_2 = "";
+
+ static private String STATIC_PRIVATE_2;
+ static private final String STATIC_PRIVATE_FINAL_2 = "";
+ static protected String STATIC_PROTECTED_2;
+ static protected final String STATIC_PROTECTED_FINAL_2 = "";
+ static String STATIC_PACKAGE_PROTECTED_2;
+ static final String STATIC_PACKAGE_PROTECTED_FINAL_2 = "";
+ static public String STATIC_PUBLIC_2 = "CT2_STATIC_PUBLIC_2_VALUE";
+ static public final String STATIC_PUBLIC_FINAL_2 =
"CT2_STATIC_PUBLIC_FINAL_2_VALUE";
+
+ private String PRIVATE_3;
+ private final String PRIVATE_FINAL_3 = "";
+ protected String PROTECTED_3;
+ protected final String PROTECTED_FINAL_3 = "";
+ String PACKAGE_PROTECTED_3;
+ final String PACKAGE_PROTECTED_FINAL_3 = "";
+ public String PUBLIC_3;
+ public final String PUBLIC_FINAL_3 = "";
+
+ static private String STATIC_PRIVATE_3;
+ static private final String STATIC_PRIVATE_FINAL_3 = "";
+ static protected String STATIC_PROTECTED_3;
+ static protected final String STATIC_PROTECTED_FINAL_3 = "";
+ static String STATIC_PACKAGE_PROTECTED_3;
+ static final String STATIC_PACKAGE_PROTECTED_FINAL_3 = "";
+ static public String STATIC_PUBLIC_3 = "CT2_STATIC_PUBLIC_3_VALUE";
+ static public final String STATIC_PUBLIC_FINAL_3 =
"CT2_STATIC_PUBLIC_FINAL_3_VALUE";
+
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant3.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant3.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstant3.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class ClassConstant3
+{
+ public static final int INT_0 = 0;
+ public static final int INT_1 = 1;
+ public static final int INT_2 = 2;
+ public static final boolean BOOLEAN_TRUE = true;
+ public static final boolean BOOLEAN_FALSE = false;
+ public static final Integer INTEGER_0 = new Integer(0);
+ public static final Integer INTEGER_1 = new Integer(1);
+ public static final Integer INTEGER_2 = new Integer(2);
+ public static final Boolean BOOLEAN_OBJECT_TRUE = Boolean.TRUE;
+ public static final Boolean BOOLEAN_OBJECT_FALSE = Boolean.FALSE;
+ public static final Object OBJECT = new Object();
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstantPublisherBeanTestCase.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstantPublisherBeanTestCase.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/ClassConstantPublisherBeanTestCase.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,387 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+import junit.framework.TestCase;
+import org.jboss.portal.faces.el.ClassConstantPublisherBean;
+import org.jboss.portal.faces.el.dynamic.DynamicBean;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class ClassConstantPublisherBeanTestCase extends TestCase
+{
+
+ private DynamicBean bean1;
+ private DynamicBean bean2;
+ private DynamicBean bean3;
+
+ protected void setUp() throws Exception
+ {
+ bean1 = new ClassConstantPublisherBean();
+ bean1.setValue("className", ClassConstant1.class.getName());
+ bean2 = new ClassConstantPublisherBean();
+ bean2.setValue("className", ClassConstant2.class.getName());
+ bean3 = new ClassConstantPublisherBean();
+ bean3.setValue("className", ClassConstant3.class.getName());
+ }
+
+ public void testMeta()
+ {
+ assertEquals(String.class, bean1.getType("className"));
+ assertNotNull(bean1.getValue("className"));
+ assertEquals(ClassConstant1.class.getName(),
bean1.getValue("className").getObject());
+ }
+
+ public void testExtendsObject()
+ {
+ assertNull(bean1.getType("PRIVATE_1"));
+ assertNull(bean1.getType("PRIVATE_FINAL_1"));
+ assertNull(bean1.getType("PROTECTED_1"));
+ assertNull(bean1.getType("PROTECTED_FINAL_1"));
+ assertNull(bean1.getType("PACKAGE_PROTECTED_1"));
+ assertNull(bean1.getType("PACKAGE_PROTECTED_FINAL_1"));
+ assertNull(bean1.getType("PUBLIC_1"));
+ assertNull(bean1.getType("PUBLIC_FINAL_1"));
+
+ //
+ assertNull(bean1.getType("STATIC_PRIVATE_1"));
+ assertNull(bean1.getType("STATIC_PRIVATE_FINAL_1"));
+ assertNull(bean1.getType("STATIC_PROTECTED_1"));
+ assertNull(bean1.getType("STATIC_PROTECTED_FINAL_1"));
+ assertNull(bean1.getType("STATIC_PACKAGE_PROTECTED_1"));
+ assertNull(bean1.getType("STATIC_PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean1.getType("STATIC_PUBLIC_1"));
+ assertNotNull(bean1.getType("STATIC_PUBLIC_FINAL_1"));
+
+ //
+ assertNotNull(bean1.getValue("PRIVATE_1"));
+ assertNotNull(bean1.getValue("PRIVATE_FINAL_1"));
+ assertNotNull(bean1.getValue("PROTECTED_1"));
+ assertNotNull(bean1.getValue("PROTECTED_FINAL_1"));
+ assertNotNull(bean1.getValue("PACKAGE_PROTECTED_1"));
+ assertNotNull(bean1.getValue("PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean1.getValue("PUBLIC_1"));
+ assertNotNull(bean1.getValue("PUBLIC_FINAL_1"));
+
+ //
+ assertNotNull(bean1.getValue("STATIC_PRIVATE_1"));
+ assertNotNull(bean1.getValue("STATIC_PRIVATE_FINAL_1"));
+ assertNotNull(bean1.getValue("STATIC_PROTECTED_1"));
+ assertNotNull(bean1.getValue("STATIC_PROTECTED_FINAL_1"));
+ assertNotNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_1"));
+ assertNotNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean1.getValue("STATIC_PUBLIC_1"));
+ assertNotNull(bean1.getValue("STATIC_PUBLIC_FINAL_1"));
+
+ //
+ assertNull(bean1.getValue("PRIVATE_1").getObject());
+ assertNull(bean1.getValue("PRIVATE_FINAL_1").getObject());
+ assertNull(bean1.getValue("PROTECTED_1").getObject());
+ assertNull(bean1.getValue("PROTECTED_FINAL_1").getObject());
+ assertNull(bean1.getValue("PACKAGE_PROTECTED_1").getObject());
+ assertNull(bean1.getValue("PACKAGE_PROTECTED_FINAL_1").getObject());
+ assertNull(bean1.getValue("PUBLIC_1").getObject());
+ assertNull(bean1.getValue("PUBLIC_FINAL_1").getObject());
+
+ //
+ assertNull(bean1.getValue("STATIC_PRIVATE_1").getObject());
+ assertNull(bean1.getValue("STATIC_PRIVATE_FINAL_1").getObject());
+ assertNull(bean1.getValue("STATIC_PROTECTED_1").getObject());
+ assertNull(bean1.getValue("STATIC_PROTECTED_FINAL_1").getObject());
+ assertNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_1").getObject());
+
assertNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_FINAL_1").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_1_VALUE",
bean1.getValue("STATIC_PUBLIC_1").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_FINAL_1_VALUE",
bean1.getValue("STATIC_PUBLIC_FINAL_1").getObject());
+
+ //
+ assertNull(bean1.getType("PRIVATE_2"));
+ assertNull(bean1.getType("PRIVATE_FINAL_2"));
+ assertNull(bean1.getType("PROTECTED_2"));
+ assertNull(bean1.getType("PROTECTED_FINAL_2"));
+ assertNull(bean1.getType("PACKAGE_PROTECTED_2"));
+ assertNull(bean1.getType("PACKAGE_PROTECTED_FINAL_2"));
+ assertNull(bean1.getType("PUBLIC_2"));
+ assertNull(bean1.getType("PUBLIC_FINAL_2"));
+
+ //
+ assertNull(bean1.getType("STATIC_PRIVATE_2"));
+ assertNull(bean1.getType("STATIC_PRIVATE_FINAL_2"));
+ assertNull(bean1.getType("STATIC_PROTECTED_2"));
+ assertNull(bean1.getType("STATIC_PROTECTED_FINAL_2"));
+ assertNull(bean1.getType("STATIC_PACKAGE_PROTECTED_2"));
+ assertNull(bean1.getType("STATIC_PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean1.getType("STATIC_PUBLIC_2"));
+ assertNotNull(bean1.getType("STATIC_PUBLIC_FINAL_2"));
+
+ //
+ assertNotNull(bean1.getValue("PRIVATE_2"));
+ assertNotNull(bean1.getValue("PRIVATE_FINAL_2"));
+ assertNotNull(bean1.getValue("PROTECTED_2"));
+ assertNotNull(bean1.getValue("PROTECTED_FINAL_2"));
+ assertNotNull(bean1.getValue("PACKAGE_PROTECTED_2"));
+ assertNotNull(bean1.getValue("PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean1.getValue("PUBLIC_2"));
+ assertNotNull(bean1.getValue("PUBLIC_FINAL_2"));
+
+ //
+ assertNotNull(bean1.getValue("STATIC_PRIVATE_2"));
+ assertNotNull(bean1.getValue("STATIC_PRIVATE_FINAL_2"));
+ assertNotNull(bean1.getValue("STATIC_PROTECTED_2"));
+ assertNotNull(bean1.getValue("STATIC_PROTECTED_FINAL_2"));
+ assertNotNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_2"));
+ assertNotNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean1.getValue("STATIC_PUBLIC_2"));
+ assertNotNull(bean1.getValue("STATIC_PUBLIC_FINAL_2"));
+
+ //
+ assertNull(bean1.getValue("PRIVATE_2").getObject());
+ assertNull(bean1.getValue("PRIVATE_FINAL_2").getObject());
+ assertNull(bean1.getValue("PROTECTED_2").getObject());
+ assertNull(bean1.getValue("PROTECTED_FINAL_2").getObject());
+ assertNull(bean1.getValue("PACKAGE_PROTECTED_2").getObject());
+ assertNull(bean1.getValue("PACKAGE_PROTECTED_FINAL_2").getObject());
+ assertNull(bean1.getValue("PUBLIC_2").getObject());
+ assertNull(bean1.getValue("PUBLIC_FINAL_2").getObject());
+
+ //
+ assertNull(bean1.getValue("STATIC_PRIVATE_2").getObject());
+ assertNull(bean1.getValue("STATIC_PRIVATE_FINAL_2").getObject());
+ assertNull(bean1.getValue("STATIC_PROTECTED_2").getObject());
+ assertNull(bean1.getValue("STATIC_PROTECTED_FINAL_2").getObject());
+ assertNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_2").getObject());
+
assertNull(bean1.getValue("STATIC_PACKAGE_PROTECTED_FINAL_2").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_2_VALUE",
bean1.getValue("STATIC_PUBLIC_2").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_FINAL_2_VALUE",
bean1.getValue("STATIC_PUBLIC_FINAL_2").getObject());
+ }
+
+ public void testExtendsObjectAnotherClass()
+ {
+ assertNull(bean2.getType("PRIVATE_1"));
+ assertNull(bean2.getType("PRIVATE_FINAL_1"));
+ assertNull(bean2.getType("PROTECTED_1"));
+ assertNull(bean2.getType("PROTECTED_FINAL_1"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_1"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_FINAL_1"));
+ assertNull(bean2.getType("PUBLIC_1"));
+ assertNull(bean2.getType("PUBLIC_FINAL_1"));
+
+ //
+ assertNull(bean2.getType("STATIC_PRIVATE_1"));
+ assertNull(bean2.getType("STATIC_PRIVATE_FINAL_1"));
+ assertNull(bean2.getType("STATIC_PROTECTED_1"));
+ assertNull(bean2.getType("STATIC_PROTECTED_FINAL_1"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_1"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_1"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_FINAL_1"));
+
+ //
+ assertNotNull(bean2.getValue("PRIVATE_1"));
+ assertNotNull(bean2.getValue("PRIVATE_FINAL_1"));
+ assertNotNull(bean2.getValue("PROTECTED_1"));
+ assertNotNull(bean2.getValue("PROTECTED_FINAL_1"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_1"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean2.getValue("PUBLIC_1"));
+ assertNotNull(bean2.getValue("PUBLIC_FINAL_1"));
+
+ //
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_1"));
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_FINAL_1"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_1"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_FINAL_1"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_1"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_1"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_1"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_FINAL_1"));
+
+ //
+ assertNull(bean2.getValue("PRIVATE_1").getObject());
+ assertNull(bean2.getValue("PRIVATE_FINAL_1").getObject());
+ assertNull(bean2.getValue("PROTECTED_1").getObject());
+ assertNull(bean2.getValue("PROTECTED_FINAL_1").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_1").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_1").getObject());
+ assertNull(bean2.getValue("PUBLIC_1").getObject());
+ assertNull(bean2.getValue("PUBLIC_FINAL_1").getObject());
+
+ //
+ assertNull(bean2.getValue("STATIC_PRIVATE_1").getObject());
+ assertNull(bean2.getValue("STATIC_PRIVATE_FINAL_1").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_1").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_FINAL_1").getObject());
+ assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_1").getObject());
+
assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_1").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_1_VALUE",
bean2.getValue("STATIC_PUBLIC_1").getObject());
+ assertEquals("CT1_STATIC_PUBLIC_FINAL_1_VALUE",
bean2.getValue("STATIC_PUBLIC_FINAL_1").getObject());
+
+ //
+ assertNull(bean2.getType("PRIVATE_2"));
+ assertNull(bean2.getType("PRIVATE_FINAL_2"));
+ assertNull(bean2.getType("PROTECTED_2"));
+ assertNull(bean2.getType("PROTECTED_FINAL_2"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_2"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_FINAL_2"));
+ assertNull(bean2.getType("PUBLIC_2"));
+ assertNull(bean2.getType("PUBLIC_FINAL_2"));
+
+ //
+ assertNull(bean2.getType("STATIC_PRIVATE_2"));
+ assertNull(bean2.getType("STATIC_PRIVATE_FINAL_2"));
+ assertNull(bean2.getType("STATIC_PROTECTED_2"));
+ assertNull(bean2.getType("STATIC_PROTECTED_FINAL_2"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_2"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_2"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_FINAL_2"));
+
+ //
+ assertNotNull(bean2.getValue("PRIVATE_2"));
+ assertNotNull(bean2.getValue("PRIVATE_FINAL_2"));
+ assertNotNull(bean2.getValue("PROTECTED_2"));
+ assertNotNull(bean2.getValue("PROTECTED_FINAL_2"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_2"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean2.getValue("PUBLIC_2"));
+ assertNotNull(bean2.getValue("PUBLIC_FINAL_2"));
+
+ //
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_2"));
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_FINAL_2"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_2"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_FINAL_2"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_2"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_2"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_2"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_FINAL_2"));
+
+ //
+ assertNull(bean2.getValue("PRIVATE_2").getObject());
+ assertNull(bean2.getValue("PRIVATE_FINAL_2").getObject());
+ assertNull(bean2.getValue("PROTECTED_2").getObject());
+ assertNull(bean2.getValue("PROTECTED_FINAL_2").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_2").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_2").getObject());
+ assertNull(bean2.getValue("PUBLIC_2").getObject());
+ assertNull(bean2.getValue("PUBLIC_FINAL_2").getObject());
+
+ //
+ assertNull(bean2.getValue("STATIC_PRIVATE_2").getObject());
+ assertNull(bean2.getValue("STATIC_PRIVATE_FINAL_2").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_2").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_FINAL_2").getObject());
+ assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_2").getObject());
+
assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_2").getObject());
+ assertEquals("CT2_STATIC_PUBLIC_2_VALUE",
bean2.getValue("STATIC_PUBLIC_2").getObject());
+ assertEquals("CT2_STATIC_PUBLIC_FINAL_2_VALUE",
bean2.getValue("STATIC_PUBLIC_FINAL_2").getObject());
+
+ assertNull(bean2.getType("PRIVATE_3"));
+ assertNull(bean2.getType("PRIVATE_FINAL_3"));
+ assertNull(bean2.getType("PROTECTED_3"));
+ assertNull(bean2.getType("PROTECTED_FINAL_3"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_3"));
+ assertNull(bean2.getType("PACKAGE_PROTECTED_FINAL_3"));
+ assertNull(bean2.getType("PUBLIC_3"));
+ assertNull(bean2.getType("PUBLIC_FINAL_3"));
+
+ //
+ assertNull(bean2.getType("STATIC_PRIVATE_3"));
+ assertNull(bean2.getType("STATIC_PRIVATE_FINAL_3"));
+ assertNull(bean2.getType("STATIC_PROTECTED_3"));
+ assertNull(bean2.getType("STATIC_PROTECTED_FINAL_3"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_3"));
+ assertNull(bean2.getType("STATIC_PACKAGE_PROTECTED_FINAL_3"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_3"));
+ assertNotNull(bean2.getType("STATIC_PUBLIC_FINAL_3"));
+
+ //
+ assertNotNull(bean2.getValue("PRIVATE_3"));
+ assertNotNull(bean2.getValue("PRIVATE_FINAL_3"));
+ assertNotNull(bean2.getValue("PROTECTED_3"));
+ assertNotNull(bean2.getValue("PROTECTED_FINAL_3"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_3"));
+ assertNotNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_3"));
+ assertNotNull(bean2.getValue("PUBLIC_3"));
+ assertNotNull(bean2.getValue("PUBLIC_FINAL_3"));
+
+ //
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_3"));
+ assertNotNull(bean2.getValue("STATIC_PRIVATE_FINAL_3"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_3"));
+ assertNotNull(bean2.getValue("STATIC_PROTECTED_FINAL_3"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_3"));
+ assertNotNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_3"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_3"));
+ assertNotNull(bean2.getValue("STATIC_PUBLIC_FINAL_3"));
+
+ //
+ assertNull(bean2.getValue("PRIVATE_3").getObject());
+ assertNull(bean2.getValue("PRIVATE_FINAL_3").getObject());
+ assertNull(bean2.getValue("PROTECTED_3").getObject());
+ assertNull(bean2.getValue("PROTECTED_FINAL_3").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_3").getObject());
+ assertNull(bean2.getValue("PACKAGE_PROTECTED_FINAL_3").getObject());
+ assertNull(bean2.getValue("PUBLIC_3").getObject());
+ assertNull(bean2.getValue("PUBLIC_FINAL_3").getObject());
+
+ //
+ assertNull(bean2.getValue("STATIC_PRIVATE_3").getObject());
+ assertNull(bean2.getValue("STATIC_PRIVATE_FINAL_3").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_3").getObject());
+ assertNull(bean2.getValue("STATIC_PROTECTED_FINAL_3").getObject());
+ assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_3").getObject());
+
assertNull(bean2.getValue("STATIC_PACKAGE_PROTECTED_FINAL_3").getObject());
+ assertEquals("CT2_STATIC_PUBLIC_3_VALUE",
bean2.getValue("STATIC_PUBLIC_3").getObject());
+ assertEquals("CT2_STATIC_PUBLIC_FINAL_3_VALUE",
bean2.getValue("STATIC_PUBLIC_FINAL_3").getObject());
+ }
+
+ public void testValues()
+ {
+ assertNotNull(bean3.getValue("INT_0"));
+ assertNotNull(bean3.getValue("INT_1"));
+ assertNotNull(bean3.getValue("INT_2"));
+ assertNotNull(bean3.getValue("BOOLEAN_TRUE"));
+ assertNotNull(bean3.getValue("BOOLEAN_FALSE"));
+ assertNotNull(bean3.getValue("INTEGER_0"));
+ assertNotNull(bean3.getValue("INTEGER_1"));
+ assertNotNull(bean3.getValue("INTEGER_2"));
+ assertNotNull(bean3.getValue("BOOLEAN_OBJECT_TRUE"));
+ assertNotNull(bean3.getValue("BOOLEAN_OBJECT_FALSE"));
+ assertNotNull(bean3.getValue("OBJECT"));
+
+ //
+ assertEquals(new Integer(0), bean3.getValue("INT_0").getObject());
+ assertEquals(new Integer(1), bean3.getValue("INT_1").getObject());
+ assertEquals(new Integer(2), bean3.getValue("INT_2").getObject());
+ assertEquals(Boolean.TRUE, bean3.getValue("BOOLEAN_TRUE").getObject());
+ assertEquals(Boolean.FALSE,
bean3.getValue("BOOLEAN_FALSE").getObject());
+ assertEquals(new Integer(0), bean3.getValue("INTEGER_0").getObject());
+ assertEquals(new Integer(1), bean3.getValue("INTEGER_1").getObject());
+ assertEquals(new Integer(2), bean3.getValue("INTEGER_2").getObject());
+ assertEquals(Boolean.TRUE,
bean3.getValue("BOOLEAN_OBJECT_TRUE").getObject());
+ assertEquals(Boolean.FALSE,
bean3.getValue("BOOLEAN_OBJECT_FALSE").getObject());
+ assertEquals(ClassConstant3.OBJECT,
bean3.getValue("OBJECT").getObject());
+ }
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/DelegatingPropertyResolverTestCase.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/DelegatingPropertyResolverTestCase.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/DelegatingPropertyResolverTestCase.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,212 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+import junit.framework.TestCase;
+import org.jboss.portal.faces.el.DelegatingPropertyResolver;
+
+import javax.faces.el.PropertyNotFoundException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class DelegatingPropertyResolverTestCase extends TestCase
+{
+
+ /** . */
+ private Object propertyName;
+
+ /** . */
+ private Object bean;
+
+ /** . */
+ private TestBean testBean;
+
+ /** . */
+ private TestBeanDecorator testBeanDecorator;
+
+ /** . */
+ private TestBeanDecorator testBeanInterfaceDecorator;
+
+ /** . */
+ private TestBeanDecorator testBeanInterfaceSuperInterfaceDecorator;
+
+ /** . */
+ private TestBeanDecorator testBeanSuperClassDecorator;
+
+ /** . */
+ private TestDynamicBean testDynamicBean;
+
+ /** . */
+ private DelegatingPropertyResolver resolver;
+
+ protected void setUp() throws Exception
+ {
+ propertyName = new Object();
+ bean = new Object();
+ testBean = new TestBean();
+ testBeanDecorator = new TestBeanDecorator(testBean.property);
+ testBeanInterfaceDecorator = new TestBeanDecorator(testBean.interfaceProperty);
+ testBeanInterfaceSuperInterfaceDecorator = new
TestBeanDecorator(testBean.interfaceSuperInterfaceProperty);
+ testBeanSuperClassDecorator = new TestBeanDecorator(testBean.superClassProperty);
+ testDynamicBean = new TestDynamicBean();
+ resolver = new DelegatingPropertyResolver();
+ resolver.registerDecorator(TestBean.class, testBeanDecorator);
+ resolver.registerDecorator(TestBeanInterface.class, testBeanInterfaceDecorator);
+ resolver.registerDecorator(TestBeanInterfaceSuperInterface.class,
testBeanInterfaceSuperInterfaceDecorator);
+ resolver.registerDecorator(TestBeanSuperClass.class, testBeanSuperClassDecorator);
+ }
+
+ public void testGetType()
+ {
+ try
+ {
+ resolver.getType(bean, propertyName);
+ fail("Was expecting PNFE");
+ }
+ catch (PropertyNotFoundException expected)
+ {
+ }
+
+ // TestBean
+ try
+ {
+ resolver.getType(testBean, new Object());
+ fail("Was expecting PNFE");
+ }
+ catch (PropertyNotFoundException expected)
+ {
+ }
+ assertEquals(Value.class, resolver.getType(testBean,
testBeanDecorator.property.name));
+ assertEquals(Value.class, resolver.getType(testBean,
testBeanInterfaceDecorator.property.name));
+ assertEquals(Value.class, resolver.getType(testBean,
testBeanInterfaceSuperInterfaceDecorator.property.name));
+ assertEquals(Value.class, resolver.getType(testBean,
testBeanSuperClassDecorator.property.name));
+
+ //
+ try
+ {
+ resolver.getType(testDynamicBean, new Object());
+ fail("Was expecting PNFE");
+ }
+ catch (PropertyNotFoundException expected)
+ {
+ }
+ assertEquals(Value.class, resolver.getType(testDynamicBean,
testDynamicBean.propertyName));
+ }
+
+ public void testIsReadOnly()
+ {
+ try
+ {
+ resolver.isReadOnly(bean, propertyName);
+ fail("Was expecting PNFE");
+ }
+ catch (PropertyNotFoundException expected)
+ {
+ }
+ }
+
+ public void testGetValue()
+ {
+ try
+ {
+ resolver.getValue(bean, propertyName);
+ fail("Was expecting PNFE");
+ }
+ catch (PropertyNotFoundException expected)
+ {
+ }
+
+ //
+ try
+ {
+ resolver.getType(testBean, new Object());
+ fail("Was expecting PNFE");
+ }
+ catch (PropertyNotFoundException expected)
+ {
+ }
+ assertEquals(testBean.property.value, resolver.getValue(testBean,
testBeanDecorator.property.name));
+ assertEquals(testBeanInterfaceDecorator.property.value, resolver.getValue(testBean,
testBeanInterfaceDecorator.property.name));
+ assertEquals(testBeanInterfaceSuperInterfaceDecorator.property.value,
resolver.getValue(testBean, testBeanInterfaceSuperInterfaceDecorator.property.name));
+ assertEquals(testBeanSuperClassDecorator.property.value,
resolver.getValue(testBean, testBeanSuperClassDecorator.property.name));
+
+ //
+ try
+ {
+ resolver.getType(testDynamicBean, new Object());
+ fail("Was expecting PNFE");
+ }
+ catch (PropertyNotFoundException expected)
+ {
+ }
+ assertEquals(testDynamicBean.propertyValue, resolver.getValue(testDynamicBean,
testDynamicBean.propertyName));
+ }
+
+ public void testSetValue()
+ {
+ try
+ {
+ resolver.setValue(bean, propertyName, null);
+ fail("Was expecting PNFE");
+ }
+ catch (PropertyNotFoundException expected)
+ {
+ }
+
+ //
+ try
+ {
+ resolver.setValue(testBean, new Object(), null);
+ fail("Was expecting PNFE");
+ }
+ catch (PropertyNotFoundException expected)
+ {
+ }
+ Value propertyExpectedValue = new Value();
+ resolver.setValue(testBean, testBeanDecorator.property.name,
propertyExpectedValue);
+ assertEquals(propertyExpectedValue, testBeanDecorator.property.value);
+ Value interfacePropertyExpectedValue = new Value();
+ resolver.setValue(testBean, testBeanInterfaceDecorator.property.name,
interfacePropertyExpectedValue);
+ assertEquals(interfacePropertyExpectedValue,
testBeanInterfaceDecorator.property.value);
+ Value interfaceSuperInterfacePropertyExpectedValue = new Value();
+ resolver.setValue(testBean, testBeanInterfaceSuperInterfaceDecorator.property.name,
interfaceSuperInterfacePropertyExpectedValue);
+ assertEquals(interfaceSuperInterfacePropertyExpectedValue,
testBeanInterfaceSuperInterfaceDecorator.property.value);
+ Value superClassPropertyExpectedValue = new Value();
+ resolver.setValue(testBean, testBeanSuperClassDecorator.property.name,
superClassPropertyExpectedValue);
+ assertEquals(superClassPropertyExpectedValue,
testBeanSuperClassDecorator.property.value);
+
+ //
+ try
+ {
+ resolver.setValue(testDynamicBean, new Object(), null);
+ fail("Was expecting PNFE");
+ }
+ catch (PropertyNotFoundException expected)
+ {
+ }
+ resolver.setValue(testDynamicBean, testDynamicBean.propertyName,
propertyExpectedValue);
+ assertEquals(propertyExpectedValue, testDynamicBean.propertyValue);
+ }
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/SimpleDynamicBeanTestCase.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/SimpleDynamicBeanTestCase.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/SimpleDynamicBeanTestCase.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,97 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+import junit.framework.TestCase;
+import org.jboss.portal.faces.el.PropertyValue;
+import org.jboss.portal.faces.el.dynamic.AbstractDynamicProperty;
+import org.jboss.portal.faces.el.dynamic.DynamicBean;
+import org.jboss.portal.faces.el.dynamic.DynamicProperty;
+import org.jboss.portal.faces.el.dynamic.SimpleDynamicBean;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class SimpleDynamicBeanTestCase extends TestCase
+{
+
+ private DynamicBean _bean;
+ private Object _propertyName;
+ private Object _propertyValue;
+
+ protected void setUp() throws Exception
+ {
+ _propertyName = new Object();
+ _propertyValue = new Value();
+ _bean = new SimpleDynamicBean()
+ {
+ protected DynamicProperty getProperty(Object propertyName)
+ {
+ if (_propertyName == propertyName)
+ {
+ return new AbstractDynamicProperty(Value.class)
+ {
+ public Object getValue() throws IllegalArgumentException
+ {
+ return _propertyValue;
+ }
+
+ public boolean setValue(Object value) throws IllegalArgumentException
+ {
+ _propertyValue = value;
+ return true;
+ }
+ };
+ }
+ return null;
+ }
+ };
+ }
+
+ protected void tearDown() throws Exception
+ {
+ _bean = null;
+ }
+
+ public void testGetType()
+ {
+ assertEquals(Value.class, _bean.getType(_propertyName));
+ }
+
+ public void testGetValue()
+ {
+ assertEquals(new PropertyValue(_propertyValue), _bean.getValue(_propertyName));
+ }
+
+ public void testSetValue()
+ {
+ Value expectedValue = new Value();
+ assertTrue(_bean.setValue(_propertyName, expectedValue));
+ assertEquals(expectedValue, _propertyValue);
+
+ //
+ assertTrue(_bean.setValue(_propertyName, null));
+ assertEquals(null, _propertyValue);
+ }
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBean.java
===================================================================
--- modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBean.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBean.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class TestBean extends TestBeanSuperClass implements TestBeanInterface
+{
+
+ /** . */
+ Property property;
+
+ /** . */
+ Property interfaceProperty;
+
+ /** . */
+ Property interfaceSuperInterfaceProperty;
+
+ /** . */
+ Property superClassProperty;
+
+ public TestBean()
+ {
+ this.property = new Property();
+ this.interfaceProperty = new Property();
+ this.interfaceSuperInterfaceProperty = new Property();
+ this.superClassProperty = new Property();
+ }
+
+ public class Property
+ {
+
+ /** . */
+ final TestBean bean;
+
+ /** . */
+ final Object name;
+
+ /** . */
+ Value value;
+
+ public Property()
+ {
+ this.bean = TestBean.this;
+ this.name = new Object();
+ this.value = new Value();
+ }
+ }
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanDecorator.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanDecorator.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanDecorator.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+import org.jboss.portal.faces.el.decorator.AbstractBeanDecorator;
+import org.jboss.portal.faces.el.decorator.AbstractPropertyDecorator;
+import org.jboss.portal.faces.el.decorator.PropertyDecorator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class TestBeanDecorator extends AbstractBeanDecorator
+{
+
+ /** . */
+ final TestBean.Property property;
+
+ public TestBeanDecorator(TestBean.Property property)
+ {
+ this.property = property;
+ }
+
+ protected PropertyDecorator getProperty(Object propertyName)
+ {
+ if (property.name == propertyName)
+ {
+ return new AbstractPropertyDecorator(Value.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ if (property.bean == bean)
+ {
+ return property.value;
+ }
+ throw new IllegalArgumentException("Not the bean we expected");
+ }
+
+ public boolean setValue(Object bean, Object value) throws
IllegalArgumentException
+ {
+ if (property.bean == bean)
+ {
+ property.value = (Value)value;
+ return true;
+ }
+ return false;
+ }
+ };
+ }
+ return null;
+ }
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanInterface.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanInterface.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanInterface.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface TestBeanInterface extends TestBeanInterfaceSuperInterface
+{
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanInterfaceSuperInterface.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanInterfaceSuperInterface.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanInterfaceSuperInterface.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public interface TestBeanInterfaceSuperInterface
+{
+}
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanSuperClass.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanSuperClass.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestBeanSuperClass.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 8784 $
+ */
+public class TestBeanSuperClass
+{
+
+}
+
Added:
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestDynamicBean.java
===================================================================
---
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestDynamicBean.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/TestDynamicBean.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+import org.jboss.portal.faces.el.dynamic.AbstractDynamicProperty;
+import org.jboss.portal.faces.el.dynamic.DynamicProperty;
+import org.jboss.portal.faces.el.dynamic.SimpleDynamicBean;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class TestDynamicBean extends SimpleDynamicBean
+{
+
+ /** . */
+ final Object propertyName;
+
+ /** . */
+ Value propertyValue;
+
+ public TestDynamicBean()
+ {
+ this.propertyName = new Object();
+ this.propertyValue = new Value();
+ }
+
+ protected DynamicProperty getProperty(Object propertyName)
+ {
+ if (propertyName == this.propertyName)
+ {
+ return new AbstractDynamicProperty(Value.class)
+ {
+ public Object getValue() throws IllegalArgumentException
+ {
+ return propertyValue;
+ }
+
+ public boolean setValue(Object value) throws IllegalArgumentException
+ {
+ propertyValue = (Value)value;
+ return true;
+ }
+ };
+ }
+ return null;
+ }
+}
Added: modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/Value.java
===================================================================
--- modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/Value.java
(rev 0)
+++
modules/faces/trunk/faces/src/test/java/org/jboss/portal/test/faces/el/Value.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,31 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.faces.el;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 8784 $
+ */
+public class Value
+{
+}
Added: modules/faces/trunk/faces/src/test/java/util/JSFFunctorTestCase.java
===================================================================
--- modules/faces/trunk/faces/src/test/java/util/JSFFunctorTestCase.java
(rev 0)
+++ modules/faces/trunk/faces/src/test/java/util/JSFFunctorTestCase.java 2009-06-05
03:25:58 UTC (rev 13436)
@@ -0,0 +1,63 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This 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 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.faces.util.JSFFunctor;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class JSFFunctorTestCase extends TestCase
+{
+ private JSFFunctor functor = JSFFunctor.ID_SANITIZER;
+
+ public void testGet()
+ {
+ assertNull(functor.get(null));
+ assertEquals("foo_bar", functor.get("foo bar"));
+ assertEquals("foo_bar", functor.get("foo.bar"));
+ assertEquals("foo______bar", functor.get("foo .bar"));
+ assertEquals("foo_bar_baz_boo", functor.get("foo.bar
baz.boo"));
+ }
+
+ public void testSimplePerformance()
+ {
+ for (int i = 0; i < 500000; i++)
+ {
+ assertEquals("foo" + i + "_bar", functor.get("foo"
+ i + " bar"));
+ }
+ }
+
+ public void testRepeatedPerformance()
+ {
+ for (int i = 0; i < 100000; i++)
+ {
+ assertEquals("foo" + i + "_bar", functor.get("foo"
+ i + " bar"));
+ assertEquals("foo" + i + "_bar", functor.get("foo"
+ i + " bar"));
+ assertEquals("foo" + i + "_bar", functor.get("foo"
+ i + " bar"));
+ assertEquals("foo" + i + "_bar", functor.get("foo"
+ i + " bar"));
+ }
+ }
+}
Added: modules/faces/trunk/pom.xml
===================================================================
--- modules/faces/trunk/pom.xml (rev 0)
+++ modules/faces/trunk/pom.xml 2009-06-05 03:25:58 UTC (rev 13436)
@@ -0,0 +1,35 @@
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.portal.faces</groupId>
+ <artifactId>module-aggregator</artifactId>
+ <packaging>pom</packaging>
+ <name>JBoss Portal JSF support</name>
+ <version>1.0.0-SNAPSHOT</version>
+ <
url>http://www.jboss.org/jbossportal</url>
+
+ <dependencies/>
+
+ <!--Repository definition needed to deploy artifacts into JBoss maven
repositories-->
+ <distributionManagement>
+ <repository>
+ <!--Copy the distribution jar file to a local checkout of the maven
repository
+ - This variable can be set in $MAVEN_HOME/conf/settings.xml-->
+ <id>repository.jboss.org</id>
+ <url>file://${jboss.repository.root}</url>
+ </repository>
+ <snapshotRepository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <
url>dav:https://snapshots.jboss.org/maven2</url>
+ <uniqueVersion>true</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <modules>
+ <module>build</module>
+ <module>faces</module>
+ </modules>
+
+
+</project>
\ No newline at end of file