[richfaces-svn-commits] JBoss Rich Faces SVN: r2124 - in trunk: samples/effect-sample and 30 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Aug 7 19:37:19 EDT 2007


Author: SergeySmirnov
Date: 2007-08-07 19:37:19 -0400 (Tue, 07 Aug 2007)
New Revision: 2124

Added:
   trunk/samples/effect-sample/
   trunk/samples/effect-sample/pom.xml
   trunk/samples/effect-sample/src/
   trunk/samples/effect-sample/src/main/
   trunk/samples/effect-sample/src/main/java/
   trunk/samples/effect-sample/src/main/java/demo/
   trunk/samples/effect-sample/src/main/java/demo/Bean.java
   trunk/samples/effect-sample/src/main/resources/
   trunk/samples/effect-sample/src/main/resources/japanCherry.skin.properties
   trunk/samples/effect-sample/src/main/webapp/
   trunk/samples/effect-sample/src/main/webapp/META-INF/
   trunk/samples/effect-sample/src/main/webapp/META-INF/MANIFEST.MF
   trunk/samples/effect-sample/src/main/webapp/WEB-INF/
   trunk/samples/effect-sample/src/main/webapp/WEB-INF/faces-config.xml
   trunk/samples/effect-sample/src/main/webapp/WEB-INF/faces-config.xml.l4t
   trunk/samples/effect-sample/src/main/webapp/WEB-INF/web.xml
   trunk/samples/effect-sample/src/main/webapp/effect.xhtml
   trunk/samples/effect-sample/src/main/webapp/index.jsp
   trunk/ui/effect/
   trunk/ui/effect/pom.xml
   trunk/ui/effect/src/
   trunk/ui/effect/src/main/
   trunk/ui/effect/src/main/config/
   trunk/ui/effect/src/main/config/component/
   trunk/ui/effect/src/main/config/component/effect.xml
   trunk/ui/effect/src/main/java/
   trunk/ui/effect/src/main/java/org/
   trunk/ui/effect/src/main/java/org/richfaces/
   trunk/ui/effect/src/main/java/org/richfaces/component/
   trunk/ui/effect/src/main/java/org/richfaces/component/UIEffect.java
   trunk/ui/effect/src/main/resources/
   trunk/ui/effect/src/main/resources/org/
   trunk/ui/effect/src/main/resources/org/richfaces/
   trunk/ui/effect/src/main/resources/org/richfaces/renderkit/
   trunk/ui/effect/src/main/resources/org/richfaces/renderkit/html/
   trunk/ui/effect/src/main/resources/org/richfaces/renderkit/html/script/
   trunk/ui/effect/src/main/resources/org/richfaces/renderkit/html/script/processEffect.js
   trunk/ui/effect/src/main/templates/
   trunk/ui/effect/src/main/templates/effect.jspx
   trunk/ui/effect/src/test/
   trunk/ui/effect/src/test/java/
   trunk/ui/effect/src/test/java/org/
   trunk/ui/effect/src/test/java/org/richfaces/
   trunk/ui/effect/src/test/java/org/richfaces/component/
   trunk/ui/effect/src/test/java/org/richfaces/component/EffectComponentTest.java
Log:
effect component has been added

Added: trunk/samples/effect-sample/pom.xml
===================================================================
--- trunk/samples/effect-sample/pom.xml	                        (rev 0)
+++ trunk/samples/effect-sample/pom.xml	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,25 @@
+<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>samples</artifactId>
+		<groupId>org.richfaces</groupId>
+		<version>3.1.0-SNAPSHOT</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.richfaces.samples</groupId>
+	<artifactId>effect-sample</artifactId>
+	<version>3.1.0-SNAPSHOT</version>
+	<packaging>war</packaging>
+	<name>effect Maven Webapp</name>
+	<dependencies>
+		<dependency>
+			<groupId>org.richfaces.ui</groupId>
+			<artifactId>effect</artifactId>
+			<version>3.1.0-SNAPSHOT</version>
+		</dependency>
+	</dependencies>
+	<build>
+		<finalName>effect-sample</finalName>
+	</build>
+</project>
\ No newline at end of file

