JBoss Rich Faces SVN: r3886 - trunk/sandbox/samples/rex-demo/src/main/webapp/richfaces/resizable.
by richfaces-svn-commits@lists.jboss.org
Author: SergeySmirnov
Date: 2007-11-09 15:52:14 -0500 (Fri, 09 Nov 2007)
New Revision: 3886
Modified:
trunk/sandbox/samples/rex-demo/src/main/webapp/richfaces/resizable/usage.xhtml
Log:
Modified: trunk/sandbox/samples/rex-demo/src/main/webapp/richfaces/resizable/usage.xhtml
===================================================================
--- trunk/sandbox/samples/rex-demo/src/main/webapp/richfaces/resizable/usage.xhtml 2007-11-09 20:46:09 UTC (rev 3885)
+++ trunk/sandbox/samples/rex-demo/src/main/webapp/richfaces/resizable/usage.xhtml 2007-11-09 20:52:14 UTC (rev 3886)
@@ -14,9 +14,9 @@
<div class="sample-container" >
- <ui:include src="/richfaces/resizable/examples/simple.xhtml"/>
+ <ui:include src="/richfaces/button/examples/simple.xhtml"/>
<ui:include src="/templates/include/sourceview.xhtml">
- <ui:param name="sourcepath" value="/richfaces/resizable/examples/simple.xhtml"/>
+ <ui:param name="sourcepath" value="/richfaces/button/examples/simple.xhtml"/>
</ui:include>
</div>
18 years, 6 months
JBoss Rich Faces SVN: r3885 - in trunk/sandbox/ui: componentControl/src/main and 24 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: SergeySmirnov
Date: 2007-11-09 15:46:09 -0500 (Fri, 09 Nov 2007)
New Revision: 3885
Added:
trunk/sandbox/ui/componentControl/src/main/templates/
trunk/sandbox/ui/componentControl/src/main/templates/htmlComponentControl.jspx
trunk/sandbox/ui/componentControl/src/test/
trunk/sandbox/ui/componentControl/src/test/java/
trunk/sandbox/ui/componentControl/src/test/java/org/
trunk/sandbox/ui/componentControl/src/test/java/org/richfaces/
trunk/sandbox/ui/componentControl/src/test/java/org/richfaces/sandbox/
trunk/sandbox/ui/componentControl/src/test/java/org/richfaces/sandbox/component/
trunk/sandbox/ui/componentControl/src/test/java/org/richfaces/sandbox/component/JSFComponentTest.java
trunk/sandbox/ui/rex-button/pom.xml
trunk/sandbox/ui/rex-button/src/
trunk/sandbox/ui/rex-button/src/main/
trunk/sandbox/ui/rex-button/src/main/config/
trunk/sandbox/ui/rex-button/src/main/config/component/
trunk/sandbox/ui/rex-button/src/main/config/component/button.xml
trunk/sandbox/ui/rex-button/src/main/java/
trunk/sandbox/ui/rex-button/src/main/java/org/
trunk/sandbox/ui/rex-button/src/main/java/org/richfaces/
trunk/sandbox/ui/rex-button/src/main/java/org/richfaces/sandbox/
trunk/sandbox/ui/rex-button/src/main/java/org/richfaces/sandbox/component/
trunk/sandbox/ui/rex-button/src/main/java/org/richfaces/sandbox/component/UIButton.java
trunk/sandbox/ui/rex-button/src/main/resources/
trunk/sandbox/ui/rex-button/src/main/templates/
trunk/sandbox/ui/rex-button/src/main/templates/htmlButton.jspx
trunk/sandbox/ui/rex-button/src/test/
trunk/sandbox/ui/rex-button/src/test/java/
trunk/sandbox/ui/rex-button/src/test/java/org/
trunk/sandbox/ui/rex-button/src/test/java/org/richfaces/
trunk/sandbox/ui/rex-button/src/test/java/org/richfaces/sandbox/
trunk/sandbox/ui/rex-button/src/test/java/org/richfaces/sandbox/component/
trunk/sandbox/ui/rex-button/src/test/java/org/richfaces/sandbox/component/JSFComponentTest.java
Log:
componentControl and rex-button
Added: trunk/sandbox/ui/componentControl/src/main/templates/htmlComponentControl.jspx
===================================================================
--- trunk/sandbox/ui/componentControl/src/main/templates/htmlComponentControl.jspx (rev 0)
+++ trunk/sandbox/ui/componentControl/src/main/templates/htmlComponentControl.jspx 2007-11-09 20:46:09 UTC (rev 3885)
@@ -0,0 +1,88 @@
+<?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.sandbox.renderkit.html.ComponentControlRenderer"
+ baseclass="org.richfaces.renderkit.ComponentControlRendererBase"
+ component="org.richfaces.sandbox.component.UIComponentControl"
+ >
+ <h:scripts>/org/richfaces/renderkit/html/scripts/jquery/jquery.js,/org/richfaces/renderkit/html/script/controlUtils.js</h:scripts>
+
+ <c:set var="event" value="#{component.attributes['event']}"/>
+ <c:set var="forAttr" value="#{component.attributes['for']}"/>
+ <c:set var="attachTiming" value="#{component.attributes['attachTiming']}"/>
+ <c:set var="attachTo" value="#{component.attributes['attachTo']}"/>
+ <c:set var="name" value="#{component.attributes['name']}"/>
+ <c:set var="operation" value="#{component.attributes['operation']}"/>
+ <c:set var="params" value="#{component.attributes['params']}"/>
+
+
+ <f:clientid var="clientId"/>
+ <jsp:scriptlet>
+<![CDATA[
+ String event = (String) variables.getVariable("event");
+ String forAttr = (String) variables.getVariable("forAttr");
+ String attachTiming = (String) variables.getVariable("attachTiming");
+ String attachTo = (String) variables.getVariable("attachTo");
+ String name = (String) variables.getVariable("name");
+ String operation = (String) variables.getVariable("operation");
+
+ checkValidity(clientId, name, attachTiming, forAttr, operation);
+ System.out.println("Before search for client id:" + forAttr);
+ variables.setVariable("forAttr", replaceClientIds(context, component, "#" + forAttr));
+ System.out.println("After search for client id:" + (String) variables.getVariable("forAttr"));
+ System.out.println("Before search for client id:" + attachTo);
+ variables.setVariable("attachTo", replaceClientIds(context, component, "#" + attachTo));
+ System.out.println("After search for client id:" + (String) variables.getVariable("attachTo"));
+]]>
+</jsp:scriptlet>
+
+<jsp:scriptlet><![CDATA[ if (! "".equals(name.trim()) ) { ]]></jsp:scriptlet>
+<script type="text/javascript">
+ //<![CDATA[
+function #{name}() {
+ Richfaces.componentControl.performOperation(
+ null, '#{forAttr}', '#{operation}', {#{params}} );
+}
+//]]>
+</script>
+<jsp:scriptlet><![CDATA[ } ]]></jsp:scriptlet>
+
+
+<jsp:scriptlet><![CDATA[ if ( "immediate".equals(attachTiming) ) { ]]></jsp:scriptlet>
+<script type="text/javascript">
+ //<![CDATA[
+ {
+
+Richfaces.componentControl.attachEvent(
+ '#{attachTo}', null, '#{event}', '#{forAttr}', '#{operation}', {#{params}} );
+
+}
+//]]>
+</script>
+<jsp:scriptlet><![CDATA[ } ]]></jsp:scriptlet>
+
+
+
+<jsp:scriptlet><![CDATA[ if ( "onload".equals(attachTiming) ) { ]]></jsp:scriptlet>
+<script type="text/javascript">
+ //<![CDATA[
+ jQuery(document).ready(function() {
+ Richfaces.componentControl.attachEvent(
+ '#{attachTo}', null, '#{event}', '#{forAttr}', '#{operation}', {#{params}} );
+ });
+
+//]]>
+</script>
+<jsp:scriptlet><![CDATA[ } ]]></jsp:scriptlet>
+
+
+
+ <div id="#{clientId}"
+ x:passThruWithExclusions="value,name,type,id"
+ >Here we start
+ </div>
+</f:root>
\ No newline at end of file
Added: trunk/sandbox/ui/componentControl/src/test/java/org/richfaces/sandbox/component/JSFComponentTest.java
===================================================================
--- trunk/sandbox/ui/componentControl/src/test/java/org/richfaces/sandbox/component/JSFComponentTest.java (rev 0)
+++ trunk/sandbox/ui/componentControl/src/test/java/org/richfaces/sandbox/component/JSFComponentTest.java 2007-11-09 20:46:09 UTC (rev 3885)
@@ -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.sandbox.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 );
+ }
+}
Added: trunk/sandbox/ui/rex-button/pom.xml
===================================================================
--- trunk/sandbox/ui/rex-button/pom.xml (rev 0)
+++ trunk/sandbox/ui/rex-button/pom.xml 2007-11-09 20:46:09 UTC (rev 3885)
@@ -0,0 +1,49 @@
+<?xml version="1.0"?><project>
+ <parent>
+ <artifactId>ui</artifactId>
+ <groupId>org.richfaces.sandbox</groupId>
+ <version>3.2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.sandbox.ui</groupId>
+ <artifactId>rex-button</artifactId>
+ <name>rex-button</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.sandbox</prefix>
+ <taglib>
+ <shortName>rex-button</shortName>
+ </taglib>
+ </library>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>richfaces-impl</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/sandbox/ui/rex-button/src/main/config/component/button.xml
===================================================================
--- trunk/sandbox/ui/rex-button/src/main/config/component/button.xml (rev 0)
+++ trunk/sandbox/ui/rex-button/src/main/config/component/button.xml 2007-11-09 20:46:09 UTC (rev 3885)
@@ -0,0 +1,51 @@
+<?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.sandbox.Button</name>
+ <family>org.richfaces.sandbox.Button</family>
+ <classname>org.richfaces.sandbox.component.html.HtmlButton</classname>
+ <superclass>org.richfaces.sandbox.component.UIButton</superclass>
+ <description>
+ <![CDATA[
+ ]]>
+ </description>
+ <renderer generate="true" override="true">
+ <name>org.richfaces.sandbox.ButtonRenderer</name>
+ <template>htmlButton.jspx</template>
+ </renderer>
+ <tag>
+ <name>button</name>
+ <classname>org.richfaces.sandbox.taglib.ButtonTag</classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+ </superclass>
+ </tag>
+ <!--
+ <taghandler>
+ <classname>org.ajax4jsf.tag.TestHandler</classname>
+ </taghandler>
+ -->
+ &ui_component_attributes;
+ &html_events;
+ &html_style_attributes;
+ <property>
+ <name>value</name>
+ <classname>java.lang.String</classname>
+ <description>
+ The text appears on the button
+ </description>
+ <defaultvalue>""</defaultvalue>
+ </property>
+
+ <!--
+ <property>
+ <name>param</name>
+ <classname>java.lang.String</classname>
+ <description>
+ </description>
+ <defaultvalue>"default"</defaultvalue>
+ </property>
+ -->
+ </component>
+</components>
Added: trunk/sandbox/ui/rex-button/src/main/java/org/richfaces/sandbox/component/UIButton.java
===================================================================
--- trunk/sandbox/ui/rex-button/src/main/java/org/richfaces/sandbox/component/UIButton.java (rev 0)
+++ trunk/sandbox/ui/rex-button/src/main/java/org/richfaces/sandbox/component/UIButton.java 2007-11-09 20:46:09 UTC (rev 3885)
@@ -0,0 +1,19 @@
+/**
+ *
+ */
+
+package org.richfaces.sandbox.component;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * JSF component class
+ *
+ */
+public abstract class UIButton extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.sandbox.Button";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.sandbox.Button";
+
+}
Added: trunk/sandbox/ui/rex-button/src/main/templates/htmlButton.jspx
===================================================================
--- trunk/sandbox/ui/rex-button/src/main/templates/htmlButton.jspx (rev 0)
+++ trunk/sandbox/ui/rex-button/src/main/templates/htmlButton.jspx 2007-11-09 20:46:09 UTC (rev 3885)
@@ -0,0 +1,44 @@
+<?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.sandbox.renderkit.html.ButtonRenderer"
+ baseclass="org.ajax4jsf.renderkit.AjaxComponentRendererBase"
+ component="org.richfaces.sandbox.component.UIButton"
+ >
+ <h:styles>extjs/ext-all.css,extjs/ext-css-patch.xcss</h:styles>
+ <h:scripts>extjs/ext-base.js,extjs/ext-all.js,/org/richfaces/renderkit/html/scripts/jquery/jquery.js</h:scripts>
+
+ <c:set var="value" value="#{component.attributes['value']}"/>
+
+ <f:clientid var="clientId"/>
+ <div id="#{clientId}" x:passThruWithExclusions="id" style="width:auto">
+ <vcp:body>
+ <f:call name="renderChildren" />
+ </vcp:body>
+ <f:clientid var="clientId"/>
+ <script type="text/javascript">
+ var $pardiv = Ext.get('#{clientId}');
+ $pardiv.dom.button = new Object();
+ if (Ext.query('input','#{clientId}' ) != 0) {
+ $pardiv.dom.button.input = Ext.query('input','#{clientId}' );
+ jQuery($pardiv.dom.button.input).hide();
+ }
+ $pardiv.dom.button.extobj = new Ext.Button ({
+ text: '#{value}',
+ renderTo:'#{clientId}',
+ handler: function() {
+ var $bdiv = jQuery(Ext.get('#{clientId}').dom.button.input);
+ $bdiv.click();
+ }
+
+ });
+ $pardiv = null;
+ </script>
+
+
+ </div>
+</f:root>
\ No newline at end of file
Added: trunk/sandbox/ui/rex-button/src/test/java/org/richfaces/sandbox/component/JSFComponentTest.java
===================================================================
--- trunk/sandbox/ui/rex-button/src/test/java/org/richfaces/sandbox/component/JSFComponentTest.java (rev 0)
+++ trunk/sandbox/ui/rex-button/src/test/java/org/richfaces/sandbox/component/JSFComponentTest.java 2007-11-09 20:46:09 UTC (rev 3885)
@@ -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.sandbox.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 );
+ }
+}
18 years, 6 months
JBoss Rich Faces SVN: r3884 - in trunk: framework/impl/src/main/java/org/richfaces/renderkit and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-11-09 15:05:17 -0500 (Fri, 09 Nov 2007)
New Revision: 3884
Added:
trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java
trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/
trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/
trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java
trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java
trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java
trunk/sandbox/ui/contextMenu/
trunk/sandbox/ui/contextMenu/pom.xml
trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
trunk/ui/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Log:
refactoring of DropDownMenu code to allow compatibility with ContextMenu
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java 2007-11-09 18:50:46 UTC (rev 3883)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java 2007-11-09 20:05:17 UTC (rev 3884)
@@ -47,7 +47,7 @@
*
* @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderScripts(javax.faces.context.FacesContext)
*/
- public LinkedHashSet getHeaderScripts(FacesContext context,
+ public LinkedHashSet<String> getHeaderScripts(FacesContext context,
UIComponent component) {
return getUrisSet(context, getScripts(), component);
}
@@ -67,7 +67,7 @@
*
* @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderStyles(javax.faces.context.FacesContext)
*/
- public LinkedHashSet getHeaderStyles(FacesContext context,
+ public LinkedHashSet<String> getHeaderStyles(FacesContext context,
UIComponent component) {
return getUrisSet(context, getStyles(), component);
}
@@ -89,10 +89,10 @@
* TODO
* @return
*/
- private LinkedHashSet getUrisSet(FacesContext context,
+ private LinkedHashSet<String> getUrisSet(FacesContext context,
InternetResource[] resources, UIComponent component) {
if (null != resources) {
- LinkedHashSet uris = new LinkedHashSet(); // Collections.singleton(ajaxScript.getUri(context,
+ LinkedHashSet<String> uris = new LinkedHashSet<String>(); // Collections.singleton(ajaxScript.getUri(context,
// null));
for (int i = 0; i < resources.length; i++) {
InternetResource resource = resources[i];
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2007-11-09 18:50:46 UTC (rev 3883)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2007-11-09 20:05:17 UTC (rev 3884)
@@ -196,7 +196,7 @@
* Get base component slass , targetted for this renderer. Used for check arguments in decode/encode.
* @return
*/
- protected abstract Class getComponentClass();
+ protected abstract Class<? extends UIComponent> getComponentClass();
/**
@@ -257,8 +257,8 @@
public void renderChildren(FacesContext facesContext,
UIComponent component) throws IOException {
if (component.getChildCount() > 0) {
- for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
+ for (Iterator<UIComponent> it = component.getChildren().iterator(); it.hasNext();) {
+ UIComponent child = it.next();
renderChild(facesContext, child);
}
}
Modified: trunk/framework/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java 2007-11-09 18:50:46 UTC (rev 3883)
+++ trunk/framework/impl/src/main/java/org/richfaces/renderkit/ScriptOptions.java 2007-11-09 20:05:17 UTC (rev 3884)
@@ -49,7 +49,7 @@
public class ScriptOptions extends ScriptStringBase {
private UIComponent component;
- protected Map opts = new HashMap();
+ protected Map<String, Object> opts = new HashMap<String, Object>();
public ScriptOptions(UIComponent component) {
this.component = component;
@@ -64,6 +64,8 @@
addOption(name, value);
}
}
+
+ @SuppressWarnings("unchecked")
public void addOption(String name, Object value) {
if (value != null) {
Object object = opts.get(name);
@@ -97,16 +99,16 @@
opts.put(event, definition);
}
}
- public Map getMap() {
+ public Map<String,Object> getMap() {
return opts;
}
public void merge(ScriptOptions anotherOptions) {
- Iterator entrySetIterator = anotherOptions.opts.entrySet().iterator();
+ Iterator<Entry<String, Object>> entrySetIterator = anotherOptions.opts.entrySet().iterator();
while (entrySetIterator.hasNext()) {
- Entry entry = (Entry) entrySetIterator.next();
+ Entry<String, Object> entry = entrySetIterator.next();
- addOption((String) entry.getKey(), entry.getValue());
+ addOption(entry.getKey(), entry.getValue());
}
}
Property changes on: trunk/sandbox/ui/contextMenu
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.project
.settings
Modified: trunk/sandbox/ui/contextMenu/pom.xml
===================================================================
--- trunk/sandbox/ui/contextMenu/pom.xml 2007-11-09 18:50:46 UTC (rev 3883)
+++ trunk/sandbox/ui/contextMenu/pom.xml 2007-11-09 20:05:17 UTC (rev 3884)
@@ -46,5 +46,10 @@
<artifactId>richfaces-impl</artifactId>
<version>3.2.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>menu-components</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Added: trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java
===================================================================
--- trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java (rev 0)
+++ trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java 2007-11-09 20:05:17 UTC (rev 3884)
@@ -0,0 +1,33 @@
+/**
+ * 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 javax.faces.component.UIComponentBase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class UIContextMenu extends UIComponentBase implements MenuComponent {
+ public static final String COMPONENT_TYPE = "org.richfaces.ContextMenu";
+
+}
Added: trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java
===================================================================
--- trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java (rev 0)
+++ trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererBase.java 2007-11-09 20:05:17 UTC (rev 3884)
@@ -0,0 +1,68 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.renderkit.TemplateEncoderRendererBase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class ContextMenuRendererBase extends
+ TemplateEncoderRendererBase {
+
+
+ private final ContextMenuRendererDelegate delegate =
+ new ContextMenuRendererDelegate();
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return delegate.getComponentClass();
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeBegin(context, component);
+ }
+
+ @Override
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException {
+ // TODO Auto-generated method stub
+ super.encodeChildren(context, component);
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ // TODO Auto-generated method stub
+ super.encodeEnd(context, component);
+ }
+
+
+}
Added: trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java
===================================================================
--- trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java (rev 0)
+++ trunk/sandbox/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java 2007-11-09 20:05:17 UTC (rev 3884)
@@ -0,0 +1,111 @@
+/**
+ * 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.renderkit.html;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.richfaces.component.UIContextMenu;
+import org.richfaces.component.UIMenuGroup;
+import org.richfaces.renderkit.ScriptOptions;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ContextMenuRendererDelegate extends AbstractMenuRenderer {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.renderkit.html.AbstractMenuRenderer#getLayerScript(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ @Override
+ protected String getLayerScript(FacesContext context, UIComponent component) {
+ StringBuffer buffer = new StringBuffer();
+ JSFunction function = new JSFunction("new RichFaces.Menu.Layer");
+ function.addParameter(component.getClientId(context)+"_menu");
+ function.addParameter(component.getAttributes().get("showDelay"));
+
+ if (component instanceof UIContextMenu) {
+ function.addParameter(component.getAttributes().get("hideDelay"));
+ } else {
+ function.addParameter(new Integer(300));
+ }
+
+ function.appendScript(buffer);
+
+ if (component instanceof UIMenuGroup) {
+ buffer.append(".");
+ function = new JSFunction("asSubMenu");
+ function.addParameter(component.getParent().getClientId(context)+"_menu");
+ function.addParameter("ref"+component.getClientId(context));
+ String evt = (String) component.getAttributes().get("event");
+ if(evt == null || evt.trim().length() == 0){
+ evt = "onmouseover";
+ }
+ function.addParameter(evt);
+ ScriptOptions subMenuOptions = new ScriptOptions(component);
+ subMenuOptions.addEventHandler("onopen");
+ subMenuOptions.addEventHandler("onclose");
+ subMenuOptions.addOption("direction");
+ function.addParameter(subMenuOptions);
+ function.appendScript(buffer);
+
+ } else {
+ buffer.append(".");
+ function = new JSFunction("asDropDown");
+ function.addParameter(component.getClientId(context));
+ String evt = (String) component.getAttributes().get("event");
+ if(evt == null || evt.trim().length() == 0){
+ evt = "onmouseover";
+ }
+ function.addParameter(evt);
+ function.addParameter("onmouseout");
+ ScriptOptions menuOptions = new ScriptOptions(component);
+
+ menuOptions.addOption("direction");
+ menuOptions.addOption("jointPoint");
+ menuOptions.addOption("verticalOffset");
+
+
+ menuOptions.addOption("horizontalOffset");
+ menuOptions.addEventHandler("oncollapse");
+ menuOptions.addEventHandler("onexpand");
+ menuOptions.addEventHandler("onitemselect");
+ menuOptions.addEventHandler("ongroupactivate");
+ function.addParameter(menuOptions);
+ function.appendScript(buffer);
+
+ }
+
+ return buffer.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIContextMenu.class;
+ }
+
+}
Modified: trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
--- trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-11-09 18:50:46 UTC (rev 3883)
+++ trunk/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-11-09 20:05:17 UTC (rev 3884)
@@ -21,140 +21,36 @@
package org.richfaces.renderkit.html;
-
-
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.richfaces.component.UIDropDownMenu;
import org.richfaces.component.UIMenuGroup;
-import org.richfaces.component.UIMenuItem;
-import org.richfaces.component.UIMenuSeparator;
-import org.richfaces.component.util.HtmlUtil;
import org.richfaces.renderkit.ScriptOptions;
-public class DropDownMenuRendererBase extends HeaderResourcesRendererBase {
+public class DropDownMenuRendererBase extends AbstractMenuRenderer {
- protected Class getComponentClass() {
+ protected Class<UIDropDownMenu> getComponentClass() {
return UIDropDownMenu.class;
}
- public boolean getRendersChildren() {
- return true;
- }
-
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- List flatListOfNodes = new LinkedList();
- String width = (String)component.getAttributes().get("popupWidth");
-
- flatten(component.getChildren(), flatListOfNodes);
- processLayer(context, component, width);
-
- for (Iterator iter = flatListOfNodes.iterator(); iter.hasNext();) {
- UIMenuGroup node = (UIMenuGroup) iter.next();
- if (node.isRendered() && !node.isDisabled()) processLayer(context, node, width);
- }
- }
-
- public void processLayer(FacesContext context, UIComponent layer, String width) throws IOException {
- String clientId = layer.getClientId(context);
-
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement("div", layer);
- writer.writeAttribute("id", clientId+"_menu", null);
- writer.writeAttribute("class", "dr-menu-list-border rich-menu-list-border", null);
- writer.writeAttribute("style", "visibility: hidden; z-index: 2; ", null);
- writer.startElement("div", layer);
- writer.writeAttribute("class", "dr-menu-list-bg rich-menu-list-bg", null);
- encodeItems(context, layer);
-
- writer.startElement("div", layer);
- writer.writeAttribute("class", "dr-menu-list-strut rich-menu-list-strut", null);
-
- writer.startElement("img", layer);
- writer.writeAttribute("width", "1", null);
- writer.writeAttribute("height", "1", null);
- writer.writeAttribute("alt", "", null);
- writer.writeAttribute("border", "0", null);
- writer.writeAttribute("style", width!=null && width.length() > 0 ? "width: " + HtmlUtil.qualifySize(width) : "", null);
- writer.writeAttribute("src",
- getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null),
- null);
- writer.endElement("img");
- writer.endElement("div");
-
- writer.endElement("div");
- writer.endElement("div");
-
- writer.startElement("iframe", layer);
- writer.writeAttribute("src",
- getResource("/org/richfaces/renderkit/html/images/spacer.gif")
- .getUri(context, null), null);
- writer.writeAttribute("id", clientId+"_menu_iframe", null);
- writer.writeAttribute("class", "underneath_iframe", null);
- writer.writeAttribute("style", "position:absolute; z-index: 1;", null);
- writer.endElement("iframe");
-
- writer.startElement("script", layer);
- writer.writeAttribute("id", clientId+"_menu_script", null);
- writer.writeAttribute("type", "text/javascript", null);
- encodeScript(context, layer);
- writer.endElement("script");
-
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
- Set renderedAreas = ajaxContext.getAjaxRenderedAreas();
- renderedAreas.add(clientId + "_menu_iframe");
- renderedAreas.add(clientId + "_menu_script");
- }
-
- public void encodeItems(FacesContext context, UIComponent component) throws IOException {
- List kids = component.getChildren();
- Iterator it = kids.iterator();
- while (it.hasNext()) {
- UIComponent kid = (UIComponent)it.next();
- if (kid instanceof UIMenuGroup || kid instanceof UIMenuItem || kid instanceof UIMenuSeparator) {
- renderChild(context, kid);
- }
- }
- }
-
- private void flatten(List kids, List flatList){
- if(kids != null){
- for (Iterator iter = kids.iterator(); iter.hasNext();) {
- UIComponent kid = (UIComponent) iter.next();
- if (kid instanceof UIMenuGroup) {
- UIMenuGroup node = (UIMenuGroup) kid;
- flatList.add(node);
- flatten(node.getChildren(), flatList);
- }
- }
- }
- }
-
- public void encodeScript(FacesContext context, UIComponent component) throws IOException {
+ @Override
+ protected String getLayerScript(FacesContext context, UIComponent component) {
StringBuffer buffer = new StringBuffer();
JSFunction function = new JSFunction("new RichFaces.Menu.Layer");
function.addParameter(component.getClientId(context)+"_menu");
function.addParameter(component.getAttributes().get("showDelay"));
- if (component instanceof UIDropDownMenu) {
+
+ if (component instanceof UIDropDownMenu) {
function.addParameter(component.getAttributes().get("hideDelay"));
+ } else {
+ function.addParameter(new Integer(300));
}
- else{
- function.addParameter(""+300);
- }
- function.appendScript(buffer);
+
+ function.appendScript(buffer);
+
if (component instanceof UIMenuGroup) {
buffer.append(".");
function = new JSFunction("asSubMenu");
@@ -162,84 +58,44 @@
function.addParameter("ref"+component.getClientId(context));
String evt = (String) component.getAttributes().get("event");
if(evt == null || evt.trim().length() == 0){
- evt = "onmouseover";
+ evt = "onmouseover";
}
function.addParameter(evt);
- ScriptOptions Optionssub = new ScriptOptions(component);
- Optionssub.addOption("onopen", component.getAttributes().get("onopen"));
- Optionssub.addOption("onclose", component.getAttributes().get("onclose"));
- Optionssub.addOption("direction", component.getAttributes().get("direction"));
- function.addParameter(Optionssub);
+ ScriptOptions subMenuOptions = new ScriptOptions(component);
+ subMenuOptions.addEventHandler("onopen");
+ subMenuOptions.addEventHandler("onclose");
+ subMenuOptions.addOption("direction");
+ function.addParameter(subMenuOptions);
function.appendScript(buffer);
} else {
buffer.append(".");
- function = new JSFunction("asDropDown");
+ function = new JSFunction("asContextMenu");
function.addParameter(component.getClientId(context));
String evt = (String) component.getAttributes().get("event");
if(evt == null || evt.trim().length() == 0){
- evt = "onmouseover";
+ evt = "oncontextmenu";
}
function.addParameter(evt);
function.addParameter("onmouseout");
- ScriptOptions Options = new ScriptOptions(component);
+ ScriptOptions menuOptions = new ScriptOptions(component);
- Options.addOption("direction", component.getAttributes().get("direction"));
- Options.addOption("jointPoint", component.getAttributes().get("jointPoint"));
- Options.addOption("verticalOffset", component.getAttributes().get("verticalOffset"));
+ menuOptions.addOption("direction");
+ menuOptions.addOption("jointPoint");
+ menuOptions.addOption("verticalOffset");
- Options.addOption("horizontalOffset", component.getAttributes().get("horizontalOffset"));
- Options.addOption("oncollapse", component.getAttributes().get("oncollapse"));
- Options.addOption("onexpand", component.getAttributes().get("onexpand"));
- Options.addOption("onitemselect", component.getAttributes().get("onitemselect"));
- Options.addOption("ongroupactivate", component.getAttributes().get("ongroupactivate"));
- function.addParameter(Options);
+ menuOptions.addOption("horizontalOffset");
+ menuOptions.addEventHandler("oncollapse");
+ menuOptions.addEventHandler("onexpand");
+ menuOptions.addEventHandler("onitemselect");
+ menuOptions.addEventHandler("ongroupactivate");
+ function.addParameter(menuOptions);
function.appendScript(buffer);
}
-
- List children = component.getChildren();
- for(Iterator it = children.iterator();it.hasNext();) {
- UIComponent kid = (UIComponent)it.next();
- String itemId = null;
- int flcloseonclick=1;
- int flagGroup = 0;
- if (kid instanceof UIMenuItem) {
- UIMenuItem MenuItem=(UIMenuItem)kid;
- itemId = kid.getClientId(context);
- if (MenuItem.isDisabled()){
- flcloseonclick=0;
- }
- } else if (kid instanceof UIMenuGroup) {
- UIMenuGroup menuGroup=(UIMenuGroup)kid;
- itemId = "ref" + kid.getClientId(context);
- flcloseonclick=0;
- if (menuGroup.isDisabled()) flagGroup = 2; else flagGroup = 1;
- }
- if(itemId != null){
- function = new JSFunction("addItem");
- function.addParameter(itemId);
- function.addParameter(new Integer(flcloseonclick));
-
- ScriptOptions options = new ScriptOptions(kid);
- options.addOption("onmouseout", kid.getAttributes().get("onmouseout"));
- options.addOption("onmouseover", kid.getAttributes().get("onmouseover"));
- options.addOption("flagGroup", new Integer(flagGroup));
- String tmp = (String)kid.getAttributes().get("selectClass");
- if (tmp != null && tmp.length() > 0) options.addOption("selectClass", tmp);
- function.addParameter(options);
- buffer.append('.');
- function.appendScript(buffer);
- }
- }
-
- ResponseWriter out = context.getResponseWriter();
- String script =buffer.append(";").toString();
- out.write(script);
-
-
-
+
+ return buffer.toString();
}
Modified: trunk/ui/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
--- trunk/ui/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-11-09 18:50:46 UTC (rev 3883)
+++ trunk/ui/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-11-09 20:05:17 UTC (rev 3884)
@@ -979,17 +979,17 @@
},
asDropDown: function(topLevel, onEvt, offEvt, options){
this.options = options || {};
- if (this.options.ongroupactivate != ""){
- this.eventOnGroupActivate = new Function("event",this.options.ongroupactivate).bindAsEventListener(this);
+ if (this.options.ongroupactivate){
+ this.eventOnGroupActivate = this.options.ongroupactivate.bindAsEventListener(this);
}
- if (this.options.onitemselect != ""){
- this.eventOnItemSelect = new Function("event",options.onitemselect).bindAsEventListener(this);
+ if (this.options.onitemselect){
+ this.eventOnItemSelect = this.options.onitemselect.bindAsEventListener(this);
}
- if (this.options.oncollapse != ""){
- this.eventOnCollapse = new Function("event",this.options.oncollapse).bindAsEventListener(this);
+ if (this.options.oncollapse){
+ this.eventOnCollapse = this.options.oncollapse.bindAsEventListener(this);
}
- if (this.options.onexpand != ""){
- this.eventOnExpand = new Function("event",this.options.onexpand).bindAsEventListener(this);
+ if (this.options.onexpand){
+ this.eventOnExpand = this.options.onexpand.bindAsEventListener(this);
}
// if($(topLevel)){ CH-1518
@@ -1031,11 +1031,11 @@
asSubMenu: function(parentv, refLayerName, evtName, options){
this.options = options || {};
- if (this.options.onclose != ""){
- this.eventOnClose = new Function("event",this.options.onclose).bindAsEventListener(this);
+ if (this.options.onclose){
+ this.eventOnClose = this.options.onclose.bindAsEventListener(this);
}
- if (this.options.onopen != ""){
- this.eventOnOpen = new Function("event",this.options.onopen).bindAsEventListener(this);
+ if (this.options.onopen){
+ this.eventOnOpen = this.options.onopen.bindAsEventListener(this);
}
if(!evtName){
Added: trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java
===================================================================
--- trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java (rev 0)
+++ trunk/ui/menu-components/src/main/java/org/richfaces/renderkit/html/AbstractMenuRenderer.java 2007-11-09 20:05:17 UTC (rev 3884)
@@ -0,0 +1,196 @@
+/**
+ * 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.renderkit.html;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.richfaces.component.UIMenuGroup;
+import org.richfaces.component.UIMenuItem;
+import org.richfaces.component.UIMenuSeparator;
+import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.ScriptOptions;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class AbstractMenuRenderer extends HeaderResourcesRendererBase {
+
+ public void encodeScript(FacesContext context, UIComponent component) throws IOException {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append(getLayerScript(context, component));
+
+ List children = component.getChildren();
+ for(Iterator it = children.iterator();it.hasNext();) {
+ buffer.append(getItemScript(context, (UIComponent) it.next()));
+ }
+
+ ResponseWriter out = context.getResponseWriter();
+ String script = buffer.append(";").toString();
+ out.write(script);
+ }
+
+ protected abstract String getLayerScript(FacesContext context, UIComponent layer);
+
+ protected String getItemScript(FacesContext context, UIComponent kid) {
+ String itemId = null;
+ int flcloseonclick = 1;
+ int flagGroup = 0;
+ if (kid instanceof UIMenuItem) {
+ UIMenuItem menuItem = (UIMenuItem) kid;
+ itemId = kid.getClientId(context);
+ if (menuItem.isDisabled()) {
+ flcloseonclick = 0;
+ }
+ } else if (kid instanceof UIMenuGroup) {
+ UIMenuGroup menuGroup = (UIMenuGroup) kid;
+ itemId = "ref" + kid.getClientId(context);
+ flcloseonclick = 0;
+ if (menuGroup.isDisabled()) {
+ flagGroup = 2;
+ } else {
+ flagGroup = 1;
+ }
+ }
+ if (itemId != null) {
+ JSFunction function = new JSFunction(".addItem");
+ function.addParameter(itemId);
+ function.addParameter(new Integer(flcloseonclick));
+
+ ScriptOptions options = new ScriptOptions(kid);
+ options.addEventHandler("onmouseout");
+ options.addEventHandler("onmouseover");
+ options.addOption("flagGroup", new Integer(flagGroup));
+ options.addOption("selectClass");
+ function.addParameter(options);
+ return function.toScript();
+ }
+ return "";
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException {
+ List flatListOfNodes = new LinkedList();
+ String width = (String) component.getAttributes().get("popupWidth");
+
+ flatten(component.getChildren(), flatListOfNodes);
+ processLayer(context, component, width);
+
+ for (Iterator iter = flatListOfNodes.iterator(); iter.hasNext();) {
+ UIMenuGroup node = (UIMenuGroup) iter.next();
+ if (node.isRendered() && !node.isDisabled())
+ processLayer(context, node, width);
+ }
+ }
+
+ public void processLayer(FacesContext context, UIComponent layer, String width) throws IOException {
+ String clientId = layer.getClientId(context);
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement("div", layer);
+ writer.writeAttribute("id", clientId+"_menu", null);
+ writer.writeAttribute("class", "dr-menu-list-border rich-menu-list-border", null);
+ writer.writeAttribute("style", "visibility: hidden; z-index: 2; ", null);
+ writer.startElement("div", layer);
+ writer.writeAttribute("class", "dr-menu-list-bg rich-menu-list-bg", null);
+ encodeItems(context, layer);
+
+ writer.startElement("div", layer);
+ writer.writeAttribute("class", "dr-menu-list-strut rich-menu-list-strut", null);
+
+ writer.startElement("img", layer);
+ writer.writeAttribute("width", "1", null);
+ writer.writeAttribute("height", "1", null);
+ writer.writeAttribute("alt", "", null);
+ writer.writeAttribute("border", "0", null);
+ writer.writeAttribute("style", width!=null && width.length() > 0 ? "width: " + HtmlUtil.qualifySize(width) : "", null);
+ writer.writeAttribute("src",
+ getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null),
+ null);
+ writer.endElement("img");
+ writer.endElement("div");
+
+ writer.endElement("div");
+ writer.endElement("div");
+
+ writer.startElement("iframe", layer);
+ writer.writeAttribute("src",
+ getResource("/org/richfaces/renderkit/html/images/spacer.gif")
+ .getUri(context, null), null);
+ writer.writeAttribute("id", clientId+"_menu_iframe", null);
+ writer.writeAttribute("class", "underneath_iframe", null);
+ writer.writeAttribute("style", "position:absolute; z-index: 1;", null);
+ writer.endElement("iframe");
+
+ writer.startElement("script", layer);
+ writer.writeAttribute("id", clientId+"_menu_script", null);
+ writer.writeAttribute("type", "text/javascript", null);
+ encodeScript(context, layer);
+ writer.endElement("script");
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
+ Set renderedAreas = ajaxContext.getAjaxRenderedAreas();
+ renderedAreas.add(clientId + "_menu_iframe");
+ renderedAreas.add(clientId + "_menu_script");
+ }
+
+ public void encodeItems(FacesContext context, UIComponent component) throws IOException {
+ List kids = component.getChildren();
+ Iterator it = kids.iterator();
+ while (it.hasNext()) {
+ UIComponent kid = (UIComponent)it.next();
+ if (kid instanceof UIMenuGroup || kid instanceof UIMenuItem || kid instanceof UIMenuSeparator) {
+ renderChild(context, kid);
+ }
+ }
+ }
+
+ private void flatten(List kids, List flatList){
+ if(kids != null){
+ for (Iterator iter = kids.iterator(); iter.hasNext();) {
+ UIComponent kid = (UIComponent) iter.next();
+ if (kid instanceof UIMenuGroup) {
+ UIMenuGroup node = (UIMenuGroup) kid;
+ flatList.add(node);
+ flatten(node.getChildren(), flatList);
+ }
+ }
+ }
+ }
+
+}
18 years, 6 months
JBoss Rich Faces SVN: r3883 - in trunk/sandbox/samples/contextMenuDemo: src/main/java/org/richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-11-09 13:50:46 -0500 (Fri, 09 Nov 2007)
New Revision: 3883
Modified:
trunk/sandbox/samples/contextMenuDemo/pom.xml
trunk/sandbox/samples/contextMenuDemo/src/main/java/org/richfaces/Bean.java
trunk/sandbox/samples/contextMenuDemo/src/main/webapp/pages/index.jsp
Log:
RF-1305
Modified: trunk/sandbox/samples/contextMenuDemo/pom.xml
===================================================================
--- trunk/sandbox/samples/contextMenuDemo/pom.xml 2007-11-09 18:48:52 UTC (rev 3882)
+++ trunk/sandbox/samples/contextMenuDemo/pom.xml 2007-11-09 18:50:46 UTC (rev 3883)
@@ -21,6 +21,11 @@
<artifactId>core</artifactId>
<version>3.2.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>dataTable</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
<build>
<finalName>contextMenuDemo</finalName>
Modified: trunk/sandbox/samples/contextMenuDemo/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/sandbox/samples/contextMenuDemo/src/main/java/org/richfaces/Bean.java 2007-11-09 18:48:52 UTC (rev 3882)
+++ trunk/sandbox/samples/contextMenuDemo/src/main/java/org/richfaces/Bean.java 2007-11-09 18:50:46 UTC (rev 3883)
@@ -31,12 +31,14 @@
public class Bean {
public class Pair {
- private String first = "first";
- private String second = "second";
+ private String first;
+ private String second;
public Pair(int i) {
- first = i + " first";
- second = i + " second";
+ if(Package.getPackages().length > i) {
+ first = Package.getPackages()[i].getName();
+ second = Package.getPackages()[i].getImplementationTitle();
+ }
}
public void setFirst(String first) {
@@ -59,7 +61,7 @@
private List<Pair> model = new ArrayList<Pair>();
public Bean() {
- for (int i = 0; i < 1000; i++) {
+ for (int i = 0; i < 100; i++) {
model.add(new Pair(i));
}
}
Modified: trunk/sandbox/samples/contextMenuDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/contextMenuDemo/src/main/webapp/pages/index.jsp 2007-11-09 18:48:52 UTC (rev 3882)
+++ trunk/sandbox/samples/contextMenuDemo/src/main/webapp/pages/index.jsp 2007-11-09 18:50:46 UTC (rev 3883)
@@ -1,6 +1,6 @@
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
-<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/dataTable" prefix="dt"%>
<html>
<head>
<title>
@@ -19,9 +19,9 @@
<body>
<f:view>
<h:form>
- <h:dataTable id="table" value="#{bean.model}" var="row" style="width:300px"
+ <dt:dataTable id="table" value="#{bean.model}" var="row" style="width:300px"
first="0" rows="40" width="100%">
- <h:column headerClass="header" footerClass="footer">
+ <dt:column headerClass="header" footerClass="footer">
<f:facet name="header">
<h:outputText value="First header"></h:outputText>
</f:facet>
@@ -29,8 +29,8 @@
<h:outputText value="First footer"></h:outputText>
</f:facet>
<h:outputText value="#{row.first}"></h:outputText>
- </h:column>
- <h:column headerClass="header" footerClass="footer">
+ </dt:column>
+ <dt:column headerClass="header" footerClass="footer">
<f:facet name="header">
<h:outputText value="Second header"></h:outputText>
</f:facet>
@@ -38,8 +38,8 @@
<h:outputText value="Second footer"></h:outputText>
</f:facet>
<h:outputText value="#{row.second}"></h:outputText>
- </h:column>
- </h:dataTable>
+ </dt:column>
+ </dt:dataTable>
</h:form>
</f:view>
18 years, 6 months
JBoss Rich Faces SVN: r3882 - in trunk/sandbox/ui/orderingList/src/main: java/org/richfaces/renderkit and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: vmolotkov
Date: 2007-11-09 13:48:52 -0500 (Fri, 09 Nov 2007)
New Revision: 3882
Modified:
trunk/sandbox/ui/orderingList/src/main/config/component/orderinglist.xml
trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
Log:
rendering of facet content was added
Modified: trunk/sandbox/ui/orderingList/src/main/config/component/orderinglist.xml
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/config/component/orderinglist.xml 2007-11-09 18:33:48 UTC (rev 3881)
+++ trunk/sandbox/ui/orderingList/src/main/config/component/orderinglist.xml 2007-11-09 18:48:52 UTC (rev 3882)
@@ -40,6 +40,13 @@
</property>
<property>
+ <name>captionLabel</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Defines caption representation text
+ </description>
+ </property>
+ <property>
<name>listWidth</name>
<classname>int</classname>
<description>
Modified: trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-09 18:33:48 UTC (rev 3881)
+++ trunk/sandbox/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2007-11-09 18:48:52 UTC (rev 3882)
@@ -39,6 +39,8 @@
private final static String FACET_DOWN = "downControl";
+ private final static String FACET_CAPTION = "caption";
+
private final static String CONTROL_TYPE_LINK = "link";
private final static String CONTROL_TYPE_BUTTON = "button";
@@ -59,6 +61,8 @@
private final static String ATTRIBUTE_CE_ONHEADERCLICK = "onheaderclick";
+ private final static String ATTRIBUTE_CAPTION_LABEL = "captionLabel";
+
private final static String CONTROL_ID_UP = "_up";
private final static String CONTROL_ID_DOWN = "_down";
@@ -179,8 +183,24 @@
}});
}
- public void encodeCaption(FacesContext context, UIOrderingList orderingList) {
-
+ public void encodeCaption(FacesContext context, UIOrderingList orderingList)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ UIComponent facetEl = orderingList.getFacet(FACET_CAPTION);
+ boolean renderFacet = ((facetEl != null) && facetEl.isRendered());
+ String captionAttr = (String) orderingList.getAttributes().get(ATTRIBUTE_CAPTION_LABEL);
+
+ if (renderFacet || (captionAttr != null)) {
+ writer.startElement(HTML.DIV_ELEM, orderingList);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, "ol_captionlabel rich-ordering-list-caption", null);
+ if (renderFacet) {
+ renderChild(context, facetEl);
+ } else {
+ writer.write(captionAttr);
+ }
+ writer.endElement(HTML.DIV_ELEM);
+ }
+
}
public void encodeHeader(FacesContext context, UIOrderingList orderingList)
@@ -301,7 +321,7 @@
}
UIComponent facet = column.getFacet(facetName);
- if (facet != null) {
+ if (facet != null && facet.isRendered()) {
renderChild(context, facet);
}
Modified: trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-11-09 18:33:48 UTC (rev 3881)
+++ trunk/sandbox/ui/orderingList/src/main/resources/org/richfaces/renderkit/html/css/orderingList.xcss 2007-11-09 18:48:52 UTC (rev 3882)
@@ -8,7 +8,7 @@
padding : 1px;
}
-.ol_headerlabel {
+.ol_captionlabel {
font-family : Arial;
font-size :11px;
font-weight : bold;
Modified: trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx
===================================================================
--- trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-09 18:33:48 UTC (rev 3881)
+++ trunk/sandbox/ui/orderingList/src/main/templates/org/richfaces/htmlOrderingList.jspx 2007-11-09 18:48:52 UTC (rev 3882)
@@ -26,6 +26,11 @@
<table id="#{clientId}table" cellpadding="0" cellspacing="0" class="ol_body">
<tbody>
<tr>
+ <td colspan="2">
+ <f:call name="encodeCaption"/>
+ </td>
+ </tr>
+ <tr>
<td>
<div id="#{clientId}headerBox" class="ol_list">
<div class="ol_list_header" style="width: #{component.attributes['listHeight']}px;">
18 years, 6 months
JBoss Rich Faces SVN: r3881 - in trunk/sandbox/samples/contextMenuDemo/src/main: webapp and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-11-09 13:33:48 -0500 (Fri, 09 Nov 2007)
New Revision: 3881
Added:
trunk/sandbox/samples/contextMenuDemo/src/main/webapp/META-INF/
trunk/sandbox/samples/contextMenuDemo/src/main/webapp/META-INF/MANIFEST.MF
Modified:
trunk/sandbox/samples/contextMenuDemo/src/main/java/org/richfaces/Bean.java
trunk/sandbox/samples/contextMenuDemo/src/main/webapp/pages/index.jsp
Log:
RF-1305
Modified: trunk/sandbox/samples/contextMenuDemo/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/sandbox/samples/contextMenuDemo/src/main/java/org/richfaces/Bean.java 2007-11-09 18:29:45 UTC (rev 3880)
+++ trunk/sandbox/samples/contextMenuDemo/src/main/java/org/richfaces/Bean.java 2007-11-09 18:33:48 UTC (rev 3881)
@@ -20,10 +20,56 @@
*/
package org.richfaces;
+
+import java.util.ArrayList;
+import java.util.List;
+
/**
- * @author $Autor$
- *
+ * @author k
+ *
*/
public class Bean {
-
+ public class Pair {
+
+ private String first = "first";
+ private String second = "second";
+
+ public Pair(int i) {
+ first = i + " first";
+ second = i + " second";
+ }
+
+ public void setFirst(String first) {
+ this.first = first;
+ }
+
+ public String getFirst() {
+ return first;
+ }
+
+ public void setSecond(String second) {
+ this.second = second;
+ }
+
+ public String getSecond() {
+ return second;
+ }
+ }
+
+ private List<Pair> model = new ArrayList<Pair>();
+
+ public Bean() {
+ for (int i = 0; i < 1000; i++) {
+ model.add(new Pair(i));
+ }
+ }
+
+ public List<Pair> getModel() {
+ return model;
+ }
+
+ public void setModel(List<Pair> model) {
+ this.model = model;
+ }
+
}
\ No newline at end of file
Added: trunk/sandbox/samples/contextMenuDemo/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- trunk/sandbox/samples/contextMenuDemo/src/main/webapp/META-INF/MANIFEST.MF (rev 0)
+++ trunk/sandbox/samples/contextMenuDemo/src/main/webapp/META-INF/MANIFEST.MF 2007-11-09 18:33:48 UTC (rev 3881)
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
Modified: trunk/sandbox/samples/contextMenuDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/contextMenuDemo/src/main/webapp/pages/index.jsp 2007-11-09 18:29:45 UTC (rev 3880)
+++ trunk/sandbox/samples/contextMenuDemo/src/main/webapp/pages/index.jsp 2007-11-09 18:33:48 UTC (rev 3881)
@@ -1,12 +1,47 @@
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<html>
<head>
- <title></title>
+ <title>
+ </title>
+ <style>
+ <!--
+.header {
+ background-color: graytext;
+}
+.footer {
+ background-color: gray;
+}
+ -->
+ </style>
</head>
<body>
<f:view>
-
+ <h:form>
+ <h:dataTable id="table" value="#{bean.model}" var="row" style="width:300px"
+ first="0" rows="40" width="100%">
+ <h:column headerClass="header" footerClass="footer">
+ <f:facet name="header">
+ <h:outputText value="First header"></h:outputText>
+ </f:facet>
+ <f:facet name="footer">
+ <h:outputText value="First footer"></h:outputText>
+ </f:facet>
+ <h:outputText value="#{row.first}"></h:outputText>
+ </h:column>
+ <h:column headerClass="header" footerClass="footer">
+ <f:facet name="header">
+ <h:outputText value="Second header"></h:outputText>
+ </f:facet>
+ <f:facet name="footer">
+ <h:outputText value="Second footer"></h:outputText>
+ </f:facet>
+ <h:outputText value="#{row.second}"></h:outputText>
+ </h:column>
+ </h:dataTable>
+ </h:form>
+
</f:view>
</body>
</html>
18 years, 6 months
JBoss Rich Faces SVN: r3880 - trunk/sandbox/samples.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-11-09 13:29:45 -0500 (Fri, 09 Nov 2007)
New Revision: 3880
Modified:
trunk/sandbox/samples/pom.xml
Log:
New demo: contextMenuDemo
Modified: trunk/sandbox/samples/pom.xml
===================================================================
--- trunk/sandbox/samples/pom.xml 2007-11-09 18:29:33 UTC (rev 3879)
+++ trunk/sandbox/samples/pom.xml 2007-11-09 18:29:45 UTC (rev 3880)
@@ -18,5 +18,6 @@
<module>orderingListDemo</module>
<module>listShuttleDemo</module>
<module>columnsDemo</module>
+ <module>contextMenuDemo</module>
</modules>
</project>
\ No newline at end of file
18 years, 6 months
JBoss Rich Faces SVN: r3879 - trunk/sandbox/ui.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-11-09 13:29:33 -0500 (Fri, 09 Nov 2007)
New Revision: 3879
Modified:
trunk/sandbox/ui/pom.xml
Log:
New component: contextMenu
Modified: trunk/sandbox/ui/pom.xml
===================================================================
--- trunk/sandbox/ui/pom.xml 2007-11-09 18:02:26 UTC (rev 3878)
+++ trunk/sandbox/ui/pom.xml 2007-11-09 18:29:33 UTC (rev 3879)
@@ -22,5 +22,6 @@
<module>rex-messageBox</module>
<!--module>rex-button</module-->
<!--module>componentControl</module-->
+ <module>contextMenu</module>
</modules>
</project>
\ No newline at end of file
18 years, 6 months
JBoss Rich Faces SVN: r3878 - management/design/orderingList.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-11-09 13:02:26 -0500 (Fri, 09 Nov 2007)
New Revision: 3878
Modified:
management/design/orderingList/FuncSpec - orderingList.doc
Log:
Optional items marked as OPT
Modified: management/design/orderingList/FuncSpec - orderingList.doc
===================================================================
(Binary files differ)
18 years, 6 months
JBoss Rich Faces SVN: r3877 - management/design/orderingList.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-11-09 13:01:09 -0500 (Fri, 09 Nov 2007)
New Revision: 3877
Modified:
management/design/orderingList/FuncSpec - orderingList.doc
Log:
Optional items marked as OPT
Modified: management/design/orderingList/FuncSpec - orderingList.doc
===================================================================
(Binary files differ)
18 years, 6 months