Author: d.bulahov
Date: 2007-04-27 08:50:58 -0400 (Fri, 27 Apr 2007)
New Revision: 584
Added:
trunk/sandbox/simpleTogglePanel2/
trunk/sandbox/simpleTogglePanel2/.svnignore
trunk/sandbox/simpleTogglePanel2/pom.xml
trunk/sandbox/simpleTogglePanel2/pom.xml.prev
trunk/sandbox/simpleTogglePanel2/src/
trunk/sandbox/simpleTogglePanel2/src/main/
trunk/sandbox/simpleTogglePanel2/src/main/config/
trunk/sandbox/simpleTogglePanel2/src/main/config/component/
trunk/sandbox/simpleTogglePanel2/src/main/config/component/README
trunk/sandbox/simpleTogglePanel2/src/main/config/component/simpleTogglePanel2.xml
trunk/sandbox/simpleTogglePanel2/src/main/java/
trunk/sandbox/simpleTogglePanel2/src/main/java/org/
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/component/
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/component/README
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/component/UISimpleTogglePanel2.java
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/event/
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/event/SimpleToggle2Event.java
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/renderkit/
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/renderkit/html/
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanel2Renderer.java
trunk/sandbox/simpleTogglePanel2/src/main/resources/
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/css/
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/css/simpleTogglePanel2.xcss
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/scripts/
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel2.js
trunk/sandbox/simpleTogglePanel2/src/main/templates/
trunk/sandbox/simpleTogglePanel2/src/main/templates/README
trunk/sandbox/simpleTogglePanel2/src/main/templates/simpleTogglePanel2.jspx
trunk/sandbox/simpleTogglePanel2/src/test/
trunk/sandbox/simpleTogglePanel2/src/test/java/
trunk/sandbox/simpleTogglePanel2/src/test/java/org/
trunk/sandbox/simpleTogglePanel2/src/test/java/org/richfaces/
trunk/sandbox/simpleTogglePanel2/src/test/java/org/richfaces/component/
trunk/sandbox/simpleTogglePanel2/src/test/java/org/richfaces/component/SimpleToggle2EventTest.java
Log:
Added: trunk/sandbox/simpleTogglePanel2/.svnignore
===================================================================
--- trunk/sandbox/simpleTogglePanel2/.svnignore (rev 0)
+++ trunk/sandbox/simpleTogglePanel2/.svnignore 2007-04-27 12:50:58 UTC (rev 584)
@@ -0,0 +1,4 @@
+target
+.project
+.classpath
+.settings
Added: trunk/sandbox/simpleTogglePanel2/pom.xml
===================================================================
--- trunk/sandbox/simpleTogglePanel2/pom.xml (rev 0)
+++ trunk/sandbox/simpleTogglePanel2/pom.xml 2007-04-27 12:50:58 UTC (rev 584)
@@ -0,0 +1,50 @@
+<?xml version="1.0"?><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>richfaces-parent</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.0.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces</groupId>
+ <artifactId>simpleTogglePanel2</artifactId>
+ <name>Toggle panel</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.ajax4jsf.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>1.1.1-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>simpleTogglePanel2</shortName>
+ </taglib>
+ </library>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/sandbox/simpleTogglePanel2/pom.xml.prev
===================================================================
--- trunk/sandbox/simpleTogglePanel2/pom.xml.prev (rev 0)
+++ trunk/sandbox/simpleTogglePanel2/pom.xml.prev 2007-04-27 12:50:58 UTC (rev 584)
@@ -0,0 +1,42 @@
+<?xml version="1.0"?><project>
+ <parent>
+ <artifactId>richfaces-parent</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces</groupId>
+ <artifactId>simpleTogglePanel</artifactId>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.ajax4jsf.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>1.1.0</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <library>
+ <prefix>org.richfaces</prefix>
+ <taglib>
+ <shortName>simpleTogglePanel</shortName>
+ </taglib>
+ </library>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/sandbox/simpleTogglePanel2/src/main/config/component/README
===================================================================
Added: trunk/sandbox/simpleTogglePanel2/src/main/config/component/simpleTogglePanel2.xml
===================================================================
--- trunk/sandbox/simpleTogglePanel2/src/main/config/component/simpleTogglePanel2.xml
(rev 0)
+++
trunk/sandbox/simpleTogglePanel2/src/main/config/component/simpleTogglePanel2.xml 2007-04-27
12:50:58 UTC (rev 584)
@@ -0,0 +1,98 @@
+<?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.SimpleTogglePanel2</name>
+ <family>org.richfaces.SimpleTogglePanel2</family>
+
<classname>org.richfaces.component.html.HtmlSimpleTogglePanel2</classname>
+
<superclass>org.richfaces.component.UISimpleTogglePanel2</superclass>
+ <test>
+ <classname>org.richfaces.component.html.HtmlSimpleTogglePanel2ComponentTest</classname>
+ <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
+ </test>
+ <description>
+ <![CDATA[Wrapper component with named facets. Every facet will be shown
after activation
+ corresponding toggleControl(the other will be hidden).
+ ]]>
+ </description>
+ <renderer generate="true" override="true">
+ <name>org.richfaces.SimpleTogglePanel2Renderer</name>
+ <template>simpleTogglePanel2.jspx</template>
+ </renderer>
+ <tag>
+ <name>simpleTogglePanel</name>
+
<classname>org.richfaces.taglib.SimpleTogglePanel2Tag</classname>
+ <superclass>
+ org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ </superclass>
+ </tag>
+
+ &ui_component_attributes;
+ &html_events;
+ &html_style_attributes;
+
+ &ui_command_attributes;
+ &ajax_component_attributes;
+ &html_event_handler_attributes;
+
+ <property>
+ <name>width</name>
+ <classname>java.lang.String</classname>
+ <description>Width of a simple toggle panel might be defined as pixels or in
percents.
+ By default width is not defined
+ </description>
+ <defaultvalue><![CDATA["100%"]]></defaultvalue>
+ </property>
+
+ <property>
+ <name>height</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Height of a simple toggle panel content area might be defined as pixels or in
percents.
+ By default height is not defined
+ </description>
+ </property>
+
+ <property>
+ <name>headerClass</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Class that defines the style for panel header
+ </description>
+ </property>
+
+ <property>
+ <name>bodyClass</name>
+ <classname>java.lang.String</classname>
+ <description>
+ A class that defines a style for a panel header
+ </description>
+ </property>
+
+ <property required="false">
+ <name>switchType</name>
+ <classname>java.lang.String</classname>
+ <description>
+ <![CDATA[Facets switch algorithm: "client",
"server"(default), "ajax".]]>
+ </description>
+ </property>
+ <property required="false" el="true"
elonly="true">
+ <name>label</name>
+ <classname>java.lang.String</classname>
+ <description>Marker to be rendered on a panel header
+
+ </description>
+ </property>
+
+ <property required="false">
+ <name>opened</name>
+ <classname>boolean</classname>
+ <description>
+ A false value for this attribute makes a panel closed as default
+ </description>
+ <defaultvalue>true</defaultvalue>
+ </property>
+
+
+ </component>
+</components>
Added: trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/component/README
===================================================================
Added:
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/component/UISimpleTogglePanel2.java
===================================================================
---
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/component/UISimpleTogglePanel2.java
(rev 0)
+++
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/component/UISimpleTogglePanel2.java 2007-04-27
12:50:58 UTC (rev 584)
@@ -0,0 +1,78 @@
+/**
+ * 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.framework.ajax.AjaxActionComponent;
+import org.ajax4jsf.framework.ajax.AjaxComponent;
+import org.ajax4jsf.framework.ajax.AjaxSource;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+
+import javax.faces.component.ActionSource;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+
+
+/**
+ * JSF component class
+ */
+public abstract class UISimpleTogglePanel2 extends AjaxActionComponent implements
AjaxComponent, AjaxSource, ActionSource
+//public abstract class UISimpleTogglePanel extends UIInput implements AjaxComponent,
AjaxSource, ActionSource
+{
+
+ public static final String COMPONENT_FAMILY = "javax.faces.Command";
+ public static final String SERVER_SWITCH_TYPE = "server";
+ public static final String CLIENT_SWITCH_TYPE = "client";
+ public static final String AJAX_SWITCH_TYPE = "ajax";
+ public static final boolean COLLAPSED = false;
+ public static final boolean EXPANDED = true;
+
+ //xxxx by nick - why properties here? just describe them in config and CDK generates
+ //valid fields & save/restore code
+ //for "public" (.tld etc.) properties you should create abstract
getters/setters only
+
+ //xxxx by nick - according to JavaDocs
http://webdownload.exadel.com/downloads/ajax4jsf/documentation/javaAPI/or...
+ //AjaxActionComponent already has immediate property
+
+
+ public abstract void setSwitchType(String switchType);
+
+ public abstract String getSwitchType();
+
+ public abstract void setOpened(boolean opened);
+
+ public abstract boolean isOpened();
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ //public void broadcast(FacesEvent facesEvent) throws AbortProcessingException {
+ // super.broadcast(facesEvent);
+ // FacesContext facesContext = FacesContext.getCurrentInstance();
+ // if (AjaxRendererUtils.isAjaxRequest(facesContext) &&
this.getSwitchType().equals(AJAX_SWITCH_TYPE)) {
+ // AjaxRendererUtils.addRegionByName(facesContext,
+ // this,
+ // this.getId());
+ // }
+ //}
+}
Added:
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java
===================================================================
---
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java
(rev 0)
+++
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/event/ISimpleToggle2Listener.java 2007-04-27
12:50:58 UTC (rev 584)
@@ -0,0 +1,38 @@
+/**
+ * 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
+ */
+
+/*
+ * Created on 11.07.2006
+ */
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author igels
+ */
+
+//TODO by nick - denis - add addToggleListener method to component
+public interface ISimpleToggle2Listener extends FacesListener {
+
+ public void processToggle(SimpleToggle2Event event);
+
+}
\ No newline at end of file
Added:
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/event/SimpleToggle2Event.java
===================================================================
---
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/event/SimpleToggle2Event.java
(rev 0)
+++
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/event/SimpleToggle2Event.java 2007-04-27
12:50:58 UTC (rev 584)
@@ -0,0 +1,76 @@
+/**
+ * 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
+ */
+
+/*
+ * Created on 11.07.2006
+ */
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author igels
+ */
+public class SimpleToggle2Event extends ActionEvent {
+
+ private static final long serialVersionUID = 5582624805941635421L;
+ private boolean _opened;
+
+ /**
+ * @param source
+ * @param opened
+ */
+ public SimpleToggle2Event(UIComponent source, boolean opened) {
+ super(source);
+ this._opened = opened;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof ISimpleToggle2Listener;
+ }
+
+ /* (non-Javadoc)
+ * @see
javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ ((ISimpleToggle2Listener) listener).processToggle(this);
+ }
+
+ /**
+ * @return Returns the _state.
+ */
+ public boolean isIsOpen() {
+ return _opened;
+ }
+
+ /**
+ *
+ * @param opened The state to set
+ */
+ public void setIsOpen(boolean opened) {
+ this._opened = opened;
+ }
+}
\ No newline at end of file
Added:
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanel2Renderer.java
===================================================================
---
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanel2Renderer.java
(rev 0)
+++
trunk/sandbox/simpleTogglePanel2/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanel2Renderer.java 2007-04-27
12:50:58 UTC (rev 584)
@@ -0,0 +1,184 @@
+/**
+ * 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
+ */
+
+/*
+ * Created on 04.07.2006
+ */
+package org.richfaces.renderkit.html;
+
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.richfaces.component.UISimpleTogglePanel2;
+import org.richfaces.event.SimpleToggle2Event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.PhaseId;
+import java.io.IOException;
+import java.util.Map;
+
+//public class SimpleTogglePanelRenderer extends AjaxCommandLinkRenderer {
+
+public class SimpleTogglePanel2Renderer extends
org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase {
+ //XXXX by nick - denis - seems there is a lot of code common to
org.richfaces.renderkit.html.ToggleControlRenderer. Please commonize!
+ //private InternetResource[] _scripts = {new PrototypeScript(),
getResource("scripts/simpleTogglePanel.js") };
+
+ protected Class getComponentClass() {
+ return UISimpleTogglePanel2.class;
+ }
+
+ //XXXX by nick - denis - move scripts to template
+ //protected InternetResource[] getAdditionalScripts() {
+ // return _scripts;
+ //}
+
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ public void doDecode(FacesContext context, UIComponent component) {
+
+ super.doDecode(context, component);
+
+
+ ExternalContext exCtx = context.getExternalContext();
+
+ Map rqMap = exCtx.getRequestParameterMap();
+ Object clnId = rqMap.get(component.getClientId(context));
+ UISimpleTogglePanel2 panel = (UISimpleTogglePanel2) component;
+
+ if (clnId != null) {
+ // enqueue event here for this component or for component with Id
+ // taken fro forId attribute
+
+ String switchType = panel.getSwitchType();
+ if (!(UISimpleTogglePanel2.CLIENT_SWITCH_TYPE.equals(switchType))) {
+
+ //xxxx by nick - denis - use constants, please!
+ if ((panel.isOpened() == UISimpleTogglePanel2.EXPANDED)) {
+ panel.setOpened(UISimpleTogglePanel2.COLLAPSED);
+ } else {
+ //xxxx by nick - denis - use constants, please!
+ panel.setOpened(UISimpleTogglePanel2.EXPANDED);
+ }
+ SimpleToggle2Event event = new SimpleToggle2Event(panel,
(panel.isOpened()));
+ if (panel.isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ event.queue();
+
+ } else {
+ if (panel.isOpened()!= new Boolean((String) clnId).booleanValue()){
+ SimpleToggle2Event event = new SimpleToggle2Event(panel,
(panel.isOpened()));
+ if (panel.isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ event.queue();
+ }
+ panel.setOpened(new Boolean((String) clnId).booleanValue());
+ }
+
+
+
+ }
+
+
+ if (AjaxRendererUtils.isAjaxRequest(context) &&
panel.getSwitchType().equals(UISimpleTogglePanel2.AJAX_SWITCH_TYPE)) {
+ AjaxRendererUtils.addRegionByName(context,
+ panel,
+ panel.getId());
+ }
+
+
+ }
+
+ public String getdivdisplay(FacesContext context, UIComponent component) {
+
+ String Switch = Boolean.toString(((UISimpleTogglePanel2) component).isOpened());
+ if (Switch == null ||
Switch.equals(Boolean.toString(UISimpleTogglePanel2.EXPANDED)))
+ {
+ //xxxx by nick - denis - do not set "block" explicitly - that can
break some elements, set "" for display. See Element.show() in prototype.js
+ return "";
+ }
+ return "none";
+ }
+
+ public String getOnClick(FacesContext context, UIComponent component) {
+ UISimpleTogglePanel2 tgComp = (UISimpleTogglePanel2) component;
+
+ String switchType = tgComp.getSwitchType();
+ StringBuffer onClick = new StringBuffer();
+ //String userOnClick =
(String)component.getAttributes().get("onclick");
+ //if(userOnClick!=null) {
+ // onClick.append(userOnClick);
+ // if(!userOnClick.trim().endsWith(";")) {
+ // onClick.append("; ");
+ // }
+ //}
+
+
+ if (UISimpleTogglePanel2.CLIENT_SWITCH_TYPE.equals(switchType)) {
+ // Client
+ String panelId = tgComp.getClientId(context);
+ onClick.append("SimpleTogglePanelManager.toggleOnClient('")
+ .append(panelId)
+ .append("');");
+ } else if (UISimpleTogglePanel2.AJAX_SWITCH_TYPE.equals(switchType)) {
+ // Ajax
+ //
writer.writeAttribute(HTML.onclick_ATTRIBUTE,AjaxRendererUtils.buildOnClick(tab,context),"ajaxOnclick");
+ onClick.append(AjaxRendererUtils.buildOnClick(component, context));
+ //return super.getOnClick(context, component);
+ } else {
+ // Server
+
+
+ onClick.append("SimpleTogglePanelManager.toggleOnServer('")
+ .append(component.getClientId(context))
+ .append("'")
+
+
+ .append(");");
+ //.append(tgComp.getSwitch()==null?"'0'":"'"
+ tgComp.getSwitch() + "'")
+ //.append("")
+ }
+ return onClick.toString();
+ }
+
+ protected String getValueAsString(FacesContext context, UISimpleTogglePanel2 Panel)
{
+ return getUtils().getValueAsString(context, Panel);
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ // TODO Auto-generated method stub
+ UISimpleTogglePanel2 comp = (UISimpleTogglePanel2) component;
+ //xxxx by nick - denis - use constants, please!
+ if (!(((comp.getSwitchType() == null) ||
(comp.getSwitchType().equals(UISimpleTogglePanel2.CLIENT_SWITCH_TYPE) != true)) &&
(comp.isOpened() == UISimpleTogglePanel2.COLLAPSED)))
+ {
+ super.encodeChildren(context, component);
+ }
+ }
+}
\ No newline at end of file
Added:
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/css/simpleTogglePanel2.xcss
===================================================================
---
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/css/simpleTogglePanel2.xcss
(rev 0)
+++
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/css/simpleTogglePanel2.xcss 2007-04-27
12:50:58 UTC (rev 584)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template
xmlns:f='http:/jsf.exadel.com/template'
+
xmlns:u='http:/jsf.exadel.com/template/util'
+
xmlns="http://www.w3.org/1999/xhtml" >
+
+<f:verbatim><![CDATA[
+.dr-stglpnl{
+ border : 1px solid #678FC5;
+ background-color : #BFD0E9;
+ padding : 1px;
+ background-position : top right;
+ background-repeat : no-repeat;
+}
+
+
+.dr-stglpnl-h{
+ border-width: 1px;
+ border-style: solid;
+ background-color : #224986;
+ font-size : 11px;
+ color : #ffffff;
+ cursor: pointer;
+ font-weight : bold;
+ font-family : verdana;
+ padding : 2px;
+ background-image : url(coll_panel_bg.gif);
+ background-position : top left;
+ background-repeat : repeat-x;
+}
+
+
+.dr-stglpnl-b{
+ font-size : 11px;
+ color : #000000;
+ font-family : verdana;
+ padding : 10px;
+ text-align : left;
+ vertical-align : top;
+}
+]]>
+
+</f:verbatim>
+
+<u:selector name=".dr-stglpnl">
+ <u:style name="background-color" skin="generalBackgroundColor"
/>
+ <u:style name="border-color" skin="panelBorderColor" />
+</u:selector>
+<u:selector name=".dr-stglpnl-h">
+ <u:style name="background-color" skin="headerBackgroundColor"
/>
+ <u:style name="border-color" skin="headerBackgroundColor"
/>
+ <u:style name="font-size" skin="headerSizeFont" />
+ <u:style name="color" skin="headerTextColor" />
+ <u:style name="font-weight" skin="headerWeightFont" />
+ <u:style name="font-family" skin="headerFamilyFont" />
+</u:selector>
+<u:selector name=".dr-stglpnl-b">
+ <u:style name="background-color" skin="generalBackgroundColor"
/>
+ <u:style name="font-size" skin="generalSizeFont" />
+ <u:style name="color" skin="panelTextColor" />
+ <u:style name="font-family" skin="generalFamilyFont" />
+</u:selector>
+<u:selector name=".dr-stglpnl-h">
+ <u:style name="background-image" >
+ <f:resource f:key="org.richfaces.renderkit.html.GradientA"/>
+ </u:style>
+</u:selector>
+
+</f:template>
Added:
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel2.js
===================================================================
---
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel2.js
(rev 0)
+++
trunk/sandbox/simpleTogglePanel2/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel2.js 2007-04-27
12:50:58 UTC (rev 584)
@@ -0,0 +1,105 @@
+
+SimpleTogglePanel = Class.create();
+
+SimpleTogglePanel.prototype = {
+ initialize: function(panelId, status, openSign, closeSign) {
+
+ this.panelId = panelId;
+ this.panelId_head = panelId+"_header";
+ this.status = status;
+ if (!this.status){
+ this.status="true";
+ }
+
+ this.openSign = openSign;
+ if (!this.openSign) {
+ this.openSign = "»";
+ }
+
+ this.closeSign = closeSign;
+ if (!this.closeSign) {
+ this.closeSign = "«";
+ }
+
+ //this.divs = divs;
+ //this.currentId = initialStateId;
+ //this.toggleToState();
+// this.windowOnLoad();
+ this.timer = setTimeout(this.windowOnLoad.bind(this), 100);
+
+ },
+
+ windowOnLoad: function(){
+ if (RichFaces.navigatorType() == "MSIE"){
+ //var body = $(this.panelId+"_body");
+ //if (body && body.style.display!="none")
body.firstChild.style.width=body.clientWidth;
+/* if ($(this.panelId_head).clientWidth<$(this.panelId).clientWidth){
+
$(this.panelId_head).style.width=$(this.panelId).clientWidth-2+"px";
+ }*/
+ }
+ },
+
+ toggleToState: function() {
+ var body = $(this.panelId+"_body");
+ if (this.status=="false"){
+ Element.show(body);
+ this.status="true";
+ $(this.panelId+"_switch").innerHTML = this.closeSign;
+ this.timer = setTimeout(this.windowOnLoad.bind(this), 100);
+// body.firstChild.style.width=body.clientWidth;
+ }
+
+ else{
+ Element.hide(body);
+ body.firstChild.style.width="100%";
+ this.status="false";
+ $(this.panelId+"_switch").innerHTML = this.openSign;
+
+ }
+ if (RichFaces.navigatorType() == "MSIE"){
+/* if ($(this.panelId_head).clientWidth<$(this.panelId).clientWidth){
+
$(this.panelId_head).style.width=$(this.panelId).clientWidth-2+"px";
+ }*/
+ }
+ $(this.panelId+"_input").value=this.status;
+ }
+}
+
+SimpleTogglePanelManager = Class.create();
+
+SimpleTogglePanelManager.panels = $H($A({}));
+
+SimpleTogglePanelManager.add = function(value) {
+ var tmp = new Object();
+ tmp[value.panelId] = value;
+ this.panels=this.panels.merge(tmp);
+}
+
+SimpleTogglePanelManager.toggleOnServer = function (clientId) {
+ var parentForm = A4J.findForm($(clientId + "_header"));
+ if(!parentForm || !parentForm.appendChild /* findForm returns surrogate form object */)
return;
+
+ var fInput = parentForm[clientId];
+ if(!fInput) {
+ fInput = document.createElement("input");
+ fInput.type = "hidden";
+ fInput.name = clientId;
+ parentForm.appendChild(fInput);
+ }
+
+ if (this.panels[clientId].status==0){
+ this.panels[clientId].status=1;
+ }
+ else{
+ this.panels[clientId].status=0;
+ }
+
+ fInput.value = this.panels[clientId].status;
+ parentForm.submit();
+ return false;
+}
+
+SimpleTogglePanelManager.toggleOnClient = function (panelId) {
+ this.panels[panelId].toggleToState();
+ return false;
+}
Added: trunk/sandbox/simpleTogglePanel2/src/main/templates/README
===================================================================
Added: trunk/sandbox/simpleTogglePanel2/src/main/templates/simpleTogglePanel2.jspx
===================================================================
--- trunk/sandbox/simpleTogglePanel2/src/main/templates/simpleTogglePanel2.jspx
(rev 0)
+++ trunk/sandbox/simpleTogglePanel2/src/main/templates/simpleTogglePanel2.jspx 2007-04-27
12:50:58 UTC (rev 584)
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:root
xmlns:f="http://jsf.exadel.com/template"
+ xmlns:vcp="
http://jsf.exadel.com/vcp"
+ xmlns:ui="
http://jsf.exadel.com/ui"
+ xmlns:x="
http://jsf.exadel.com/vcp"
+
xmlns:u="http://jsf.exadel.com/util"
+
xmlns:h="http://jsf.exadel.com/header"
+ baseclass="org.richfaces.renderkit.html.SimpleTogglePanel2Renderer"
+ class="org.richfaces.renderkit.html.SimpleTogglePanel2Template"
+ >
+
+ <f:clientid var="clientId"/>
+ <h:styles>css/simpleTogglePanel2.xcss</h:styles>
+<h:scripts>
+new org.ajax4jsf.framework.resource.PrototypeScript(),
+new org.ajax4jsf.framework.ajax.AjaxScript(),
+new org.ajax4jsf.framework.ajax.ImageCacheScript(),
+/org/ajax4jsf/renderkit/html/scripts/form.js,
+/org/richfaces/renderkit/html/scripts/browser_info.js,
+scripts/simpleTogglePanel2.js
+</h:scripts>
+
+ <div id="#{clientId}" x:passThruWithExclusions="id,value"
+ style="width: #{component.attributes['width']};">
+ <div class="dr-stglpnl rich-stglpanel
#{component.attributes['styleClass']}"
+ style="#{component.attributes['style']};">
+ <script type="text/javascript">
+ SimpleTogglePanelManager.add(new SimpleTogglePanel("#{clientId}",
"#{component.attributes['opened']}"
+ <jsp:scriptlet><![CDATA[
+ if(component.getFacet("openMarker")!=null &&
component.getFacet("openMarker").isRendered()) {
+ ]]></jsp:scriptlet>
+ , "<u:insertFacet name='openMarker'/>"
+ <jsp:scriptlet><![CDATA[
+ } else {
+ ]]></jsp:scriptlet>
+ , null
+ <jsp:scriptlet><![CDATA[
+ }
+ ]]></jsp:scriptlet>
+ <jsp:scriptlet><![CDATA[
+ if(component.getFacet("closeMarker")!=null &&
component.getFacet("closeMarker").isRendered()) {
+ ]]></jsp:scriptlet>
+ , "<u:insertFacet name='closeMarker'/>"
+ <jsp:scriptlet><![CDATA[
+ } else {
+ ]]></jsp:scriptlet>
+ , null
+ <jsp:scriptlet><![CDATA[
+ }
+ ]]></jsp:scriptlet>
+ ));
+ </script>
+
+ <f:call name="utils.encodeBeginFormIfNessesary"/>
+ <div id="#{clientId}_header"
+ class="dr-stglpnl-h rich-stglpanel-header
#{component.attributes['headerClass']}"
+ style="position : relative;"
+ onclick="#{this:getOnClick(context,component)}">
+
+ #{component.attributes['label']}
<jsp:scriptlet><![CDATA[writer.write(" ");]]></jsp:scriptlet>
+ <div id="#{clientId}_switch"
+ style="position : absolute; top: 0px; right: 5px;">
+ <jsp:scriptlet><![CDATA[
+ if(component.isOpened()){
+ if(component.getFacet("closeMarker")!=null &&
component.getFacet("closeMarker").isRendered()) {
+ ]]></jsp:scriptlet>
+ <u:insertFacet name="closeMarker" />
+ <jsp:scriptlet><![CDATA[
+ } else {
+ writer.write("«");
+ }
+ } else {
+ if(component.getFacet("openMarker")!=null &&
component.getFacet("openMarker").isRendered()) {
+ ]]></jsp:scriptlet>
+ <u:insertFacet name="openMarker" />
+ <jsp:scriptlet><![CDATA[
+ } else {
+ writer.write("»");
+ }
+ }
+ ]]></jsp:scriptlet>
+ </div>
+ </div>
+ <jsp:scriptlet>
+ <![CDATA[if((component.getSwitchType()!=null) &&
(component.getSwitchType().equals(component.CLIENT_SWITCH_TYPE)==true)){]]>
+ </jsp:scriptlet>
+
+ <div style="display: none;">
+ <input type="hidden" id="#{clientId}_input"
name="#{clientId}"
+ value="#{component.attributes['opened']}"/>
+ </div>
+ <jsp:scriptlet>
+ <![CDATA[}]]>
+ </jsp:scriptlet>
+ <f:call name="utils.encodeEndFormIfNessesary"/>
+
+ <div id="#{clientId}_body"
+ style="display : #{this:getdivdisplay(context, component)};
+ overflow: auto; height: #{component.attributes['height']};"
+ class="dr-stglpnl-b rich-stglpanel-body
#{component.attributes['bodyClass']}">
+ <vcp:body>
+ <f:call name="renderChildren" />
+ </vcp:body>
+ </div>
+ </div>
+ </div>
+</f:root>
Added:
trunk/sandbox/simpleTogglePanel2/src/test/java/org/richfaces/component/SimpleToggle2EventTest.java
===================================================================
---
trunk/sandbox/simpleTogglePanel2/src/test/java/org/richfaces/component/SimpleToggle2EventTest.java
(rev 0)
+++
trunk/sandbox/simpleTogglePanel2/src/test/java/org/richfaces/component/SimpleToggle2EventTest.java 2007-04-27
12:50:58 UTC (rev 584)
@@ -0,0 +1,90 @@
+/**
+ * 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.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.event.ISimpleToggle2Listener;
+import org.richfaces.event.SimpleToggle2Event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * Unit test for SuggestionEvent.
+ */
+public class SimpleToggle2EventTest extends AbstractAjax4JsfTestCase {
+
+ private SimpleToggle2Event event;
+ private UISimpleTogglePanel2 stp;
+ private boolean result;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public SimpleToggle2EventTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ stp =
(UISimpleTogglePanel2)application.createComponent("org.richfaces.SimpleTogglePanel2");
+ stp.setId("simpleTogglePanel1");
+ result = false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ event = null;
+ stp = null;
+ }
+
+ public void testEvent() throws Exception {
+ event = new SimpleToggle2Event(stp, false);
+ assertFalse(event.isIsOpen());
+ event.setIsOpen(true);
+ assertTrue(event.isIsOpen());
+
+ assertFalse(event.isAppropriateListener(new TestFacesListener()));
+ assertTrue(event.isAppropriateListener(new TestSimpleToggleListener()));
+
+ event.processListener(new TestSimpleToggleListener());
+ assertTrue(result);
+ }
+
+ class TestFacesListener implements FacesListener {
+
+ }
+
+ class TestSimpleToggleListener implements ISimpleToggle2Listener {
+ public void processToggle(SimpleToggle2Event event) {
+ result = true;
+ }
+ }
+}