Added: trunk/samples/effect-sample/src/main/java/demo/Bean.java
===================================================================
--- trunk/samples/effect-sample/src/main/java/demo/Bean.java	                        (rev 0)
+++ trunk/samples/effect-sample/src/main/java/demo/Bean.java	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - 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 demo;
+
+public class Bean {
+ String zoom;
+
+public String getZoom() {
+	return zoom;
+}
+
+public void setZoom(String zoom) {
+	this.zoom = zoom;
+}
+
+public String act() {
+	zoom = "17";
+	System.out.println("zoom="+zoom);
+	return null;
+}
+
+}

Added: trunk/samples/effect-sample/src/main/resources/japanCherry.skin.properties
===================================================================
--- trunk/samples/effect-sample/src/main/resources/japanCherry.skin.properties	                        (rev 0)
+++ trunk/samples/effect-sample/src/main/resources/japanCherry.skin.properties	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,35 @@
+# render.kit=HTML_BASIC
+#Colors
+headerBackgroundColor=#E8BDBD
+headTextColor=#980808
+selectBackgroundColor=#d9E0E0
+generalBackgroundColor=#F8ECEC
+generalTextColor=#000000
+panelTextColor=#000000
+shadowBackgroundColor=#AFB1B2
+shadowOpacity=2
+tableBorderColor=#C0C0C0
+tableBackgroundColor=#ffffff
+selectControlColor=#980808
+controlBorderColor=#DFA5A5
+interfaceLevel3D=10
+overAllBackground=#ffffff
+generalLinkColor=#980808
+hoverLinkColor=#E10000
+visitedLinkColor=#c0c0c0
+# Fonts
+headerSizeFont=12px
+headerFamilyFont=Arial, Verdana, sans-serif
+tabSizeFont=11
+tabFamilyFont=Arial, Verdana, sans-serif
+buttonSizeFont=12
+buttonFamilyFont=Arial, Verdana, sans-serif
+buttonRadiusCorner=12
+panelRadiusCorner=5
+tabRadiusCorner=5
+
+# Preferable
+preferablePanelBodyPadding=0px 0px 0px 0px
+preferableDataSizeFont=11px
+preferableDataFamilyFont=Arial, Verdana, sans-serif
+preferableHeaderWeightFont=bold

Added: trunk/samples/effect-sample/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- trunk/samples/effect-sample/src/main/webapp/META-INF/MANIFEST.MF	                        (rev 0)
+++ trunk/samples/effect-sample/src/main/webapp/META-INF/MANIFEST.MF	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+

Added: trunk/samples/effect-sample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/effect-sample/src/main/webapp/WEB-INF/faces-config.xml	                        (rev 0)
+++ trunk/samples/effect-sample/src/main/webapp/WEB-INF/faces-config.xml	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
+                              "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
+<faces-config>
+ <managed-bean>
+  <managed-bean-name>bean</managed-bean-name>
+  <managed-bean-class>demo.Bean</managed-bean-class>
+  <managed-bean-scope>request</managed-bean-scope>
+  <managed-property>
+   <property-name>zoom</property-name>
+   <property-class>java.lang.String</property-class>
+   <value>10</value>
+  </managed-property>
+ </managed-bean>
+</faces-config>

Added: trunk/samples/effect-sample/src/main/webapp/WEB-INF/faces-config.xml.l4t
===================================================================
--- trunk/samples/effect-sample/src/main/webapp/WEB-INF/faces-config.xml.l4t	                        (rev 0)
+++ trunk/samples/effect-sample/src/main/webapp/WEB-INF/faces-config.xml.l4t	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PROCESS ENTITY="JSFProcess">
+ <PROCESS-ITEM ENTITY="JSFProcessGroup" NAME="rules:#panel.xhtml"
+  PATH="/panel.xhtml" SHAPE="98,111,0,0" persistent="true"/>
+ <PROCESS-ITEM ENTITY="JSFProcessGroup" NAME="rules:#gmap.xhtml"
+  PATH="/gmap.xhtml" SHAPE="63,198,0,0" persistent="true"/>
+</PROCESS>

