Author: nbelaevski
Date: 2008-03-20 15:50:46 -0400 (Thu, 20 Mar 2008)
New Revision: 7033
Added:
trunk/samples/functions-demo/
trunk/samples/functions-demo/pom.xml
trunk/samples/functions-demo/src/
trunk/samples/functions-demo/src/main/
trunk/samples/functions-demo/src/main/webapp/
trunk/samples/functions-demo/src/main/webapp/WEB-INF/
trunk/samples/functions-demo/src/main/webapp/WEB-INF/web.xml
trunk/samples/functions-demo/src/main/webapp/index.jsp
trunk/samples/functions-demo/src/main/webapp/pages/
trunk/samples/functions-demo/src/main/webapp/pages/index.jsp
trunk/samples/functions-demo/src/main/webapp/pages/index.xhtml
trunk/ui/functions/
trunk/ui/functions/pom.xml
trunk/ui/functions/src/
trunk/ui/functions/src/main/
trunk/ui/functions/src/main/config/
trunk/ui/functions/src/main/config/component/
trunk/ui/functions/src/main/config/component/functions.xml
trunk/ui/functions/src/main/java/
trunk/ui/functions/src/main/java/org/
trunk/ui/functions/src/main/java/org/richfaces/
trunk/ui/functions/src/main/java/org/richfaces/function/
trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java
trunk/ui/functions/src/test/
trunk/ui/functions/src/test/java/
trunk/ui/functions/src/test/java/org/
trunk/ui/functions/src/test/java/org/richfaces/
trunk/ui/functions/src/test/java/org/richfaces/component/
trunk/ui/functions/src/test/java/org/richfaces/component/JSFComponentTest.java
Modified:
trunk/samples/pom.xml
trunk/samples/richfaces-ear-demo/
trunk/ui/pom.xml
Log:
http://jira.jboss.com/jira/browse/RF-2667
Property changes on: trunk/samples/functions-demo
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
Added: trunk/samples/functions-demo/pom.xml
===================================================================
--- trunk/samples/functions-demo/pom.xml (rev 0)
+++ trunk/samples/functions-demo/pom.xml 2008-03-20 19:50:46 UTC (rev 7033)
@@ -0,0 +1,22 @@
+<?xml version="1.0"?><project>
+ <parent>
+ <artifactId>samples</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces</groupId>
+ <artifactId>functions-demo</artifactId>
+ <packaging>war</packaging>
+ <name>functions-demo Maven Webapp</name>
+ <build>
+ <finalName>functions-demo</finalName>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>functions</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/samples/functions-demo/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/functions-demo/src/main/webapp/WEB-INF/web.xml
(rev 0)
+++ trunk/samples/functions-demo/src/main/webapp/WEB-INF/web.xml 2008-03-20 19:50:46 UTC
(rev 7033)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+ <display-name>Archetype Created Web Application</display-name>
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/faces-config.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <!-- Use Documents Saved as *.xhtml -->
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.jsp</param-value>
+ </context-param>
+
+ <!-- Facelets pages will use the .xhtml extension -->
+ <context-param>
+ <param-name>facelets.VIEW_MAPPINGS</param-name>
+ <param-value>*xhtml</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
+ <param-value>com.sun.facelets.FaceletViewHandler</param-value>
+ </context-param>
+
+ <!--
+ -->
+ <filter>
+ <display-name>Ajax4jsf Filter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>ajax4jsf</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ <dispatcher>ERROR</dispatcher>
+ </filter-mapping>
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ </servlet>
+
+ <!-- Use prefix mapping for Facelets pages, e.g.
http://localhost:8080/webapp/faces/mypage.xhtml -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Added: trunk/samples/functions-demo/src/main/webapp/index.jsp
===================================================================
--- trunk/samples/functions-demo/src/main/webapp/index.jsp (rev
0)
+++ trunk/samples/functions-demo/src/main/webapp/index.jsp 2008-03-20 19:50:46 UTC (rev
7033)
@@ -0,0 +1,12 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+
+<html>
+
+<head></head>
+
+ <body>
+ <a href="faces/pages/index.jsp">JSP</a><br/>
+ <a href="faces/pages/index.xhtml">Facelets</a>
+ </body>
+
+</html>
\ No newline at end of file
Added: trunk/samples/functions-demo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/functions-demo/src/main/webapp/pages/index.jsp
(rev 0)
+++ trunk/samples/functions-demo/src/main/webapp/pages/index.jsp 2008-03-20 19:50:46 UTC
(rev 7033)
@@ -0,0 +1,24 @@
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/functions"
prefix="fn" %>
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+ <f:subview id="view">
+ <h:form id="myForm">
+ <h:inputText id="input" />
+ </h:form>
+ </f:subview>
+
+ <h:outputText value="#{fn:clientId('input')}" />
+ <br />
+ <h:outputText value="#{fn:element('input')}" />
+ <br />
+ <h:outputText value="#{fn:component('input')}" />
+ <br />
+ </f:view>
+ </body>
+</html>
Added: trunk/samples/functions-demo/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/samples/functions-demo/src/main/webapp/pages/index.xhtml
(rev 0)
+++ trunk/samples/functions-demo/src/main/webapp/pages/index.xhtml 2008-03-20 19:50:46 UTC
(rev 7033)
@@ -0,0 +1,22 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:fn="http://labs.jboss.com/jbossrichfaces/ui/functions"
+ >
+ <f:view>
+ <f:subview id="view">
+ <h:form id="myForm">
+ <h:inputText id="input" />
+ </h:form>
+ </f:subview>
+
+ <h:outputText value="#{fn:clientId('input')}" />
+ <br />
+ <h:outputText value="#{fn:element('input')}" />
+ <br />
+ <h:outputText value="#{fn:component('input')}" />
+ <br />
+ </f:view>
+</html>
\ No newline at end of file
Modified: trunk/samples/pom.xml
===================================================================
--- trunk/samples/pom.xml 2008-03-20 19:36:23 UTC (rev 7032)
+++ trunk/samples/pom.xml 2008-03-20 19:50:46 UTC (rev 7033)
@@ -466,5 +466,6 @@
<module>sortingFilteringDemo</module>
<module>inplaceInput-sample</module>
<module>inplaceSelect-sample</module>
+ <module>functions-demo</module>
</modules>
</project>
\ No newline at end of file
Property changes on: trunk/samples/richfaces-ear-demo
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: trunk/ui/functions
___________________________________________________________________
Name: svn:ignore
+ target
Added: trunk/ui/functions/pom.xml
===================================================================
--- trunk/ui/functions/pom.xml (rev 0)
+++ trunk/ui/functions/pom.xml 2008-03-20 19:50:46 UTC (rev 7033)
@@ -0,0 +1,43 @@
+<?xml version="1.0"?><project>
+ <parent>
+ <artifactId>ui</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>functions</artifactId>
+ <name>functions</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <library>
+ <prefix>org.richfaces</prefix>
+ <taglib>
+ <shortName>functions</shortName>
+ </taglib>
+ </library>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>richfaces-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/ui/functions/src/main/config/component/functions.xml
===================================================================
--- trunk/ui/functions/src/main/config/component/functions.xml
(rev 0)
+++ trunk/ui/functions/src/main/config/component/functions.xml 2008-03-20 19:50:46 UTC
(rev 7033)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components
+ PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
+ "https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd">
+
+<components>
+ <function>
+ <name>clientId</name>
+
<method>org.richfaces.function.RichFunction.clientId(String)</method>
+ </function>
+
+ <function>
+ <name>component</name>
+
<method>org.richfaces.function.RichFunction.component(String)</method>
+ </function>
+
+ <function>
+ <name>element</name>
+
<method>org.richfaces.function.RichFunction.element(String)</method>
+ </function>
+</components>
Added: trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java
===================================================================
--- trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java
(rev 0)
+++ trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java 2008-03-20
19:50:46 UTC (rev 7033)
@@ -0,0 +1,75 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.function;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.RendererUtils;
+
+/**
+ * Created 20.03.2008
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public class RichFunction {
+
+ public static String clientId(String id) {
+ if (id != null) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (context != null) {
+ UIViewRoot root = context.getViewRoot();
+
+ if (root != null) {
+ UIComponent component = RendererUtils.getInstance().findComponentFor(root, id);
+
+ if (component != null) {
+ return component.getClientId(context);
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public static String component(String id) {
+ String element = element(id);
+ if (element != null) {
+ return element + ".component";
+ }
+
+ return null;
+ }
+
+ public static String element(String id) {
+ String clientId = clientId(id);
+ if (clientId != null) {
+ return "document.getElementById('" + clientId + "')";
+ }
+
+ return null;
+ }
+
+}
Added: trunk/ui/functions/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
--- trunk/ui/functions/src/test/java/org/richfaces/component/JSFComponentTest.java
(rev 0)
+++
trunk/ui/functions/src/test/java/org/richfaces/component/JSFComponentTest.java 2008-03-20
19:50:46 UTC (rev 7033)
@@ -0,0 +1,53 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import javax.faces.component.UIComponent;
+
+/**
+ * Unit test for simple Component.
+ */
+public class JSFComponentTest
+ extends TestCase
+{
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public JSFComponentTest( String testName )
+ {
+ super( testName );
+ }
+
+
+ /**
+ * Rigourous Test :-)
+ */
+ public void testComponent()
+ {
+ assertTrue( true );
+ }
+}
Modified: trunk/ui/pom.xml
===================================================================
--- trunk/ui/pom.xml 2008-03-20 19:36:23 UTC (rev 7032)
+++ trunk/ui/pom.xml 2008-03-20 19:50:46 UTC (rev 7033)
@@ -127,6 +127,7 @@
<module>fileUpload</module>
<module>inplaceInput</module>
<module>inplaceSelect</module>
+ <module>functions</module>
</modules>
<dependencies>
<dependency>
@@ -183,4 +184,4 @@
<scope>provided</scope>
</dependency>
</dependencies>
-</project>
+</project>
\ No newline at end of file