Author: SergeySmirnov
Date: 2007-10-09 21:09:00 -0400 (Tue, 09 Oct 2007)
New Revision: 3304
Added:
trunk/ui/jQuery/
trunk/ui/jQuery/pom.xml
trunk/ui/jQuery/src/
trunk/ui/jQuery/src/main/
trunk/ui/jQuery/src/main/config/
trunk/ui/jQuery/src/main/config/component/
trunk/ui/jQuery/src/main/config/component/jQuery.xml
trunk/ui/jQuery/src/main/java/
trunk/ui/jQuery/src/main/java/org/
trunk/ui/jQuery/src/main/java/org/richfaces/
trunk/ui/jQuery/src/main/java/org/richfaces/component/
trunk/ui/jQuery/src/main/java/org/richfaces/component/UIJQuery.java
trunk/ui/jQuery/src/main/java/org/richfaces/renderkit/
trunk/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java
trunk/ui/jQuery/src/main/templates/
trunk/ui/jQuery/src/main/templates/jQuery.jspx
trunk/ui/jQuery/src/test/
trunk/ui/jQuery/src/test/java/
trunk/ui/jQuery/src/test/java/org/
trunk/ui/jQuery/src/test/java/org/richfaces/
trunk/ui/jQuery/src/test/java/org/richfaces/component/
trunk/ui/jQuery/src/test/java/org/richfaces/component/JQueryComponentTest.java
Log:
jQuery component has been added. init version
Property changes on: trunk/ui/jQuery
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
Added: trunk/ui/jQuery/pom.xml
===================================================================
--- trunk/ui/jQuery/pom.xml (rev 0)
+++ trunk/ui/jQuery/pom.xml 2007-10-10 01:09:00 UTC (rev 3304)
@@ -0,0 +1,45 @@
+<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>
+ <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>jQuery</artifactId>
+ <name>jQuery Selectors</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>
+ <execution>
+ <id>generate-test-sources</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>generate-tests</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <library>
+ <prefix>org.richfaces</prefix>
+ <taglib>
+ <shortName>jQuery</shortName>
+ </taglib>
+ </library>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/ui/jQuery/src/main/config/component/jQuery.xml
===================================================================
--- trunk/ui/jQuery/src/main/config/component/jQuery.xml (rev 0)
+++ trunk/ui/jQuery/src/main/config/component/jQuery.xml 2007-10-10 01:09:00 UTC (rev
3304)
@@ -0,0 +1,69 @@
+<?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>
+ <component>
+ <name>org.richfaces.JQuery</name>
+ <family>org.richfaces.JQuery</family>
+ <classname>org.richfaces.component.html.HtmlJQuery</classname>
+ <superclass>org.richfaces.component.UIJQuery</superclass>
+ <description>
+ <![CDATA[
+ It presents the google map in JSF applications
+ ]]>
+ </description>
+ <test />
+ <renderer generate="true" override="true">
+ <name>org.richfaces.JQueryRenderer</name>
+ <template>jQuery.jspx</template>
+ </renderer>
+ <tag>
+ <name>jQuery</name>
+ <classname>org.richfaces.taglib.JQueryTag</classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+ </superclass>
+ </tag>
+ &ui_component_attributes;
+
+ <property>
+ <name>name</name>
+ <classname>java.lang.String</classname>
+ <description>
+ The name of the function that will be generated to execute the query. If name is
+ not defined explicitly it will be pre-generated from the id of the component
where
+ colon is replaced with underscore and "jq_" prefix is added. The name
attribute is required
+ if timing attribute equals to "onJScall"
+ </description>
+ <defaultvalue>""</defaultvalue>
+ </property>
+ <property>
+ <name>selector</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Selector for query. The component id as well as any html element id might
+ be used inside.
+ </description>
+ <defaultvalue>""</defaultvalue>
+ </property>
+ <property required="true">
+ <name>query</name>
+ <classname>java.lang.String</classname>
+ <description>
+ The query string that will be executed for given selector.
+ </description>
+ <defaultvalue>""</defaultvalue>
+ </property>
+ <property>
+ <name>timing</name>
+ <classname>java.lang.String</classname>
+ <description>
+ When to peform the query. Two possible values are
"immediate","onload" and "onJScall".
+ "immediate" performs the query right away. "onload" adds the task
to the
+ time when document is loaded (the DOM tree is created). "onJScall" allows
to invoke the
+ query by Javascipt function name defined with "name" attribute. The default
value is
+ "immediate".
+ </description>
+ <defaultvalue>"immediate"</defaultvalue>
+ </property>
+ </component>
+</components>
Added: trunk/ui/jQuery/src/main/java/org/richfaces/component/UIJQuery.java
===================================================================
--- trunk/ui/jQuery/src/main/java/org/richfaces/component/UIJQuery.java
(rev 0)
+++ trunk/ui/jQuery/src/main/java/org/richfaces/component/UIJQuery.java 2007-10-10
01:09:00 UTC (rev 3304)
@@ -0,0 +1,36 @@
+/**
+ * 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.component;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * JSF component class
+ *
+ */
+public abstract class UIJQuery extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.JQuery";
+
+ private static final String COMPONENT_FAMILY = "org.richfaces.JQuery";
+
+}
Added: trunk/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java
===================================================================
--- trunk/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java
(rev 0)
+++
trunk/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java 2007-10-10
01:09:00 UTC (rev 3304)
@@ -0,0 +1,55 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.regex.Pattern;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.FacesException;
+import org.richfaces.renderkit.JQueryRendererBase;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.richfaces.component.UIJQuery;
+
+
+public class JQueryRendererBase extends HeaderResourcesRendererBase {
+
+ protected Class getComponentClass() {
+ return UIJQuery.class;
+ }
+
+
+
+ protected void checkValidity(String clientId, String name, String timing, String query)
{
+
+ if ( ! "onJScall".equals(timing) &&
+ ! "onload".equals(timing) &&
+ ! "immediate".equals(timing) ) {
+ throw new FacesException(
+ "The timing attribute of the jQuery component
(id='"+clientId+"') has an invalid value:'"+ timing +
+ "'. It may have only the following values: 'immediate',
'onload', 'onJScall'");
+ }
+
+ if ( name == null ) {
+ throw new FacesException(
+ "The name attribute of the jQuery component
(id='"+clientId+"') might not be null" );
+
+ }
+
+ if ( "".equals(name.trim()) && "onJScall".equals(timing) )
{
+ throw new FacesException(
+ "The name attribute of the jQuery component
(id='"+clientId+"') must be specified when timing attribute equals to
'onJScall'" );
+ }
+
+ if ( "".equals(query.trim()) || query==null ) {
+ throw new FacesException(
+ "The query attribute of the jQuery component
(id='"+clientId+"') must be specified" );
+ }
+
+ }
+ protected String replaceClientIds(String selector) {
+ return selector;
+ }
+
+
+}
Added: trunk/ui/jQuery/src/main/templates/jQuery.jspx
===================================================================
--- trunk/ui/jQuery/src/main/templates/jQuery.jspx (rev 0)
+++ trunk/ui/jQuery/src/main/templates/jQuery.jspx 2007-10-10 01:09:00 UTC (rev 3304)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:root
+
xmlns:f="http://ajax4jsf.org/cdk/template"
+ xmlns:c="
http://java.sun.com/jsf/core"
+ xmlns:ui="
http://ajax4jsf.org/cdk/ui"
+ xmlns:u="
http://ajax4jsf.org/cdk/u"
+ xmlns:x="
http://ajax4jsf.org/cdk/x"
+ class="org.richfaces.renderkit.html.JQueryRenderer"
+ baseclass="org.richfaces.renderkit.JQueryRendererBase"
+ component="org.richfaces.component.UIJQuery">
+ <f:clientid var="clientId"/>
+
+
+ <c:set var="selector"
value="#{component.attributes['selector']}"/>
+ <c:set var="name"
value="#{component.attributes['name']}"/>
+ <c:set var="timing"
value="#{component.attributes['timing']}"/>
+ <c:set var="query"
value="#{component.attributes['query']}"/>
+ <h:scripts>/org/richfaces/renderkit/html/scripts/jquery/jquery.js</h:scripts>
+
+
+<jsp:scriptlet>
+<![CDATA[
+ String name = (String) variables.getVariable("name");
+ String timing = (String) variables.getVariable("timing");
+ String query = (String) variables.getVariable("query");
+ String selector = (String) variables.getVariable("selector");
+
+ checkValidity(clientId, name, timing, query);
+ variables.setVariable("selector", replaceClientIds(selector));
+]]>
+</jsp:scriptlet>
+
+<jsp:scriptlet><![CDATA[ if (! "".equals(name.trim()) ) {
]]></jsp:scriptlet>
+<script type="text/javascript">
+ //<![CDATA[
+function #{name}(elm, param) {
+ jQuery(elm || '#{selector}').#{query};
+}
+//]]>
+</script>
+<jsp:scriptlet><![CDATA[ } ]]></jsp:scriptlet>
+
+<jsp:scriptlet><![CDATA[ if ( "immediate".equals(timing) ) {
]]></jsp:scriptlet>
+<script type="text/javascript">
+ //<![CDATA[
+ jQuery('#{selector}').#{query};
+//]]>
+</script>
+<jsp:scriptlet><![CDATA[ } ]]></jsp:scriptlet>
+
+<jsp:scriptlet><![CDATA[ if ( "onload".equals(timing) ) {
]]></jsp:scriptlet>
+<script type="text/javascript">
+ //<![CDATA[
+ jQuery(document).ready(function() {
+ jQuery('#{selector}').#{query};
+ });
+//]]>
+</script>
+<jsp:scriptlet><![CDATA[ } ]]></jsp:scriptlet>
+
+
+</f:root>
\ No newline at end of file
Added: trunk/ui/jQuery/src/test/java/org/richfaces/component/JQueryComponentTest.java
===================================================================
--- trunk/ui/jQuery/src/test/java/org/richfaces/component/JQueryComponentTest.java
(rev 0)
+++
trunk/ui/jQuery/src/test/java/org/richfaces/component/JQueryComponentTest.java 2007-10-10
01:09:00 UTC (rev 3304)
@@ -0,0 +1,92 @@
+/**
+ * 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.component;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
+/**
+ * Unit test for simple Component.
+ */
+public class JQueryComponentTest extends AbstractAjax4JsfTestCase {
+ private UIForm form = null;
+ private UIComponent jq = null;
+ private static Set javaScripts = new HashSet();
+
+
+ static {
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("script/query.js");
+ }
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public JQueryComponentTest( String testName )
+ {
+ super( testName );
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ form = new HtmlForm();
+ facesContext.getViewRoot().getChildren().add(form);
+
+ jq = application.createComponent(UIJQuery.COMPONENT_TYPE);
+ jq.setId("jq");
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ jq = null;
+ form = null;
+ }
+
+ public void testRendcerComponent() throws Exception {
+ HtmlPage renderedView = renderView();
+
+ HtmlElement htmlGmap =
renderedView.getHtmlElementById(jq.getClientId(facesContext));
+
+
+ }
+
+ public void testRenderStyle() throws Exception {
+ }
+
+ public void testRenderScript() throws Exception {
+ }
+}