Added: trunk/samples/effect-sample/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/effect-sample/src/main/webapp/WEB-INF/web.xml	                        (rev 0)
+++ trunk/samples/effect-sample/src/main/webapp/WEB-INF/web.xml	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,66 @@
+<?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">
+ <description>Richfaces Effect Sample</description>
+ <display-name>effect-sample</display-name>
+ <context-param>
+  <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+  <param-value>.xhtml</param-value>
+ </context-param>
+ <context-param>
+  <param-name>facelets.REFRESH_PERIOD</param-name>
+  <param-value>2</param-value>
+ </context-param>
+ <context-param>
+  <param-name>facelets.DEVELOPMENT</param-name>
+  <param-value>true</param-value>
+ </context-param>
+ <context-param>
+  <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+  <param-value>client</param-value>
+ </context-param>
+ <context-param>
+  <param-name>com.sun.faces.validateXml</param-name>
+  <param-value>true</param-value>
+ </context-param>
+ <context-param>
+  <param-name>com.sun.faces.verifyObjects</param-name>
+  <param-value>true</param-value>
+ </context-param>
+ <context-param>
+  <param-name>org.ajax4jsf.SKIN</param-name>
+  <param-value>japanCherry</param-value>
+ </context-param>
+ <context-param>
+  <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
+  <param-value>com.sun.facelets.FaceletViewHandler</param-value>
+ </context-param>
+ <context-param>
+     <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
+     <param-value>false</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>FORWARD</dispatcher>
+  <dispatcher>REQUEST</dispatcher>
+  <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+ <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>
+ <login-config>
+  <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>

Added: trunk/samples/effect-sample/src/main/webapp/effect.xhtml
===================================================================
--- trunk/samples/effect-sample/src/main/webapp/effect.xhtml	                        (rev 0)
+++ trunk/samples/effect-sample/src/main/webapp/effect.xhtml	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,79 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core"
+      xmlns:c="http://java.sun.com/jstl/core"
+      xmlns:e="http://labs.jboss.com/jbossrichfaces/ui/effect"
+      xmlns:a4j="http://richfaces.org/a4j">
+
+  <f:view contentType="text/html" >
+
+  	<body>
+  
+        <script>
+                 ma = 1.4;
+        </script>
+        <h:outputText value="Non-JSF tags:" />
+	<span onclick="hideIt()">Hide</span>
+	<span onclick="showIt()">Show</span>
+
+	<div id="my" style="width:100px;height:100px;background-color:lightblue">&nbsp;</div>
+
+	<e:effect for="my" name="hideIt" type="Fade"/>
+	<e:effect  for="my" name="showIt" type="Appear"/>
+
+	<br/><br/>
+
+        <h:outputText value="JSF Component:" />
+
+	<span onclick="hideItJ()">Hide</span>
+	<span onclick="showItJ()">Show</span>
+
+	<h:form id="myform">
+	        <h:panelGrid id="mypanel" border="1" style="background-color:#CCC">
+			<f:facet name="header">
+			        <h:outputText value="Panel Header" />
+			</f:facet>
+	
+		        <h:outputText value="Panel Content" />
+		</h:panelGrid>
+	</h:form>
+
+	<e:effect for="mypanel" name="hideItJ" type="Fade" params="duration:ma"/>
+	<e:effect  for="mypanel" name="showItJ" type="Appear"/>
+
+        <h:outputText value="JSF Component with Event:" />
+
+	<h:form id="myform2">
+	        <h:panelGrid id="mypanel2" border="1" style="background-color:#CCC">
+	<e:effect event="onclick" type="Opacity" params="duration:0.5,from:0.4,to:1.0"/>
+	<e:effect event="onmouseout"  type="Opacity" params="duration:0.5,from:1.0,to:0.4"/>
+			<f:facet name="header">
+			        <h:outputText value="Panel Header" />
+			</f:facet>
+	
+		        <h:outputText value="Panel Content" />
+		</h:panelGrid>
+	</h:form>
+
+
+
+        <h:outputText value="Using function parameters:" />
+
+	<span onclick="Richfaces.hideItP({id:'mynewpanel'})">Hide</span>
+	<span onclick="Richfaces.showItP({id:'mynewpanel', type:'Appear', duration:2.5})">Show</span>
+
+	<div id="mynewpanel" style="width:100px;height:100px;background-color:lightblue">&nbsp;</div>
+
+	<e:effect name="Richfaces.hideItP" onmouseover="Richfaces.hideItP({id:'mynewpanel'})" type="Opacity" params="duration:0.8, from:1.0, to:0.2" />
+	<e:effect name="Richfaces.showItP" />
+
+
+         <div style="margin:10px;"><a href='javascript:void(0)'
+          onclick='new Effect["Opacity"]( document.getElementById("mynewpanel"),{duration:0.8, from:1.0, to:0.2} );'>Click for Demo!</a><br /></div>
+
+
+	</body>
+</f:view>
+</html>

Added: trunk/samples/effect-sample/src/main/webapp/index.jsp
===================================================================
--- trunk/samples/effect-sample/src/main/webapp/index.jsp	                        (rev 0)
+++ trunk/samples/effect-sample/src/main/webapp/index.jsp	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,7 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head></head>
+	<body>
+		<jsp:forward page="effect.jsf" />
+	</body>
+</html>
\ No newline at end of file

Added: trunk/ui/effect/pom.xml
===================================================================
--- trunk/ui/effect/pom.xml	                        (rev 0)
+++ trunk/ui/effect/pom.xml	2007-08-07 23:37:19 UTC (rev 2124)
@@ -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.1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.richfaces.ui</groupId>
+  <artifactId>effect</artifactId>
+  <name>Effect</name>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.richfaces.cdk</groupId>
+        <artifactId>maven-cdk-plugin</artifactId>
+	    <version>3.1.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>effect</shortName>
+            </taglib>
+          </library>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+  </dependencies>
+</project>
\ No newline at end of file

Added: trunk/ui/effect/src/main/config/component/effect.xml
===================================================================
--- trunk/ui/effect/src/main/config/component/effect.xml	                        (rev 0)
+++ trunk/ui/effect/src/main/config/component/effect.xml	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,61 @@
+<?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.Effect</name>
+		<family>org.richfaces.Effect</family>
+		<classname>org.richfaces.component.html.HtmlEffect</classname>
+		<superclass>org.richfaces.component.UIEffect</superclass>
+		<description>
+			<![CDATA[
+			It presents the google map in JSF applications
+            ]]>
+		</description>
+		<test />
+		<renderer generate="true" override="true">
+			<name>org.richfaces.EffectRenderer</name>
+			<template>effect.jspx</template>
+		</renderer>
+		<tag>
+			<name>effect</name>
+			<classname>org.richfaces.taglib.EffectTag</classname>
+			<superclass>
+				org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+			</superclass>
+		</tag>
+		&ui_component_attributes;
+		<property>
+			<name>name</name>
+			<classname>java.lang.String</classname>
+			<description>
+			  Generated Javascript name.
+			</description>
+			<defaultvalue>""</defaultvalue>
+		</property>
+		<property>
+			<name>for</name>
+			<classname>java.lang.String</classname>
+			<description>
+			  Id of the target component.
+			</description>
+			<defaultvalue>""</defaultvalue>
+		</property>
+		<property>
+			<name>params</name>
+			<classname>java.lang.String</classname>
+			<description>
+			  Parameters passed to the effect function.
+			  Example params="{id:'foo',type:'Fade'}"
+			</description>
+			<defaultvalue>""</defaultvalue>
+		</property>
+		<property el="false" >
+			<name>event</name>
+			<classname>java.lang.String</classname>
+			<description>
+			  Event of the parent
+			</description>
+			<defaultvalue>""</defaultvalue>
+		</property>
+	</component>
+</components>

Added: trunk/ui/effect/src/main/java/org/richfaces/component/UIEffect.java
===================================================================
--- trunk/ui/effect/src/main/java/org/richfaces/component/UIEffect.java	                        (rev 0)
+++ trunk/ui/effect/src/main/java/org/richfaces/component/UIEffect.java	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,117 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - 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 org.ajax4jsf.Messages;
+import org.ajax4jsf.component.EventValueBinding;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import org.ajax4jsf.component.AjaxSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * JSF component class
+ *
+ */
+public abstract class UIEffect extends UIComponentBase implements AjaxSupport {
+	
+	public static final String COMPONENT_TYPE = "org.richfaces.Effect";
+	
+	private static final String COMPONENT_FAMILY = "org.richfaces.Effect";
+
+       	private static final Log log = LogFactory.getLog(UIEffect.class);
+
+
+    /**
+     * @return JavaScript eventString. Rebuild on every call, since
+     * can be in loop ( as in dataTable ) with different parameters.
+     */
+    public String getEventString()
+    {
+        StringBuffer buildOnEvent = new StringBuffer();
+/*
+        String onsubmit = getOnsubmit();
+        // Insert script to call before submit ajax request.
+        if (null != onsubmit) {
+			buildOnEvent.append(onsubmit).append(";");
+		}
+        // Due to JSF RI 1.1 bug, clear cached clientId
+        setId(getId());
+		buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this, getFacesContext(),
+				                getEvent()));
+		String script = buildOnEvent.toString();
+*/
+                buildOnEvent.append("Richfaces.processEffect(this,'");
+                buildOnEvent.append(getType());
+		buildOnEvent.append("',{},'{");
+		buildOnEvent.append(getParams());
+		buildOnEvent.append("}')");
+		return buildOnEvent.toString();
+    }
+
+    public abstract String getEvent();
+
+    public abstract String getFor();
+    public abstract void setFor(String value);
+
+    public abstract void setEvent(String event);
+
+    public abstract String getType();
+    public abstract void setType(String value);
+
+    public abstract String getParams();
+    public abstract void setParams(String value);
+    /**
+     * After nornal setting <code>parent</code> property in case of
+     * created component set Ajax properties for parent.
+     * @see javax.faces.component.UIComponentBase#setParent(javax.faces.component.UIComponent)
+     */
+    public void setParent(UIComponent parent)
+    {
+        super.setParent(parent);
+        if (null != parent && parent.getFamily() != null ) {
+			if (log.isDebugEnabled()) {
+				log.debug(Messages.getMessage(Messages.CALLED_SET_PARENT, parent.getClass().getName()));
+			}
+			// TODO If this comopnent configured, set properties for parent component.
+			// NEW created component have parent, restored view - null in My faces.
+			// and SUN RI not call at restore saved view.
+			// In other case - set in restoreState method.
+			//        if (parent.getParent() != null)
+			{
+				if (log.isDebugEnabled()) {
+					log.debug(Messages.getMessage(Messages.DETECT_NEW_COMPONENT));
+				}
+				setParentProperties(parent);
+
+			}
+		}
+    }
+
+
+   public void setParentProperties(UIComponent parent){
+   	if (getFor() == null || getFor() == "" ) {
+	   	parent.setValueBinding(getEvent(), new EventValueBinding(this));
+	}
+   }	
+}

Added: trunk/ui/effect/src/main/resources/org/richfaces/renderkit/html/script/processEffect.js
===================================================================
--- trunk/ui/effect/src/main/resources/org/richfaces/renderkit/html/script/processEffect.js	                        (rev 0)
+++ trunk/ui/effect/src/main/resources/org/richfaces/renderkit/html/script/processEffect.js	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,6 @@
+if (!window.Richfaces) {
+window.Richfaces = {};
+}
+Richfaces.processEffect = new Function("cid","etype","aparam","param",
+"var h=Object.extend(param.evalJSON(), aparam);"+
+"new Effect[h.type||etype]($(h.id||cid),h);");

Added: trunk/ui/effect/src/main/templates/effect.jspx
===================================================================
--- trunk/ui/effect/src/main/templates/effect.jspx	                        (rev 0)
+++ trunk/ui/effect/src/main/templates/effect.jspx	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,50 @@
+<?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.EffectRenderer"
+	baseclass="org.ajax4jsf.renderkit.HeaderResourcesRendererBase"
+	component="org.richfaces.component.UIEffect">
+	<f:clientid var="clientId"/>
+	
+
+	<c:set var="for" value="#{component.attributes['for']}"/>
+	<c:set var="event" value="#{component.attributes['event']}"/>
+	<c:set var="name" value="#{component.attributes['name']}"/>
+	<c:set var="type" value="#{component.attributes['type']}"/>
+	<c:set var="params" value="#{component.attributes['params']}"/>
+	<h:scripts>new org.ajax4jsf.javascript.PrototypeScript(),scripts/scriptaculous/scriptaculous.js,scripts/scriptaculous/effects.js,/org/richfaces/renderkit/html/script/processEffect.js</h:scripts>
+         
+
+<jsp:scriptlet>
+		<![CDATA[
+		                String  sid = (String)variables.getVariable("for");
+		                if (! "".equals(sid)) {
+	                                UIComponent forcomp = getUtils().findComponentFor(context, (UIComponent)component,sid);
+        	                        if (forcomp != null) {
+						variables.setVariable("forid",forcomp.getClientId(context));
+	                                } else {
+	 	                              	// if no corresponded component id,  may be it is non-jsf id. 
+	        	                        // So, returning the id as is
+	                	                variables.setVariable("forid",sid);	
+	                                }
+				}
+                                String name = (String)variables.getVariable("name");
+                                variables.setVariable("needsFunction",new Boolean(! "".equals(name)));	
+        			]]>
+				
+</jsp:scriptlet>
+<c:if test="#{needsFunction}">
+
+<script type="text/javascript"
+			x:passThruWithExclusions="name,type,for"
+			>
+ //<![CDATA[
+#{name} = new Function("Richfaces.processEffect('#{forid}','#{type}',arguments[0]||{}, '{#{params}}');");
+//]]>
+</script>
+</c:if>
+</f:root>
\ No newline at end of file

Added: trunk/ui/effect/src/test/java/org/richfaces/component/EffectComponentTest.java
===================================================================
--- trunk/ui/effect/src/test/java/org/richfaces/component/EffectComponentTest.java	                        (rev 0)
+++ trunk/ui/effect/src/test/java/org/richfaces/component/EffectComponentTest.java	2007-08-07 23:37:19 UTC (rev 2124)
@@ -0,0 +1,132 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces 3.0 - 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 EffectComponentTest extends AbstractAjax4JsfTestCase {
+	private UIForm form = null;
+    private UIComponent effect = null;
+    private static Set javaScripts = new HashSet();
+    
+
+
+    static {
+	    javaScripts.add("org.ajax4jsf.javascript.PrototypeScript");
+	    javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+	    javaScripts.add("script/effect.js");
+	    javaScripts.add("http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5");
+    }
+    
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public EffectComponentTest( String testName )
+    {
+        super( testName );
+    }
+
+    public void setUp() throws Exception {
+    	super.setUp();
+    	form = new HtmlForm();
+    	facesContext.getViewRoot().getChildren().add(form);
+    	
+    	effect = application.createComponent(UIEffect.COMPONENT_TYPE);
+    	effect.setId("effect");
+    	
+    	effect.getAttributes().put("var", "testEffect");
+    	
+    	form.getChildren().add(effect);
+    }
+    
+    public void tearDown() throws Exception {
+       	super.tearDown();
+       	effect = null;
+       	form = null;
+    }
+    
+    public void testRenderComponent() throws Exception {
+    	HtmlPage renderedView = renderView();
+    	
+    	HtmlElement htmlEffect = renderedView.getHtmlElementById(effect.getClientId(facesContext));
+    	
+    	assertNotNull(htmlEffect);
+    	assertTrue("div".equals(htmlEffect.getTagName()));
+
+//    	assertTrue(htmlEffect.getAttributeValue("class").contains("dr-ve"));
+//    	assertTrue(htmlEffect.getAttributeValue("class").contains("rich-effect"));
+
+    }
+    
+    public void testRenderStyle() throws Exception {
+        HtmlPage page = renderView();
+        assertNotNull(page);
+        
+        List links = page.getDocumentElement().getHtmlElementsByTagName("link");
+        assertEquals(1, links.size());
+        
+    }
+    
+    public void testRenderScript() throws Exception {
+        HtmlPage page = renderView();
+        assertNotNull(page);
+        List scripts = page.getDocumentElement().getHtmlElementsByTagName("script");
+        for (Iterator it = scripts.iterator(); it.hasNext();) {
+            HtmlScript item = (HtmlScript) it.next();
+            String srcAttr = item.getSrcAttribute();
+
+            if (StringUtils.isNotBlank(srcAttr)) {
+                boolean found = false;
+                for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();) {
+                    String src = (String) srcIt.next();
+
+                    found = srcAttr.contains(src);
+                    if (found) {
+                        break;
+                    }
+                }
+
+                assertTrue(found);
+            }
+        }
+    }
+
+}




More information about the richfaces-svn-commits mailing list