JBoss Rich Faces SVN: r17764 - root/ui-sandbox.
by richfaces-svn-commits@lists.jboss.org
Author: blabno
Date: 2010-07-07 16:15:49 -0400 (Wed, 07 Jul 2010)
New Revision: 17764
Added:
root/ui-sandbox/schedule/
Log:
Initial import of schedule component
14 years, 6 months
JBoss Rich Faces SVN: r17763 - branches/community/3.3.X/cdk/richfaces-facelets/src/main/resources/archetype-resources.
by richfaces-svn-commits@lists.jboss.org
Author: prabhat.jha(a)jboss.com
Date: 2010-07-07 12:02:44 -0400 (Wed, 07 Jul 2010)
New Revision: 17763
Modified:
branches/community/3.3.X/cdk/richfaces-facelets/src/main/resources/archetype-resources/pom.xml
Log:
adding -impl dependency because post 3.3.3 release, this needs to be set
Modified: branches/community/3.3.X/cdk/richfaces-facelets/src/main/resources/archetype-resources/pom.xml
===================================================================
--- branches/community/3.3.X/cdk/richfaces-facelets/src/main/resources/archetype-resources/pom.xml 2010-07-07 15:57:58 UTC (rev 17762)
+++ branches/community/3.3.X/cdk/richfaces-facelets/src/main/resources/archetype-resources/pom.xml 2010-07-07 16:02:44 UTC (rev 17763)
@@ -29,6 +29,11 @@
<groupId>org.richfaces.ui</groupId>
<artifactId>richfaces-ui</artifactId>
<version>3.3.4-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>richfaces-impl</artifactId>
+ <version>3.3.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
14 years, 6 months
JBoss Rich Faces SVN: r17761 - root/examples/iteration-demo/trunk/src/main/webapp.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-07 09:41:28 -0400 (Wed, 07 Jul 2010)
New Revision: 17761
Modified:
root/examples/iteration-demo/trunk/src/main/webapp/list.xhtml
Log:
Added dataScroller to lists demo
Modified: root/examples/iteration-demo/trunk/src/main/webapp/list.xhtml
===================================================================
--- root/examples/iteration-demo/trunk/src/main/webapp/list.xhtml 2010-07-07 13:40:35 UTC (rev 17760)
+++ root/examples/iteration-demo/trunk/src/main/webapp/list.xhtml 2010-07-07 13:41:28 UTC (rev 17761)
@@ -20,13 +20,15 @@
</h:form>
<h:form id="form1">
- <it:list var="item" value="#{dataBean.employeeList}" rows="20" type="#{listBean.listType}">
+ <it:list id="list" var="item" value="#{dataBean.employeeList}" rows="20" type="#{listBean.listType}">
<f:facet name="term">
#{item.EMail}
</f:facet>
-
+
#{item.name}
</it:list>
+
+ <it:dataScroller for="list" />
</h:form>
</h:body>
</html>
14 years, 6 months
JBoss Rich Faces SVN: r17760 - in root/ui/iteration/trunk/lists/ui/src: main/resources/META-INF/resources/org.richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-07 09:40:35 -0400 (Wed, 07 Jul 2010)
New Revision: 17760
Modified:
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java
Log:
https://jira.jboss.org/browse/RF-8852
Modified: root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java 2010-07-07 13:25:55 UTC (rev 17759)
+++ root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java 2010-07-07 13:40:35 UTC (rev 17760)
@@ -146,7 +146,7 @@
}
rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(), "rf-lst-d rf-dlst-d"));
+ HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(), "rf-lst-i rf-dlst-d"));
renderHandlers(context, sequence);
rendererUtils.encodeChildren(context, sequence);
writer.endElement(HTML.DD_ELEMENT);
Modified: root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss 2010-07-07 13:25:55 UTC (rev 17759)
+++ root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss 2010-07-07 13:40:35 UTC (rev 17760)
@@ -1,4 +1,4 @@
-.rf-lst-i, .rf-lst-t {
+.rf-lst-i, .rf-dlst-t, .rf-dlst-d {
font-size: '#{richSkin.generalSizeFont}';
font-family: '#{richSkin.generalFamilyFont}';
color: '#{richSkin.generalTextColor}';
Modified: root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java 2010-07-07 13:25:55 UTC (rev 17759)
+++ root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java 2010-07-07 13:40:35 UTC (rev 17760)
@@ -150,7 +150,7 @@
HtmlElement item = (HtmlElement) definitionItems.get(i);
assertEquals("dd", item.getNodeName());
- assertEquals("rf-lst-d rf-dlst-d", item.getAttribute("class"));
+ assertEquals("rf-lst-i rf-dlst-d", item.getAttribute("class"));
assertEquals(data.getDefinition(), item.asText());
}
}
14 years, 6 months
JBoss Rich Faces SVN: r17759 - in root/ui/iteration/trunk/lists/ui/src: main and 14 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-07 09:25:55 -0400 (Wed, 07 Jul 2010)
New Revision: 17759
Added:
root/ui/iteration/trunk/lists/ui/src/main/resources/
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/
root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss
root/ui/iteration/trunk/lists/ui/src/test/
root/ui/iteration/trunk/lists/ui/src/test/java/
root/ui/iteration/trunk/lists/ui/src/test/java/org/
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/Data.java
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/DataBean.java
root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java
root/ui/iteration/trunk/lists/ui/src/test/resources/
root/ui/iteration/trunk/lists/ui/src/test/resources/org/
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/faces-config.xml
root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml
Modified:
root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java
Log:
https://jira.jboss.org/browse/RF-8853
https://jira.jboss.org/browse/RF-8855
Modified: root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java 2010-07-07 12:55:57 UTC (rev 17758)
+++ root/ui/iteration/trunk/lists/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java 2010-07-07 13:25:55 UTC (rev 17759)
@@ -22,10 +22,12 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.Collections;
import java.util.Map;
import javax.faces.FacesException;
+import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -39,11 +41,13 @@
import org.richfaces.component.ListType;
import org.richfaces.component.UISequence;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.log.RichfacesLogger;
/**
* @author Nick Belaevski
- *
+ *
*/
+@ResourceDependency(library = "org.richfaces", name = "list.ecss")
public abstract class ListRendererBase extends Renderer {
private static final Map<String, ComponentAttribute> ROW_HANDLER_ATTRIBUTES = Collections
@@ -63,9 +67,9 @@
new ComponentAttribute(HTML.ONMOUSEOUT_ATTRIBUTE).setEventNames("rowmouseout").
setComponentAttributeName("onrowmouseout"),
new ComponentAttribute(HTML.ONKEYPRESS_ATTRIBUTE).setEventNames("rowkeypress").
- setComponentAttributeName("onrowkeypress"),
+ setComponentAttributeName("onrowkeypress"),
new ComponentAttribute(HTML.ONKEYDOWN_ATTRIBUTE).setEventNames("rowkeydown").
- setComponentAttributeName("onrowkeydown"),
+ setComponentAttributeName("onrowkeydown"),
new ComponentAttribute(HTML.ONKEYUP_ATTRIBUTE).setEventNames("rowkeyup").
setComponentAttributeName("onrowkeyup")
));
@@ -74,12 +78,12 @@
/**
* @author Nick Belaevski
- *
+ *
*/
private class SimpleItemsEncoder extends ItemsEncoder {
-
+
private String itemClass;
-
+
public SimpleItemsEncoder(String itemClass) {
super();
this.itemClass = itemClass;
@@ -113,7 +117,7 @@
/**
* @author Nick Belaevski
- *
+ *
*/
private final class DefinitionItemsEncoder extends ItemsEncoder {
@Override
@@ -122,7 +126,7 @@
ResponseWriter writer = context.getResponseWriter();
UIComponent termFacet = sequence.getFacet(AbstractList.TERM);
- if (termFacet != null && termFacet.isRendered()) {
+ if (termFacet != null) {
writer.startElement(HTML.DT_ELEMENT, sequence);
if (rendererUtils.hasExplicitId(sequence)) {
@@ -142,7 +146,7 @@
}
rendererUtils.writeAttribute(writer, HTML.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(), "rf-lst-i rf-dlst-i"));
+ HtmlUtil.concatClasses(helper.getRowClass(), helper.getColumnClass(), "rf-lst-d rf-dlst-d"));
renderHandlers(context, sequence);
rendererUtils.encodeChildren(context, sequence);
writer.endElement(HTML.DD_ELEMENT);
@@ -202,12 +206,12 @@
return "rf-lst rf-ulst";
case definitions:
return "rf-lst rf-dlst";
-
+
default:
throw new IllegalArgumentException(type.toString());
}
}
-
+
protected ItemsEncoder getItemsEncoderByType(ListType type) {
switch (type) {
case ordered:
@@ -216,17 +220,17 @@
return unorderedListItemsEncoder;
case definitions:
return definitionItemsEncoder;
-
+
default:
throw new IllegalArgumentException(type.toString());
}
}
-
+
protected ListType getType(UIComponent component) {
ListType type = ((AbstractList) component).getType();
if (type == null) {
- // TODO add component information
- throw new IllegalArgumentException("Type for rich:list is required!");
+ String exceptionMessage = MessageFormat.format("Type for rich:list {0} is required!", RichfacesLogger.getComponentPath(component));
+ throw new IllegalArgumentException(exceptionMessage);
}
return type;
@@ -234,7 +238,6 @@
protected String getStyleClass(UIComponent component, ListType listType) {
String styleClass = (String) component.getAttributes().get(HTML.STYLE_CLASS_ATTR);
- // TODO rf-* classes for different list types
return HtmlUtil.concatClasses(styleClass, getListClass(listType));
}
@@ -242,10 +245,10 @@
if (rendererUtils.hasExplicitId(component)) {
return component.getClientId(facesContext);
}
-
+
return null;
}
-
+
protected void encodeListItems(FacesContext context, UIComponent component, ListType listType)
throws IOException {
AbstractList list = (AbstractList) component;
Added: root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss (rev 0)
+++ root/ui/iteration/trunk/lists/ui/src/main/resources/META-INF/resources/org.richfaces/list.ecss 2010-07-07 13:25:55 UTC (rev 17759)
@@ -0,0 +1,5 @@
+.rf-lst-i, .rf-lst-t {
+ font-size: '#{richSkin.generalSizeFont}';
+ font-family: '#{richSkin.generalFamilyFont}';
+ color: '#{richSkin.generalTextColor}';
+}
\ No newline at end of file
Added: root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/Data.java
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/Data.java (rev 0)
+++ root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/Data.java 2010-07-07 13:25:55 UTC (rev 17759)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit;
+
+/**
+ * @author nick
+ *
+ */
+public class Data {
+
+ private String term;
+
+ private String definition;
+
+ public Data(String term, String definition) {
+ super();
+ this.term = term;
+ this.definition = definition;
+ }
+
+ public String getDefinition() {
+ return definition;
+ }
+
+ public String getTerm() {
+ return term;
+ }
+}
Added: root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/DataBean.java
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/DataBean.java (rev 0)
+++ root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/DataBean.java 2010-07-07 13:25:55 UTC (rev 17759)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author nick
+ *
+ */
+public class DataBean {
+
+ private List<Data> list = new ArrayList<Data>();
+
+ public DataBean() {
+ list.add(new Data("RF-8282", "jQuery 1.4 AJAX requests broken if using Richfaces"));
+ list.add(new Data("RF-6900", "scrollableDataTable: is getting broken after vertical scrolling"));
+ list.add(new Data("RF-6917", "scrollableDataTable: scroll + sort + F5 actions brake down the table at richfaces-demo"));
+ list.add(new Data("RF-6920", "scrollableDataTable: scroll + rerender + F5 causes to enpty selection in FF3"));
+ list.add(new Data("RF-7695", "Error rendering extendedDataTable on tab panel when switch type is ajax. in Google Chrome"));
+ list.add(new Data("RF-8072", "ExtendedDataTable : the table bugs when the navigator is resized"));
+ list.add(new Data("RF-8143", "suggestionBox: submit the page when you choose a list iten in Opera"));
+ list.add(new Data("RF-8490", "Editor can't be updated via ajax in Chrome"));
+ list.add(new Data("RF-8521", "context menu doesn't show with rightclickselection in FF OS X"));
+ list.add(new Data("RF-8536", "fileUpload does not always complete in IE8"));
+ list.add(new Data("RF-2580", "orderingList, listShuttle, pickList: buttons sometimes don't work if mouse cursor is above some special areas of the button"));
+ list.add(new Data("RF-3220", "InplaceInput: \"editEvent\" attribute with value \"ondblclick\" doesn't work on Opera 9.25"));
+ list.add(new Data("RF-3398", "InplaceSelect: Broken under Opera."));
+ list.add(new Data("RF-3504", "InputNumberSpinner: Doesn't work after reRender in Opera."));
+ list.add(new Data("RF-3704", "InplaceInput component: part of defaultLabel displays in the page (only for IE6)"));
+ list.add(new Data("RF-5285", "PickList: onlistchanged, onkeypress, onblur events do not work in some browsers."));
+ list.add(new Data("RF-6926", "Tree: rightClickSelection attribute does not work in Safari and Opera."));
+ list.add(new Data("RF-6967", "InputNumberSpinner: disableBrowserAutoComplete works wrong"));
+ list.add(new Data("RF-7063", "Editor: Use Seam Text mode is work incorrectly in safari and google chrome"));
+ list.add(new Data("RF-7100", "colorPicker: input and color box are missaligned"));
+ list.add(new Data("RF-7162", "realworld/images/Opera: Unordered list and Ordered list icons work incorrectly"));
+ list.add(new Data("RF-7169", "scrollableDataTable: first column disappears after crolling"));
+ list.add(new Data("RF-7187", "InplaceInput attribute selectOnEdit not worked in Safari/Chrome2"));
+ list.add(new Data("RF-7663", "scrollableDataTable: onRowDblClick and onRowClick events is triggered once after sorting in safari"));
+ list.add(new Data("RF-7664", "colorPicker is opened up with flat=\"true\" in ie 7"));
+ }
+
+ public List<Data> getList() {
+ return list;
+ }
+
+ public List<Data> getEmptyList() {
+ return Collections.emptyList();
+ }
+}
Added: root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java (rev 0)
+++ root/ui/iteration/trunk/lists/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java 2010-07-07 13:25:55 UTC (rev 17759)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author nick
+ *
+ */
+public class ListRendererTest {
+
+ private HtmlUnitEnvironment environment;
+
+ private DataBean testBean;
+
+ @Before
+ public void setUp() {
+ environment = new HtmlUnitEnvironment();
+
+ environment.withResource("/WEB-INF/faces-config.xml", "org/richfaces/renderkit/faces-config.xml");
+ environment.withResource("/test.xhtml", "org/richfaces/renderkit/rendererTest.xhtml");
+
+ environment.start();
+
+ testBean = new DataBean();
+ }
+
+ @After
+ public void tearDown() {
+ environment.release();
+ environment = null;
+
+ testBean = null;
+ }
+
+ @Test
+ public void testOrderedList() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ List<?> nodes = page.getByXPath("//*[@id = 'form:ol']");
+
+ assertEquals(1, nodes.size());
+ HtmlElement list = (HtmlElement) nodes.get(0);
+ assertEquals("ol", list.getNodeName());
+ assertEquals("rf-lst rf-olst", list.getAttribute(HTML.CLASS_ATTRIBUTE));
+ verifySimpleListItems(list, "rf-lst-i rf-olst-i");
+ }
+
+ @Test
+ public void testUnorderedList() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ List<?> nodes = page.getByXPath("//*[@id = 'form:ul']");
+
+ assertEquals(1, nodes.size());
+ HtmlElement list = (HtmlElement) nodes.get(0);
+
+ assertEquals("ul", list.getNodeName());
+ assertEquals("rf-lst rf-ulst", list.getAttribute(HTML.CLASS_ATTRIBUTE));
+ verifySimpleListItems((HtmlElement) list, "rf-lst-i rf-ulst-i");
+ }
+
+ @Test
+ public void testDefinitionsList() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ List<?> nodes = page.getByXPath("//*[@id = 'form:dl']");
+
+ assertEquals(1, nodes.size());
+ HtmlElement list = (HtmlElement) nodes.get(0);
+ assertEquals("dl", list.getNodeName());
+ verifyDefinitionsListItems(list);
+ }
+
+ @Test
+ public void testFakeItem() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ List<?> nodes = page.getByXPath("//*[@id = 'form:emptyList']");
+
+ assertEquals(1, nodes.size());
+ HtmlElement list = (HtmlElement) nodes.get(0);
+ assertEquals("ol", list.getNodeName());
+
+ HtmlElement fakeItem = (HtmlElement) list.getFirstByXPath("li");
+ assertNotNull(fakeItem);
+ assertEquals("display:none", fakeItem.getAttribute("style"));
+ }
+
+ private void verifySimpleListItems(HtmlElement listElement, String styleClass) {
+ List<?> listItems = listElement.getByXPath("li");
+ assertEquals(testBean.getList().size(), listItems.size());
+ for (int i = 0; i < listItems.size(); i++) {
+ Data data = testBean.getList().get(i);
+
+ HtmlElement item = (HtmlElement) listItems.get(i);
+
+ assertEquals("li", item.getNodeName());
+ assertEquals(styleClass, item.getAttribute("class"));
+ assertEquals(data.getTerm(), item.asText());
+ }
+ }
+
+ private void verifyDefinitionsListItems(HtmlElement listElement) {
+ List<?> termItems = listElement.getByXPath("dt");
+ List<?> definitionItems = listElement.getByXPath("dd");
+
+ assertEquals(testBean.getList().size(), termItems.size());
+ assertEquals(testBean.getList().size(), definitionItems.size());
+
+ for (int i = 0; i < termItems.size(); i++) {
+ Data data = testBean.getList().get(i);
+
+ HtmlElement item = (HtmlElement) termItems.get(i);
+ assertEquals("dt", item.getNodeName());
+ assertEquals("rf-lst-t rf-dlst-t", item.getAttribute("class"));
+ assertEquals(data.getTerm(), item.asText());
+ }
+
+ for (int i = 0; i < definitionItems.size(); i++) {
+ Data data = testBean.getList().get(i);
+
+ HtmlElement item = (HtmlElement) definitionItems.get(i);
+ assertEquals("dd", item.getNodeName());
+ assertEquals("rf-lst-d rf-dlst-d", item.getAttribute("class"));
+ assertEquals(data.getDefinition(), item.asText());
+ }
+ }
+}
+
Added: root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/faces-config.xml
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/faces-config.xml (rev 0)
+++ root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/faces-config.xml 2010-07-07 13:25:55 UTC (rev 17759)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ version="2.0">
+
+ <managed-bean>
+ <managed-bean-name>dataBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.renderkit.DataBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+</faces-config>
\ No newline at end of file
Added: root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml
===================================================================
--- root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml (rev 0)
+++ root/ui/iteration/trunk/lists/ui/src/test/resources/org/richfaces/renderkit/rendererTest.xhtml 2010-07-07 13:25:55 UTC (rev 17759)
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:lst="http://richfaces.org/lists">
+<f:view contentType="text/html" />
+
+<h:head>
+ <title>Richfaces List</title>
+</h:head>
+
+<h:body>
+ <h:form id="form">
+ <lst:list id="ol" var="item" value="#{dataBean.list}" type="ordered">
+ #{item.term}
+ </lst:list>
+
+ <lst:list id="ul" var="item" value="#{dataBean.list}" type="unordered">
+ #{item.term}
+ </lst:list>
+
+ <lst:list id="dl" var="item" value="#{dataBean.list}" type="definitions">
+ <f:facet name="term">
+ #{item.term}
+ </f:facet>
+ #{item.definition}
+ </lst:list>
+
+ <lst:list id="emptyList" type="ordered" />
+ </h:form>
+</h:body>
+</html>
14 years, 6 months
JBoss Rich Faces SVN: r17758 - in root/ui-sandbox/inputs/trunk/combobox/src/main: resources/META-INF/resources/org.richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-07-07 08:55:57 -0400 (Wed, 07 Jul 2010)
New Revision: 17758
Removed:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/richfaces-selection.js
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.ecss
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js
Log:
https://jira.jboss.org/browse/RF-8875
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java 2010-07-07 11:46:04 UTC (rev 17757)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/java/org/richfaces/renderkit/ComboBoxRendererBase.java 2010-07-07 12:55:57 UTC (rev 17758)
@@ -49,7 +49,7 @@
@ResourceDependency(name = "richfaces.js"),
@ResourceDependency(name = "richfaces-event.js"),
@ResourceDependency(name = "richfaces-base-component.js"),
- @ResourceDependency(library = "org.richfaces", name = "richfaces-selection.js"),
+ @ResourceDependency(name = "richfaces-selection.js"),
@ResourceDependency(library = "org.richfaces", name = "SelectBase.js"),
@ResourceDependency(library = "org.richfaces", name = "ComboBox.js"),
@ResourceDependency(library = "org.richfaces", name = "ComboBox.ecss")
@@ -108,7 +108,7 @@
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HTML.LI_ELEMENT, comboBox);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "cb_option cb_font", null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "cb_option cb_font rf-ac-i", null);
if (comboBox.getChildCount() > 0) {
for (UIComponent child: comboBox.getChildren()) {
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.ecss
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.ecss 2010-07-07 11:46:04 UTC (rev 17757)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.ecss 2010-07-07 12:55:57 UTC (rev 17758)
@@ -13,7 +13,8 @@
}
.cb_list_height {
- height: 100px;
+ max-height: 100px;
+ min-height: 20px;
}
input.cb_font {
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js 2010-07-07 11:46:04 UTC (rev 17757)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/ComboBox.js 2010-07-07 12:55:57 UTC (rev 17758)
@@ -71,7 +71,9 @@
var defaultOptions = {
selectedItemClass:'cb_select',
- autoFill:true
+ autoFill:true,
+ minChars:0,
+ selectFirst:false
};
var ID = {
@@ -80,16 +82,14 @@
};
var bindEventHandlers = function () {
- rf.Event.bindById(this.componentId+ID.ITEMS, "mouseover"+this.namespace, onMouseOver, this);
+ rf.Event.bind(rf.getDomElement(this.componentId+ID.ITEMS).parentNode, "mouseover"+this.namespace, onMouseOver, this);
};
var onMouseOver = function(event) {
- //console && console.log && console.log("mouseOver");
- var element = event.target;
- while (element.parentNode && element.parentNode!=event.currentTarget) {
- element = element.parentNode;
- };
- if (element.parentNode) {
+ console && console.log && console.log("mouseOver");
+ var element = $(event.target).closest(".rf-ac-i", event.currentTarget).get(0);
+
+ if (element) {
var index = this.items.index(element);
if (index!=this.index) {
this.selectItem(index);
@@ -98,7 +98,7 @@
};
var updateItemsList = function (value) {
- this.items = $(rf.getDomElement(this.componentId+ID.ITEMS)).children();
+ this.items = $(rf.getDomElement(this.componentId+ID.ITEMS)).find(".rf-ac-i");
this.cache = new rf.utils.Cache(this.items, {
parse: getData,
key: value
@@ -118,7 +118,7 @@
this.items.slice(0, this.index).each(function() {
offset += this.offsetHeight;
});
- var itemsContainer = this.items.first().parent();
+ var itemsContainer = this.items.first().parent().parent();
if(offset < itemsContainer.scrollTop()) {
itemsContainer.scrollTop(offset);
} else {
@@ -143,7 +143,8 @@
name:"CompoBox",
destroy: function () {
//TODO: add all unbind
- $super.destroy.call(this);
+ rf.Event.unbind(rf.getDomElement(this.componentId+ID.ITEMS).parentNode, this.namespace);
+ $super.destroy.call(this);
},
getNamespace: function () {
return this.namespace;
@@ -204,16 +205,21 @@
this.selectItem();
var newItems = this.cache.getItems(value);
this.items = $(newItems);
+ //TODO: works only with simple markup, not with <tr>
$(rf.getDomElement(this.componentId+ID.ITEMS)).empty().append(newItems);
this.index = -1;
this.newValue = value;
- this.selectItem(0, false, event.which == rf.KEYS.BACKSPACE);
+ if (this.options.selectFirst) {
+ this.selectItem(0, false, event.which == rf.KEYS.BACKSPACE);
+ }
},
onShow: function (event) {
if (this.items && this.items.length>0) {
//??TODO it's nessesary only if not changed value
- this.selectItem(0);
+ if (this.options.selectFirst) {
+ this.selectItem(0);
+ }
}
},
Deleted: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/richfaces-selection.js
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/richfaces-selection.js 2010-07-07 11:46:04 UTC (rev 17757)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/richfaces-selection.js 2010-07-07 12:55:57 UTC (rev 17758)
@@ -1,45 +0,0 @@
-(function (richfaces) {
-
- richfaces.Selection = richfaces.Selection || {};
-
- richfaces.Selection.set = function (field, start, end) {
- if(field.setSelectionRange) {
- field.focus();
- field.setSelectionRange(start, end);
- } else if (field.createTextRange){
- var range = field.createTextRange();
- range.collapse(true);
- range.moveEnd('character', end);
- range.moveStart('character', start);
- range.select();
- }
- }
-
- richfaces.Selection.getStart = function(field)
- {
- if (field.setSelectionRange) {
- return field.selectionStart;
- } else if (document.selection && document.selection.createRange) {
- var r = document.selection.createRange().duplicate();
- r.moveEnd('character', field.value.length);
- if (r.text == '') return field.value.length;
- return field.value.lastIndexOf(r.text);
- }
- }
-
- richfaces.Selection.getEnd = function(field)
- {
- if (field.setSelectionRange) {
- return field.selectionEnd;
- } else if (document.selection && document.selection.createRange) {
- var r = document.selection.createRange().duplicate();
- r.moveStart('character', -field.value.length);
- return r.text.length;
- }
- }
-
- richfaces.Selection.setCaretTo = function (field, pos)
- {
- richfaces.Selection.set(field, pos, pos);
- }
-})(window.RichFaces || (window.RichFaces={}));
\ No newline at end of file
14 years, 6 months
JBoss Rich Faces SVN: r17757 - in root/core/trunk: impl/src/main/java/org/ajax4jsf/context and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-07-07 07:46:04 -0400 (Wed, 07 Jul 2010)
New Revision: 17757
Removed:
root/core/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java
Modified:
root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
root/core/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
Log:
RF-8745 TogglePanel component
Modified: root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
===================================================================
--- root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2010-07-07 11:35:05 UTC (rev 17756)
+++ root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2010-07-07 11:46:04 UTC (rev 17757)
@@ -63,6 +63,8 @@
public abstract void setOncomplete(Object oncompleteFunction);
+ public abstract void appendOncomplete(Object oncompleteFunction);
+
public abstract Object getOncomplete();
public abstract void setOnbeforedomupdate(Object onbeforedomupdateFunction);
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-07-07 11:35:05 UTC (rev 17756)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-07-07 11:46:04 UTC (rev 17757)
@@ -575,6 +575,18 @@
this.oncomplete = oncomplete;
}
+ public void appendOncomplete(Object onComplete) {
+ StringBuilder res = new StringBuilder();
+ if (this.oncomplete != null) {
+ res.append(this.oncomplete);
+ res.append(';');
+ }
+
+ res.append(onComplete).append(';');
+
+ this.oncomplete = res.toString();
+ }
+
/* (non-Javadoc)
* @see org.ajax4jsf.context.AjaxContext#getOnbeforedomupdate()
*/
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2010-07-07 11:35:05 UTC (rev 17756)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2010-07-07 11:46:04 UTC (rev 17757)
@@ -76,12 +76,14 @@
/**
* Substitutions for components properies names and HTML attributes names.
*/
- private static Map<String, String> substitutions = new HashMap<String, String>();
- private static Set<String> requiredAttributes = new HashSet<String>();
+ private static final Map<String, String> SUBSTITUTIONS = new HashMap<String, String>();
+
+ private static final Set<String> REQUIRED_ATTRIBUTES = new HashSet<String>();
static {
- substitutions.put(HTML.CLASS_ATTRIBUTE, "styleClass");
- requiredAttributes.add(HTML.ALT_ATTRIBUTE);
+ SUBSTITUTIONS.put(HTML.CLASS_ATTRIBUTE, "styleClass");
+
+ REQUIRED_ATTRIBUTES.add(HTML.ALT_ATTRIBUTE);
Arrays.sort(HTML.PASS_THRU);
Arrays.sort(HTML.PASS_THRU_EVENTS);
@@ -460,12 +462,12 @@
}
public boolean shouldRenderAttribute(String attributeName, Object attributeVal) {
- if (!requiredAttributes.contains(attributeName)) {
- return shouldRenderAttribute(attributeVal);
- } else {
- if (null == attributeVal) {
+ if (REQUIRED_ATTRIBUTES.contains(attributeName)) {
+ if (attributeVal == null) {
return false;
}
+ } else {
+ return shouldRenderAttribute(attributeVal);
}
return true;
@@ -604,7 +606,7 @@
* @return
*/
protected Object getComponentAttributeName(Object key) {
- Object converted = substitutions.get(key);
+ Object converted = SUBSTITUTIONS.get(key);
if (null == converted) {
return key;
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java 2010-07-07 11:35:05 UTC (rev 17756)
+++ root/core/trunk/impl/src/main/java/org/richfaces/component/UISwitchablePanel.java 2010-07-07 11:46:04 UTC (rev 17757)
@@ -1,261 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.richfaces.event.SwitchablePanelSwitchEvent;
-
-import javax.el.ValueExpression;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.event.ValueChangeEvent;
-import java.util.Iterator;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 23.01.2007
- */
-public abstract class UISwitchablePanel extends UIInput {
-
- /**
- * value for tab change method - ajax tabs
- */
- public static final String AJAX_METHOD = "ajax";
-
- /**
- * value for tab change method for - client-side tabs.
- */
- public static final String CLIENT_METHOD = "client";
-
- /**
- * value for tab change method - server-side tabs
- */
- public static final String SERVER_METHOD = "server";
-
- /**
- * default tab change method - server.
- */
- public static final String DEFAULT_METHOD = SERVER_METHOD;
- private String switchType;
-
- public String getSwitchType() {
- if (this.switchType != null) {
- return switchType;
- }
-
- ValueExpression switchTypeExpression = getValueExpression("switchType");
-
- if (switchTypeExpression != null) {
- return (String) switchTypeExpression.getValue(FacesContext.getCurrentInstance().getELContext());
- }
-
- return DEFAULT_METHOD;
- }
-
- public void setSwitchType(String switchType) {
- this.switchType = switchType;
- }
-
- public Object convertSwitchValue(UIComponent component, Object object) {
- return object;
- }
-
- public void queueEvent(FacesEvent event) {
- if ((event instanceof SwitchablePanelSwitchEvent) && this.equals(event.getComponent())) {
- if (isImmediate()) {
- event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
- } else {
- event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
- }
- }
-
- super.queueEvent(event);
- }
-
- public void broadcast(FacesEvent facesEvent) throws AbortProcessingException {
- if (facesEvent instanceof ActionEvent) {
-
- // TODO invoke action listener or remove it
- if (isImmediate()) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
-
- facesContext.renderResponse();
- }
- } // TODO else here
-
- if (facesEvent instanceof SwitchablePanelSwitchEvent) {
- if (isRendered()) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- SwitchablePanelSwitchEvent switchEvent = (SwitchablePanelSwitchEvent) facesEvent;
- Object newValue = convertSwitchValue(switchEvent.getEventSource(), switchEvent.getValue());
- Object oldValue = getValue();
-
- if (((oldValue == null) && (newValue != null)) || ((oldValue != null) && !oldValue.equals(newValue))) {
- queueEvent(new ValueChangeEvent(this, oldValue, newValue));
- }
-
- // TODO UIInput should update the model, not the switchable panel itself
- ValueExpression valueBinding = getValueExpression("value");
-
- if (valueBinding != null) {
- valueBinding.setValue(facesContext.getELContext(), newValue);
- setValue(null);
- setLocalValueSet(false);
- } else {
- setValue(newValue);
- }
-
- if (AjaxRendererUtils.isAjaxRequest(facesContext)
-
- /* && this.getSwitchType().equals(AJAX_METHOD) */
- ) { // RF-7292
- AjaxRendererUtils.addRegionByName(facesContext, this, this.getId());
- }
- }
- } else /* component should throw IllegalArgumentException for unknown events - RF-30 */ {
- super.broadcast(facesEvent);
- }
- }
-
- public void updateModel(FacesContext context) {
-
- // no processing here
- }
-
- protected Iterator<UIComponent> getSwitchedFacetsAndChildren() {
- return getFacetsAndChildren();
- }
-
- public void processDecodes(FacesContext context) {
- if (context == null) {
- throw new NullPointerException("FacesContext is null!");
- }
-
- if (!isRendered()) {
- return;
- }
-
- // Process all facets and children of this component
- Iterator<UIComponent> kids = getSwitchedFacetsAndChildren();
-
- while (kids.hasNext()) {
- UIComponent kid = kids.next();
-
- kid.processDecodes(context);
- }
-
- try {
- decode(context);
-
- if (isImmediate()) {
- validate(context);
- }
- } catch (RuntimeException e) {
- context.renderResponse();
-
- throw e;
- }
- }
-
- public void processUpdates(FacesContext context) {
- if (context == null) {
- throw new NullPointerException("FacesContext is null!");
- }
-
- if (!isRendered()) {
- return;
- }
-
- Iterator<UIComponent> kids = getSwitchedFacetsAndChildren();
-
- while (kids.hasNext()) {
- UIComponent kid = kids.next();
-
- kid.processUpdates(context);
- }
-
- try {
- updateModel(context);
-
- if (!isValid()) {
- context.renderResponse();
- }
- } catch (RuntimeException e) {
- context.renderResponse();
-
- throw e;
- }
- }
-
- public void processValidators(FacesContext context) {
- if (context == null) {
- throw new NullPointerException("FacesContext is null!");
- }
-
- if (!isRendered()) {
- return;
- }
-
- Iterator<UIComponent> kids = getSwitchedFacetsAndChildren();
-
- while (kids.hasNext()) {
- UIComponent kid = (UIComponent) kids.next();
-
- kid.processValidators(context);
- }
-
- try {
- if (!isImmediate()) {
- validate(context);
-
- if (!isValid()) {
- context.renderResponse();
- }
- }
- } catch (RuntimeException e) {
- context.renderResponse();
-
- throw e;
- }
- }
-
- public Object saveState(FacesContext context) {
- Object[] states = new Object[2];
-
- states[0] = super.saveState(context);
- states[1] = switchType;
-
- return states;
- }
-
- public void restoreState(FacesContext context, Object state) {
- Object[] states = (Object[]) state;
-
- super.restoreState(context, states[0]);
- this.switchType = (String) states[1];
- }
-}
Modified: root/core/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2010-07-07 11:35:05 UTC (rev 17756)
+++ root/core/trunk/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2010-07-07 11:46:04 UTC (rev 17757)
@@ -271,7 +271,7 @@
//TODO - review
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
ajaxContext.setOnbeforedomupdate(callback.getOnbeforedomupdate());
- ajaxContext.setOncomplete(callback.getOncomplete());
+ ajaxContext.appendOncomplete(callback.getOncomplete());
ajaxContext.setResponseData(callback.getData());
}
} else {
14 years, 6 months
JBoss Rich Faces SVN: r17755 - in root/ui-sandbox/panels/trunk/ui/src/main: java and 9 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-07-07 07:32:06 -0400 (Wed, 07 Jul 2010)
New Revision: 17755
Added:
root/ui-sandbox/panels/trunk/ui/src/main/java/
root/ui-sandbox/panels/trunk/ui/src/main/java/org/
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractDivPanel.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/Method.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UIDivPanel.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanel.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/behavior/
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlDivPanel.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlTogglePanel.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlTogglePanelItem.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/MethodExpressionSelectedItemChangeListener.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/SelectedItemChangeEvent.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/SelectedItemChangeListener.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelItemRenderer.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/taglib/
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/taglib/SelectedItemChangeListenerHandler.java
root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/taglib/TogglePanelTagHandler.java
Log:
RF-8745 TogglePanel component
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractDivPanel.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractDivPanel.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractDivPanel.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIOutput;
+
+/**
+ * @author akolonitsky
+ * @version 1.0
+ * @since -4712-01-01
+ *
+ */
+public abstract class AbstractDivPanel extends UIOutput {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panels.DivPanel";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.panels.DivPanel";
+
+ protected AbstractDivPanel() {
+ setRendererType("org.richfaces.panels.DivPanelRenderer");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+}
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,641 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import org.richfaces.event.SelectedItemChangeEvent;
+import org.richfaces.event.SelectedItemChangeListener;
+
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.EditableValueHolder;
+//import javax.faces.component.MessageFactory;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UpdateModelException;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.event.ExceptionQueuedEvent;
+import javax.faces.event.ExceptionQueuedEventContext;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PostValidateEvent;
+import javax.faces.event.PreValidateEvent;
+import javax.faces.event.ValueChangeListener;
+import javax.faces.validator.Validator;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author akolonitsky
+ * @version 1.0
+ * @since -4712-01-01
+ */
+public abstract class AbstractTogglePanel extends AbstractDivPanel implements EditableValueHolder {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panels.TogglePanel";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.panels.TogglePanel";
+
+ public static final String UPDATE_MESSAGE_ID =
+ "javax.faces.component.UIInput.UPDATE";
+
+ private String submittedSelectedItem = null;
+
+ private enum PropertyKeys {
+ localValueSet,
+ required,
+ valid,
+ immediate
+ }
+
+ protected AbstractTogglePanel() {
+ setRendererType("org.richfaces.panels.TogglePanelRenderer");
+ }
+
+
+ // -------------------------------------------------- Editable Value Holder
+
+ public Object getSubmittedValue() {
+ return this.submittedSelectedItem;
+ }
+
+ public void resetValue() {
+ this.setValue(null);
+ this.setSubmittedValue(null);
+ this.setLocalValueSet(false);
+ this.setValid(true);
+ }
+
+ public void setSubmittedValue(Object submittedValue) {
+ this.submittedSelectedItem = String.valueOf(submittedValue);
+ }
+
+ /**
+ * Return the "local value set" state for this component.
+ * Calls to <code>setValue()</code> automatically reset
+ * this property to <code>true</code>.
+ */
+ public boolean isLocalValueSet() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.localValueSet, false);
+ }
+
+ /**
+ * Sets the "local value set" state for this component.
+ */
+ public void setLocalValueSet(boolean localValueSet) {
+ getStateHelper().put(PropertyKeys.localValueSet, localValueSet);
+ }
+
+ public boolean isValid() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.valid, true);
+ }
+
+
+ public void setValid(boolean valid) {
+ getStateHelper().put(PropertyKeys.valid, valid);
+ }
+
+ /**
+ * <p>Return the "required field" state for this component.</p>
+ */
+ public boolean isRequired() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.required, false);
+ }
+
+ /**
+ * <p>Set the "required field" state for this component.</p>
+ *
+ * @param required The new "required field" state
+ */
+ public void setRequired(boolean required) {
+ getStateHelper().put(PropertyKeys.required, required);
+ }
+
+
+ public boolean isImmediate() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.immediate, false);
+ }
+
+
+ public void setImmediate(boolean immediate) {
+ getStateHelper().put(PropertyKeys.immediate, immediate);
+ }
+
+ public MethodBinding getValidator() {
+ throw new UnknownError();
+ }
+
+ public void setValidator(MethodBinding validatorBinding) {
+ throw new UnknownError();
+ }
+
+ public MethodBinding getValueChangeListener() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setValueChangeListener(MethodBinding valueChangeMethod) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addValidator(Validator validator) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Validator[] getValidators() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeValidator(Validator validator) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addValueChangeListener(ValueChangeListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ public ValueChangeListener[] getValueChangeListeners() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeValueChangeListener(ValueChangeListener listener) {
+ throw new UnsupportedOperationException();
+ }
+
+ // ----------------------------------------------------- UIComponent Methods
+
+ /**
+ * <p>Specialized decode behavior on top of that provided by the
+ * superclass. In addition to the standard
+ * <code>processDecodes</code> behavior inherited from {@link
+ * javax.faces.component.UIComponentBase}, calls <code>validate()</code> if the the
+ * <code>immediate</code> property is true; if the component is
+ * invalid afterwards or a <code>RuntimeException</code> is thrown,
+ * calls {@link FacesContext#renderResponse}. </p>
+ *
+ * @throws NullPointerException {@inheritDoc}
+ */
+ @Override
+ public void processDecodes(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Skip processing if our rendered flag is false
+ if (!isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(context, null);
+
+ // Process all facets and children of this component
+ Iterator<UIComponent> kids = getFacetsAndChildren();
+ while (kids.hasNext()) {
+ UIComponent kid = kids.next();
+ if (isSelectedItem(kid)) {
+ kid.processDecodes(context);
+ }
+ }
+
+ // Process this component itself
+ try {
+ decode(context);
+ } catch (RuntimeException e) {
+ context.renderResponse();
+ throw e;
+ } finally {
+ popComponentFromEL(context);
+ }
+
+ if (isImmediate()) {
+ executeValidate(context);
+ }
+ }
+
+ /**
+ * <p>In addition to the standard <code>processValidators</code> behavior
+ * inherited from {@link javax.faces.component.UIComponentBase}, calls <code>validate()</code>
+ * if the <code>immediate</code> property is false (which is the
+ * default); if the component is invalid afterwards, calls
+ * {@link FacesContext#renderResponse}.
+ * If a <code>RuntimeException</code> is thrown during
+ * validation processing, calls {@link FacesContext#renderResponse}
+ * and re-throw the exception.
+ * </p>
+ *
+ * @throws NullPointerException {@inheritDoc}
+ */
+ @Override
+ public void processValidators(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Skip processing if our rendered flag is false
+ if (!isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(context, null);
+
+ Application app = context.getApplication();
+ app.publishEvent(context, PreValidateEvent.class, this);
+ // Process all the facets and children of this component
+ Iterator<UIComponent> kids = getFacetsAndChildren();
+ while (kids.hasNext()) {
+ UIComponent kid = kids.next();
+ if (isSelectedItem(kid)) {
+ kid.processValidators(context);
+ }
+ }
+ app.publishEvent(context, PostValidateEvent.class, this);
+ popComponentFromEL(context);
+
+ if (!isImmediate()) {
+ executeValidate(context);
+ }
+ }
+
+ /**
+ * <p>In addition to the standard <code>processUpdates</code> behavior
+ * inherited from {@link javax.faces.component.UIComponentBase}, calls
+ * <code>updateModel()</code>.
+ * If the component is invalid afterwards, calls
+ * {@link FacesContext#renderResponse}.
+ * If a <code>RuntimeException</code> is thrown during
+ * update processing, calls {@link FacesContext#renderResponse}
+ * and re-throw the exception.
+ * </p>
+ *
+ * @throws NullPointerException {@inheritDoc}
+ */
+ @Override
+ public void processUpdates(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Skip processing if our rendered flag is false
+ if (!isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(context, null);
+
+ // Process all facets and children of this component
+ Iterator<UIComponent> kids = getFacetsAndChildren();
+ while (kids.hasNext()) {
+ UIComponent kid = kids.next();
+ if (isSelectedItem(kid)) {
+ kid.processUpdates(context);
+ }
+ }
+
+ popComponentFromEL(context);
+
+ try {
+ updateModel(context);
+ } catch (RuntimeException e) {
+ context.renderResponse();
+ throw e;
+ }
+
+ if (!isValid()) {
+ context.renderResponse();
+ }
+ }
+
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ */
+ @Override
+ public void decode(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Force validity back to "true"
+ setValid(true);
+ super.decode(context);
+ }
+
+ /**
+ * <p><span class="changed_modified_2_0">Perform</span>
+ * the following algorithm to update the model data
+ * associated with this {@link javax.faces.component.UIInput}, if any, as appropriate.</p>
+ * <ul>
+ * <li>If the <code>valid</code> property of this component is
+ * <code>false</code>, take no further action.</li>
+ * <li>If the <code>localValueSet</code> property of this component is
+ * <code>false</code>, take no further action.</li>
+ * <li>If no {@link javax.el.ValueExpression} for <code>value</code> exists,
+ * take no further action.</li>
+ * <li>Call <code>setValue()</code> method of the {@link javax.el.ValueExpression}
+ * to update the value that the {@link javax.el.ValueExpression} points at.</li>
+ * <li>If the <code>setValue()</code> method returns successfully:
+ * <ul>
+ * <li>Clear the local value of this {@link javax.faces.component.UIInput}.</li>
+ * <li>Set the <code>localValueSet</code> property of this
+ * {@link javax.faces.component.UIInput} to false.</li>
+ * </ul></li>
+ * <li>If the <code>setValue()</code> method throws an Exception:
+ * <ul>
+ * <li class="changed_modified_2_0">Enqueue an error message. Create a
+ * {@link javax.faces.application.FacesMessage} with the id {@link #UPDATE_MESSAGE_ID}. Create a
+ * {@link javax.faces.component.UpdateModelException}, passing the <code>FacesMessage</code> and
+ * the caught exception to the constructor. Create an
+ * {@link javax.faces.event.ExceptionQueuedEventContext}, passing the <code>FacesContext</code>,
+ * the <code>UpdateModelException</code>, this component instance, and
+ * {@link javax.faces.event.PhaseId#UPDATE_MODEL_VALUES} to its constructor. Call
+ * {@link FacesContext#getExceptionHandler} and then call
+ * {@link javax.faces.context.ExceptionHandler#processEvent}, passing the
+ * <code>ExceptionQueuedEventContext</code>.
+ * </li>
+ * <li>Set the <code>valid</code> property of this {@link javax.faces.component.UIInput}
+ * to <code>false</code>.</li>
+ * </ul></li>
+ * The exception must not be re-thrown. This enables tree traversal
+ * to continue for this lifecycle phase, as in all the other lifecycle
+ * phases.
+ * </ul>
+ *
+ * @param context {@link FacesContext} for the request we are processing
+ * @throws NullPointerException if <code>context</code>
+ * is <code>null</code>
+ */
+ public void updateModel(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (!isValid() || !isLocalValueSet()) {
+ return;
+ }
+
+ ValueExpression ve = getValueExpression("value");
+ if (ve == null) {
+ return;
+ }
+
+ Throwable caught = null;
+ FacesMessage message = null;
+ try {
+ ve.setValue(context.getELContext(), getLocalValue());
+ setValue(null);
+ setLocalValueSet(false);
+ } catch (ELException e) {
+ caught = e;
+ String messageStr = e.getMessage();
+ Throwable result = e.getCause();
+ while (null != result && result.getClass().isAssignableFrom(ELException.class)) {
+ messageStr = result.getMessage();
+ result = result.getCause();
+ }
+
+ if (messageStr == null) {
+ // todo
+ //message = MessageFactory.getMessage(context, UPDATE_MESSAGE_ID,
+ // MessageFactory.getLabel(context, this));
+ } else {
+ //message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageStr, messageStr);
+ }
+ setValid(false);
+ } catch (Exception e) {
+ caught = e;
+ //message = MessageFactory.getMessage(context, UPDATE_MESSAGE_ID,
+ // MessageFactory.getLabel(context, this));
+ setValid(false);
+ }
+
+ if (caught != null) {
+ assert message != null;
+
+ @SuppressWarnings({"ThrowableInstanceNeverThrown"})
+ UpdateModelException toQueue = new UpdateModelException(message, caught);
+ ExceptionQueuedEventContext eventContext = new ExceptionQueuedEventContext(context,
+ toQueue, this, PhaseId.UPDATE_MODEL_VALUES);
+ context.getApplication().publishEvent(context, ExceptionQueuedEvent.class, eventContext);
+ }
+ }
+
+ /**
+ * Executes validation logic.
+ */
+ private void executeValidate(FacesContext context) {
+ try {
+ validate(context);
+ } catch (RuntimeException e) {
+ context.renderResponse();
+ throw e;
+ }
+
+ if (!isValid()) {
+ context.validationFailed();
+ context.renderResponse();
+ }
+ }
+
+ public void validate(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // Submitted value == null means "the component was not submitted at all".
+ String submittedValue = getSubmittedSelectedItem();
+ if (submittedValue == null) {
+ return;
+ }
+
+ String previous = (String) getValue();
+ setValue(submittedValue);
+ setSubmittedSelectedItem(null);
+ if (!previous.equalsIgnoreCase(submittedValue)) {
+ queueEvent(new SelectedItemChangeEvent(this, previous, submittedValue));
+ }
+ }
+
+
+
+ // -------------------------------------------------- Panel Items Managing
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ @Override
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ private boolean isSelectedItem(UIComponent kid) {
+ String value = getSelectedItem();
+ if (value == null) {
+ value = getSubmittedSelectedItem();
+ }
+ return getChildName(kid).equals(value);
+ }
+
+ public String getFirstItem() {
+ checkChildCount(getChildCount());
+
+ return getChildName(getChildren().get(0));
+ }
+
+ private static void checkChildCount(int childCount) {
+ if (childCount < 1) {
+ throw new IllegalStateException("TogglePanel must have at least one TogglePanelItem.");
+ }
+ }
+
+ public AbstractTogglePanelItem getItem(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Name is required parameter.");
+ }
+ checkChildCount(getChildCount());
+
+ List<UIComponent> children = getChildren();
+ int index = getChildIndex(name, children);
+ if (index == -1) {
+ return null;
+ }
+ return (AbstractTogglePanelItem) children.get(index);
+ }
+
+ public String getNext(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Name is required parameter.");
+ }
+ checkChildCount(getChildCount());
+
+
+ List<UIComponent> children = getChildren();
+
+ int nextItem = getChildIndex(name, children) + 1;
+ if (nextItem < children.size()) {
+ return getFirstItem();
+ } else {
+ return getChildName(children.get(nextItem));
+ }
+ }
+
+ private static int getChildIndex(String name, List<UIComponent> children) {
+ int ind = 0;
+ while (ind < children.size()) {
+ UIComponent child = children.get(ind);
+ if (name.equals(getChildName(child))) {
+ return ind;
+ }
+ ind++;
+ }
+
+// throw new IllegalStateException("Can't find child panel item with name: " + name);
+ return -1;
+ }
+
+ private static String getChildName(UIComponent item) {
+ if (!(item instanceof AbstractTogglePanelItem)) {
+ throw new IllegalStateException("TogglePanel can contain only TogglePanelItem as child.");
+ }
+
+ return ((AbstractTogglePanelItem) item).getName();
+ }
+
+ // ------------------------------------------------
+
+ public String getSubmittedSelectedItem() {
+ return submittedSelectedItem;
+ }
+
+ public void setSubmittedSelectedItem(String submittedSelectedItem) {
+ this.submittedSelectedItem = submittedSelectedItem;
+ }
+
+
+ // ------------------------------------------------ Properties
+
+ public String getSelectedItem() {
+ return (String) getValue();
+ }
+
+ public void setSelectedItem(String value) {
+ setValue(value);
+ }
+
+ public abstract Method getSwitchType();
+
+ public abstract boolean getBypassUpdates();
+
+ public abstract boolean getLimitToList();
+
+ public abstract Object getData();
+
+ public abstract String getStatus();
+
+ public abstract Object getExecute();
+
+ public abstract Object getRender();
+
+ public abstract MethodExpression getSelectedItemChangeListener();
+
+
+
+ // ------------------------------------------------ Event Processing Methods
+
+ /**
+ * <p>Add a new {@link SelectedItemChangeListener} to the set of listeners
+ * interested in being notified when {@link org.richfaces.event.SelectedItemChangeEvent}s occur.</p>
+ *
+ * @param listener The {@link SelectedItemChangeListener} to be added
+ * @throws NullPointerException if <code>listener</code>
+ * is <code>null</code>
+ */
+ public void addSelectedItemChangeListener(SelectedItemChangeListener listener) {
+ addFacesListener(listener);
+ }
+
+ /**
+ * <p>Return the set of registered {@link SelectedItemChangeListener}s for this instance.
+ * If there are no registered listeners, a zero-length array is returned.</p>
+ */
+ public SelectedItemChangeListener[] getSelectedItemChangeListeners() {
+ return (SelectedItemChangeListener[]) getFacesListeners(SelectedItemChangeListener.class);
+ }
+
+ /**
+ * <p>Remove an existing {@link SelectedItemChangeListener} (if any) from the
+ * set of listeners interested in being notified when
+ * {@link org.richfaces.event.SelectedItemChangeEvent}s occur.</p>
+ *
+ * @param listener The {@link SelectedItemChangeListener} to be removed
+ * @throws NullPointerException if <code>listener</code>
+ * is <code>null</code>
+ */
+ public void removeSelectedItemChangeListener(SelectedItemChangeListener listener) {
+ removeFacesListener(listener);
+ }
+
+}
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+
+/**
+ * @author akolonitsky
+ * @version 1.0
+ * @since -4712-01-01
+ */
+public abstract class AbstractTogglePanelItem extends AbstractDivPanel {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panels.TogglePanelItem";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.panels.TogglePanelItem";
+
+ protected AbstractTogglePanelItem() {
+ setRendererType("org.richfaces.panels.TogglePanelItemRenderer");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ @Override
+ public void setParent(UIComponent parent) {
+ if (!(parent instanceof AbstractTogglePanel)) {
+ throw new IllegalArgumentException("Parent of TogglePanelItem can be only TogglePanel.");
+ }
+ super.setParent(parent);
+ }
+
+ @Override
+ public AbstractTogglePanel getParent() {
+ return (AbstractTogglePanel) super.getParent();
+ }
+
+ @Override
+ public Renderer getRenderer(FacesContext context) {
+ return super.getRenderer(context);
+ }
+
+ public abstract String getName();
+
+ public abstract Method getSwitchType();
+
+ public String toString() {
+ return "TogglePanelItem {name: " + getName() + ", switchType: " + getSwitchType() + '}';
+ }
+}
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/Method.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/Method.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/Method.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,22 @@
+package org.richfaces.component;
+
+/**
+ * @author akolonitsky
+ * @since Jun 15, 2010
+ */
+public enum Method {
+ /**
+ * value for tab change method for - client-side tabs.
+ */
+ client,
+
+ /**
+ * value for tab change method - server-side tabs
+ */
+ server,
+
+ /**
+ * value for tab change method - ajax tabs
+ */
+ ajax
+}
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UIDivPanel.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UIDivPanel.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UIDivPanel.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+
+
+/**
+ * @author akolonitsky
+ * @since -4712-01-01
+ */
+public class UIDivPanel extends AbstractDivPanel {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panels.DivPanel";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.panels.DivPanel";
+
+
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+
+}
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanel.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanel.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanel.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import javax.el.MethodExpression;
+
+/**
+ * @author akolonitsky
+ * @since -4712-01-01
+ */
+public class UITogglePanel extends AbstractTogglePanel {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panels.TogglePanel";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.panels.TogglePanel";
+
+ private enum PropertyKeys {
+ switchType,
+ bypassUpdates,
+ limitToList,
+ data,
+ status,
+ execute,
+ render,
+ selectedItemChangeListener
+ }
+
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public Method getSwitchType() {
+ return (Method) getStateHelper().eval(PropertyKeys.switchType, Method.ajax);
+ }
+
+ public void setSwitchType(Method switchType) {
+ getStateHelper().put(PropertyKeys.switchType, switchType);
+ }
+
+ public boolean getBypassUpdates() {
+ return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.bypassUpdates)));
+ }
+
+ public void setBypassUpdates(boolean bypassUpdates) {
+ getStateHelper().put(PropertyKeys.bypassUpdates, bypassUpdates);
+ }
+
+ public boolean getLimitToList() {
+ return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.limitToList)));
+ }
+
+ public void setLimitToList(boolean limitToList) {
+ getStateHelper().put(PropertyKeys.limitToList, limitToList);
+ }
+
+ public Object getData() {
+ return getStateHelper().eval(PropertyKeys.data);
+ }
+
+ public void setData(Object data) {
+ getStateHelper().put(PropertyKeys.data, data);
+ }
+
+ public String getStatus() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.status));
+ }
+
+ public void setStatus(String status) {
+ getStateHelper().put(PropertyKeys.status, status);
+ }
+
+ public Object getExecute() {
+ return getStateHelper().eval(PropertyKeys.execute);
+ }
+
+ public void setExecute(Object execute) {
+ getStateHelper().put(PropertyKeys.execute, execute);
+ }
+
+ public Object getRender() {
+ return getStateHelper().eval(PropertyKeys.render);
+ }
+
+ public void setRender(Object render) {
+ getStateHelper().put(PropertyKeys.render, render);
+ }
+
+ public MethodExpression getSelectedItemChangeListener() {
+ return (MethodExpression) getStateHelper().eval(PropertyKeys.selectedItemChangeListener);
+ }
+
+ public void setSelectedItemChangeListener(MethodExpression selectedItemChangeListener) {
+ getStateHelper().put(PropertyKeys.selectedItemChangeListener, selectedItemChangeListener);
+ }
+
+
+}
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+/**
+ * @author akolonitsky
+ * @since -4712-01-01
+ */
+public class UITogglePanelItem extends AbstractTogglePanelItem {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panels.TogglePanelItem";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.panels.TogglePanelItem";
+
+ private enum PropertyKeys {
+ name,
+ switchType
+ }
+
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ @Override
+ public String getName() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.name));
+ }
+
+ public void setName(String name) {
+ getStateHelper().put(PropertyKeys.name, name);
+ }
+
+ @Override
+ public Method getSwitchType() {
+ return (Method) getStateHelper().eval(PropertyKeys.switchType, getParent().getSwitchType());
+ }
+
+ public void setSwitchType(Method switchType) {
+ getStateHelper().put(PropertyKeys.switchType, switchType);
+ }
+
+
+}
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component.behavior;
+
+import org.ajax4jsf.component.behavior.ClientBehavior;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.richfaces.component.AbstractTogglePanel;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+/**
+ * @author akolonitsky
+ *
+ */
+public class ToggleControl extends ClientBehavior {
+
+ public static final String BEHAVIOR_ID = "org.richfaces.component.behavior.ToggleControl";
+
+ private enum PropertyKeys {
+ event,
+ targetItem,
+ forPanel,
+ }
+
+ public String getEvent() {
+ return (String) getStateHelper().eval(PropertyKeys.event);
+ }
+
+ public void setEvent(String eventName) {
+ getStateHelper().eval(PropertyKeys.event, eventName);
+ }
+
+ public String getTargetItem() {
+ return (String) getStateHelper().eval(PropertyKeys.targetItem);
+ }
+
+ public void setTargetItem(String target) {
+ getStateHelper().put(PropertyKeys.targetItem, target);
+ }
+
+ public String getForPanel() {
+ return (String) getStateHelper().eval(PropertyKeys.forPanel);
+ }
+
+ public void setForPanel(String selector) {
+ getStateHelper().put(PropertyKeys.forPanel, selector);
+ }
+
+ public AbstractTogglePanel getPanel(UIComponent comp) throws FacesException {
+ String target = this.getForPanel();
+
+ if (target != null) {
+
+ UIComponent targetComponent = RendererUtils.getInstance()
+ .findComponentFor(comp, target);
+
+ if (null != targetComponent) {
+ return (AbstractTogglePanel) targetComponent;
+ } else {
+ throw new FacesException("Parent panel for control (id="
+ + comp.getClientId(getFacesContext()) + ") has not been found.");
+ }
+ } else {
+ UIComponent control = comp;
+ while (control != null) {
+ if (control instanceof AbstractTogglePanel) {
+ return (AbstractTogglePanel) control;
+ }
+
+ control = control.getParent();
+ }
+ throw new FacesException("Parent panel for control (id="
+ + comp.getClientId(getFacesContext()) + ") has not been found.");
+ }
+ }
+
+ @Override
+ public String getRendererType() {
+ return BEHAVIOR_ID;
+ }
+
+ @Override
+ public void setLiteralAttribute(String name, Object value) {
+// if (compare(PropertyKeys.operation, name)) {
+// setOperation((String) value);
+// } else if (compare(PropertyKeys.target, name)) {
+// setTargetItem((String) value);
+// } else if (compare(PropertyKeys.selector, name)) {
+// setForPanel((String) value);
+// }
+ }
+}
\ No newline at end of file
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlDivPanel.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlDivPanel.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlDivPanel.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component.html;
+
+
+import org.richfaces.component.UIDivPanel;
+
+public class HtmlDivPanel extends UIDivPanel {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panels.DivPanel";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.panels.DivPanel";
+
+ private enum PropertyKeys {
+ lang,
+ onclick,
+ ondblclick,
+ onmousedown,
+ onmousemove,
+ onmouseout,
+ onmouseover,
+ onmouseup,
+ title,
+ style,
+ styleClass,
+ dir
+ }
+
+ public HtmlDivPanel() {
+ setRendererType("org.richfaces.panels.DivPanelRenderer");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public String getLang() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.lang));
+ }
+
+ public void setLang(String lang) {
+ getStateHelper().put(PropertyKeys.lang, lang);
+ }
+
+ public String getOnclick() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onclick));
+ }
+
+ public void setOnclick(String onclick) {
+ getStateHelper().put(PropertyKeys.onclick, onclick);
+ }
+
+ public String getOndblclick() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.ondblclick));
+ }
+
+ public void setOndblclick(String ondblclick) {
+ getStateHelper().put(PropertyKeys.ondblclick, ondblclick);
+ }
+
+ public String getOnmousedown() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmousedown));
+ }
+
+ public void setOnmousedown(String onmousedown) {
+ getStateHelper().put(PropertyKeys.onmousedown, onmousedown);
+ }
+
+ public String getOnmousemove() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmousemove));
+ }
+
+ public void setOnmousemove(String onmousemove) {
+ getStateHelper().put(PropertyKeys.onmousemove, onmousemove);
+ }
+
+ public String getOnmouseout() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmouseout));
+ }
+
+ public void setOnmouseout(String onmouseout) {
+ getStateHelper().put(PropertyKeys.onmouseout, onmouseout);
+ }
+
+ public String getOnmouseover() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmouseover));
+ }
+
+ public void setOnmouseover(String onmouseover) {
+ getStateHelper().put(PropertyKeys.onmouseover, onmouseover);
+ }
+
+ public String getOnmouseup() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmouseup));
+ }
+
+ public void setOnmouseup(String onmouseup) {
+ getStateHelper().put(PropertyKeys.onmouseup, onmouseup);
+ }
+
+ public String getTitle() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.title));
+ }
+
+ public void setTitle(String title) {
+ getStateHelper().put(PropertyKeys.title, title);
+ }
+
+ public String getStyle() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.style));
+ }
+
+ public void setStyle(String style) {
+ getStateHelper().put(PropertyKeys.style, style);
+ }
+
+ public String getStyleClass() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.styleClass));
+ }
+
+ public void setStyleClass(String styleClass) {
+ getStateHelper().put(PropertyKeys.styleClass, styleClass);
+ }
+
+ public String getDir() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.dir));
+ }
+
+ public void setDir(String dir) {
+ getStateHelper().put(PropertyKeys.dir, dir);
+ }
+
+
+}
+
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlTogglePanel.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlTogglePanel.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlTogglePanel.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,191 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component.html;
+
+import org.richfaces.component.UITogglePanel;
+
+public class HtmlTogglePanel extends UITogglePanel {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panels.TogglePanel";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.panels.TogglePanel";
+
+ private enum PropertyKeys {
+ lang,
+ onclick,
+ ondblclick,
+ onmousedown,
+ onmousemove,
+ onmouseout,
+ onmouseover,
+ onmouseup,
+ title,
+ style,
+ styleClass,
+ dir,
+ oncomplete,
+ onbeforedomupdate,
+ onitemchange,
+ onitemchanged
+ }
+
+ public HtmlTogglePanel() {
+ setRendererType("org.richfaces.panels.TogglePanelRenderer");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public String getLang() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.lang));
+ }
+
+ public void setLang(String lang) {
+ getStateHelper().put(PropertyKeys.lang, lang);
+ }
+
+ public String getOnclick() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onclick));
+ }
+
+ public void setOnclick(String onclick) {
+ getStateHelper().put(PropertyKeys.onclick, onclick);
+ }
+
+ public String getOndblclick() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.ondblclick));
+ }
+
+ public void setOndblclick(String ondblclick) {
+ getStateHelper().put(PropertyKeys.ondblclick, ondblclick);
+ }
+
+ public String getOnmousedown() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmousedown));
+ }
+
+ public void setOnmousedown(String onmousedown) {
+ getStateHelper().put(PropertyKeys.onmousedown, onmousedown);
+ }
+
+ public String getOnmousemove() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmousemove));
+ }
+
+ public void setOnmousemove(String onmousemove) {
+ getStateHelper().put(PropertyKeys.onmousemove, onmousemove);
+ }
+
+ public String getOnmouseout() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmouseout));
+ }
+
+ public void setOnmouseout(String onmouseout) {
+ getStateHelper().put(PropertyKeys.onmouseout, onmouseout);
+ }
+
+ public String getOnmouseover() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmouseover));
+ }
+
+ public void setOnmouseover(String onmouseover) {
+ getStateHelper().put(PropertyKeys.onmouseover, onmouseover);
+ }
+
+ public String getOnmouseup() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmouseup));
+ }
+
+ public void setOnmouseup(String onmouseup) {
+ getStateHelper().put(PropertyKeys.onmouseup, onmouseup);
+ }
+
+ public String getTitle() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.title));
+ }
+
+ public void setTitle(String title) {
+ getStateHelper().put(PropertyKeys.title, title);
+ }
+
+ public String getStyle() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.style));
+ }
+
+ public void setStyle(String style) {
+ getStateHelper().put(PropertyKeys.style, style);
+ }
+
+ public String getStyleClass() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.styleClass));
+ }
+
+ public void setStyleClass(String styleClass) {
+ getStateHelper().put(PropertyKeys.styleClass, styleClass);
+ }
+
+ public String getDir() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.dir));
+ }
+
+ public void setDir(String dir) {
+ getStateHelper().put(PropertyKeys.dir, dir);
+ }
+
+ public String getOncomplete() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.oncomplete));
+ }
+
+ public void setOncomplete(String oncomplete) {
+ getStateHelper().put(PropertyKeys.oncomplete, oncomplete);
+ }
+
+ public String getOnbeforedomupdate() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onbeforedomupdate));
+ }
+
+ public void setOnbeforedomupdate(String onbeforedomupdate) {
+ getStateHelper().put(PropertyKeys.onbeforedomupdate, onbeforedomupdate);
+ }
+
+ public String getOnitemchange() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onitemchange));
+ }
+
+ public void setOnitemchange(String onitemchange) {
+ getStateHelper().put(PropertyKeys.onitemchange, onitemchange);
+ }
+
+ public String getOnitemchanged() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onitemchanged));
+ }
+
+ public void setOnitemchanged(String onitemchanged) {
+ getStateHelper().put(PropertyKeys.onitemchanged, onitemchanged);
+ }
+
+
+}
+
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlTogglePanelItem.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlTogglePanelItem.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/component/html/HtmlTogglePanelItem.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component.html;
+
+import org.richfaces.component.UITogglePanelItem;
+
+public class HtmlTogglePanelItem extends UITogglePanelItem {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.panels.TogglePanelItem";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.panels.TogglePanelItem";
+
+ private enum PropertyKeys {
+ lang,
+ onclick,
+ ondblclick,
+ onmousedown,
+ onmousemove,
+ onmouseout,
+ onmouseover,
+ onmouseup,
+ title,
+ style,
+ styleClass,
+ dir,
+ onenter,
+ onleave
+ }
+
+ public HtmlTogglePanelItem() {
+ setRendererType("org.richfaces.panels.TogglePanelItemRenderer");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public String getLang() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.lang));
+ }
+
+ public void setLang(String lang) {
+ getStateHelper().put(PropertyKeys.lang, lang);
+ }
+
+ public String getOnclick() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onclick));
+ }
+
+ public void setOnclick(String onclick) {
+ getStateHelper().put(PropertyKeys.onclick, onclick);
+ }
+
+ public String getOndblclick() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.ondblclick));
+ }
+
+ public void setOndblclick(String ondblclick) {
+ getStateHelper().put(PropertyKeys.ondblclick, ondblclick);
+ }
+
+ public String getOnmousedown() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmousedown));
+ }
+
+ public void setOnmousedown(String onmousedown) {
+ getStateHelper().put(PropertyKeys.onmousedown, onmousedown);
+ }
+
+ public String getOnmousemove() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmousemove));
+ }
+
+ public void setOnmousemove(String onmousemove) {
+ getStateHelper().put(PropertyKeys.onmousemove, onmousemove);
+ }
+
+ public String getOnmouseout() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmouseout));
+ }
+
+ public void setOnmouseout(String onmouseout) {
+ getStateHelper().put(PropertyKeys.onmouseout, onmouseout);
+ }
+
+ public String getOnmouseover() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmouseover));
+ }
+
+ public void setOnmouseover(String onmouseover) {
+ getStateHelper().put(PropertyKeys.onmouseover, onmouseover);
+ }
+
+ public String getOnmouseup() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onmouseup));
+ }
+
+ public void setOnmouseup(String onmouseup) {
+ getStateHelper().put(PropertyKeys.onmouseup, onmouseup);
+ }
+
+ public String getTitle() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.title));
+ }
+
+ public void setTitle(String title) {
+ getStateHelper().put(PropertyKeys.title, title);
+ }
+
+ public String getStyle() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.style));
+ }
+
+ public void setStyle(String style) {
+ getStateHelper().put(PropertyKeys.style, style);
+ }
+
+ public String getStyleClass() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.styleClass));
+ }
+
+ public void setStyleClass(String styleClass) {
+ getStateHelper().put(PropertyKeys.styleClass, styleClass);
+ }
+
+ public String getDir() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.dir));
+ }
+
+ public void setDir(String dir) {
+ getStateHelper().put(PropertyKeys.dir, dir);
+ }
+
+ public String getOnenter() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onenter));
+ }
+
+ public void setOnenter(String onenter) {
+ getStateHelper().put(PropertyKeys.onenter, onenter);
+ }
+
+ public String getOnleave() {
+ return String.valueOf(getStateHelper().eval(PropertyKeys.onleave));
+ }
+
+ public void setOnleave(String onleave) {
+ getStateHelper().put(PropertyKeys.onleave, onleave);
+ }
+
+
+}
+
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/MethodExpressionSelectedItemChangeListener.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/MethodExpressionSelectedItemChangeListener.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/MethodExpressionSelectedItemChangeListener.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,189 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.event;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.MethodNotFoundException;
+import javax.faces.context.FacesContext;
+import javax.faces.component.StateHolder;
+import javax.faces.event.AbortProcessingException;
+
+/**
+ * <p><strong><span
+ * class="changed_modified_2_0">MethodExpressionSelectedItemChangeListener</span></strong>
+ * is a {@link SelectedItemChangeListener} that wraps a {@link
+ * MethodExpression}. When it receives a {@link SelectedItemChangeEvent}, it
+ * executes a method on an object identified by the {@link
+ * MethodExpression}.</p>
+ *
+ * @author akolonitsky
+ * @version 1.0
+ * @since -4712-01-01
+ *
+ */
+public class MethodExpressionSelectedItemChangeListener implements SelectedItemChangeListener, StateHolder {
+
+ private static final Class[] SELECTED_ITEM_CHANGE_LISTENER_ZERO_ARG_SIG = new Class[] {};
+
+ // ------------------------------------------------------ Instance Variables
+
+ private MethodExpression methodExpressionOneArg = null;
+ private MethodExpression methodExpressionZeroArg = null;
+
+ private boolean isTransient;
+
+
+ public MethodExpressionSelectedItemChangeListener() { }
+
+ /**
+ * <p><span class="changed_modified_2_0">Construct</span> a {@link
+ * SelectedItemChangeListener} that contains a {@link
+ * MethodExpression}.<span
+ * class="changed_added_2_0">To accomodate method expression targets
+ * that take no arguments instead of taking a {@link
+ * SelectedItemChangeEvent} argument</span>, the implementation of this
+ * class must take the argument <code>methodExpressionOneArg</code>,
+ * extract its expression string, and create another
+ * <code>MethodExpression</code> whose expected param types match
+ * those of a zero argument method. The usage requirements for both
+ * of these <code>MethodExpression</code> instances are described in
+ * {@link #processSelectedItemChange}.</span></p>
+ *
+ * @param methodExpressionOneArg a <code>MethodExpression</code>
+ * that points to a method that returns <code>void</code> and takes
+ * a single argument of type {@link SelectedItemChangeEvent}.
+ */
+ public MethodExpressionSelectedItemChangeListener(MethodExpression methodExpressionOneArg) {
+
+ super();
+ this.methodExpressionOneArg = methodExpressionOneArg;
+ FacesContext context = FacesContext.getCurrentInstance();
+ ELContext elContext = context.getELContext();
+ this.methodExpressionZeroArg = context.getApplication().
+ getExpressionFactory().createMethodExpression(elContext,
+ methodExpressionOneArg.getExpressionString(), Void.class,
+ SELECTED_ITEM_CHANGE_LISTENER_ZERO_ARG_SIG);
+ }
+
+ /**
+ * <p>Construct a {@link SelectedItemChangeListener} that contains a {@link MethodExpression}.</p>
+ */
+ public MethodExpressionSelectedItemChangeListener(MethodExpression methodExpressionOneArg,
+ MethodExpression methodExpressionZeroArg) {
+
+ super();
+ this.methodExpressionOneArg = methodExpressionOneArg;
+ this.methodExpressionZeroArg = methodExpressionZeroArg;
+ }
+
+ // ------------------------------------------------------- Event Method
+
+ /**
+ * <p><span class="changed_modified_2_0">Call</span> through to the
+ * {@link MethodExpression} passed in our constructor. <span
+ * class="changed_added_2_0">First, try to invoke the
+ * <code>MethodExpression</code> passed to the constructor of this
+ * instance, passing the argument {@link SelectedItemChangeEvent} as the
+ * argument. If a {@link MethodNotFoundException} is thrown, call
+ * to the zero argument <code>MethodExpression</code> derived from
+ * the <code>MethodExpression</code> passed to the constructor of
+ * this instance. If that fails for any reason, throw an {@link
+ * AbortProcessingException}, including the cause of the
+ * failure.</span></p>
+ *
+ * @throws NullPointerException {@inheritDoc}
+ * @throws AbortProcessingException {@inheritDoc}
+ */
+ public void processSelectedItemChange(SelectedItemChangeEvent selectedItemChangeEvent) throws AbortProcessingException {
+
+ if (selectedItemChangeEvent == null) {
+ throw new NullPointerException();
+ }
+ FacesContext context = FacesContext.getCurrentInstance();
+ ELContext elContext = context.getELContext();
+ // PENDING: The corresponding code in MethodExpressionActionListener
+ // has an elaborate message capture, logging, and rethrowing block.
+ // Why not here?
+ try {
+ methodExpressionOneArg.invoke(elContext, new Object[] {selectedItemChangeEvent});
+ } catch (MethodNotFoundException mnf) {
+ if (null != methodExpressionZeroArg) {
+
+ try {
+ // try to invoke a no-arg version
+ methodExpressionZeroArg.invoke(elContext, new Object[]{});
+ } catch (ELException ee) {
+ throw new AbortProcessingException(ee.getMessage(), ee.getCause());
+ }
+ }
+ } catch (ELException ee) {
+ throw new AbortProcessingException(ee.getMessage(), ee.getCause());
+ }
+ }
+
+
+ // ------------------------------------------------ Methods from StateHolder
+
+
+ /**
+ * <p class="changed_modified_2_0">Both {@link MethodExpression}
+ * instances described in the constructor must be saved.</p>
+ */
+ public Object saveState(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ return new Object[] {methodExpressionOneArg, methodExpressionZeroArg };
+ }
+
+
+ /**
+ * <p class="changed_modified_2_0">Both {@link MethodExpression}
+ * instances described in the constructor must be restored.</p>
+ */
+ public void restoreState(FacesContext context, Object state) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (state == null) {
+ return;
+ }
+
+ methodExpressionOneArg = (MethodExpression) ((Object[]) state)[0];
+ methodExpressionZeroArg = (MethodExpression) ((Object[]) state)[1];
+ }
+
+
+ public boolean isTransient() {
+ return isTransient;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ isTransient = newTransientValue;
+ }
+}
+
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/SelectedItemChangeEvent.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/SelectedItemChangeEvent.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/SelectedItemChangeEvent.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+
+/**
+ * <p>A {@link SelectedItemChangeEvent} is a ...</p>
+ *
+ * @author akolonitsky
+ * @version 1.0
+ * @since -4712-01-01
+ */
+public class SelectedItemChangeEvent extends FacesEvent {
+
+ private final String oldItem;
+ private final String newItem;
+
+ // ------------------------------------------------------------ Constructors
+
+ /**
+ * <p>Construct a new event object from the specified source component,
+ * old value, and new value.</p>
+ *
+ * <p>The default {@link javax.faces.event.PhaseId} for this event is {@link
+ * javax.faces.event.PhaseId#ANY_PHASE}.</p>
+ *
+ * @param component Source {@link UIComponent} for this event
+ *
+ * @param oldItem
+ * @param newItem
+ *
+ * @throws IllegalArgumentException if <code>component</code> is
+ * <code>null</code>
+ */
+ public SelectedItemChangeEvent(UIComponent component, String oldItem, String newItem) {
+ super(component);
+ this.oldItem = oldItem;
+ this.newItem = newItem;
+ }
+
+
+ // -------------------------------------------------------------- Properties
+
+ public String getOldItem() {
+ return oldItem;
+ }
+
+ public String getNewItem() {
+ return newItem;
+ }
+
+ // ------------------------------------------------- Event Broadcast Methods
+
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof SelectedItemChangeListener;
+ }
+
+ /**
+ * @throws javax.faces.event.AbortProcessingException {@inheritDoc}
+ */
+ public void processListener(FacesListener listener) {
+ ((SelectedItemChangeListener) listener).processSelectedItemChange(this);
+ }
+}
+
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/SelectedItemChangeListener.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/SelectedItemChangeListener.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/event/SelectedItemChangeListener.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesListener;
+
+/**
+ * <p>A listener interface for receiving {@link SelectedItemChangeEvent}s. A class
+ * that is interested in receiving such events implements this interface, and
+ * then registers itself with the source {@link javax.faces.component.UIComponent} of interest, by
+ * calling <code>addSelectedItemChangeListener()</code>.</p>
+ *
+ * @author akolonitsky
+ * @version 1.0
+ * @since -4712-01-01
+ *
+ */
+public interface SelectedItemChangeListener extends FacesListener {
+
+
+ /**
+ * <p>Invoked when {@link SelectedItemChangeEvent} occurs.</p>
+ *
+ * @param event The {@link SelectedItemChangeEvent} that has occurred
+ *
+ * @throws AbortProcessingException Signal the JavaServer Faces
+ * implementation that no further processing on the current event
+ * should be performed
+ */
+ void processSelectedItemChange(SelectedItemChangeEvent event) throws AbortProcessingException;
+
+}
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html;
+
+import static org.ajax4jsf.renderkit.RendererUtils.*;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.richfaces.component.AbstractDivPanel;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author akolonitsky
+ * @since -4712-01-01
+ */
+public class DivPanelRenderer extends RendererBase {
+
+ public static final String[] ATTRIBUTES = new String[] {
+ "lang",
+ "onclick",
+ "ondblclick",
+ "onmousedown",
+ "onmousemove",
+ "onmouseout",
+ "onmouseover",
+ "onmouseup",
+ "title",
+ "style",
+ "styleClass",
+ "dir",
+ };
+
+ @Override
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ super.doEncodeBegin(writer, context, component);
+
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute("id", component.getClientId(context), "clientId");
+
+ writeAttributes(writer, component, ATTRIBUTES);
+ }
+
+ private void writeAttributes(ResponseWriter writer, UIComponent component, String[] attributes) throws IOException {
+ Map<String, Object> componentAttributes = component.getAttributes();
+ for (String attrName : attributes) {
+ Object attrValue = componentAttributes.get(attrName);
+ if (!"null".equalsIgnoreCase(String.valueOf(attrValue))) {
+ writer.writeAttribute(attrName, attrValue, attrName); // TODO Use RendererUtils
+ }
+ }
+ }
+
+ @Override
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ super.doEncodeEnd(writer, context, component);
+
+ writeJavaScript(writer, context, component);
+
+ writer.endElement(HTML.DIV_ELEM);
+ }
+
+ protected void writeJavaScript(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ Object script = getScriptObject(context, component);
+ if (script != null) {
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", "type");
+ writer.writeText(script, null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ }
+ }
+
+ protected Object getScriptObject(FacesContext context, UIComponent component) {
+ return null;
+ }
+
+ protected Map<String, Object> getScriptObjectOptions(FacesContext context, UIComponent component) {
+ return null;
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return AbstractDivPanel.class;
+ }
+}
+
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/ToggleControlRenderer.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html;
+
+import org.richfaces.component.AbstractTogglePanel;
+import org.richfaces.component.behavior.ToggleControl;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.render.ClientBehaviorRenderer;
+import javax.faces.render.FacesBehaviorRenderer;
+import javax.faces.render.RenderKitFactory;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+@FacesBehaviorRenderer(
+ rendererType = "org.richfaces.component.behavior.ToggleControl",
+ renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT)
+@ResourceDependencies({
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js") })
+public class ToggleControlRenderer extends ClientBehaviorRenderer {
+
+ @Override
+ public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior behavior) {
+ ToggleControl control = (ToggleControl) behavior;
+
+ AbstractTogglePanel panel = control.getPanel(behaviorContext.getComponent());
+ return "RichFaces.$('" + panel.getClientId() + "').switchToItem('" + control.getTargetItem() + "'); return false;";
+ }
+}
\ No newline at end of file
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelItemRenderer.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelItemRenderer.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelItemRenderer.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html;
+
+import org.ajax4jsf.javascript.JSObject;
+import org.richfaces.component.AbstractTogglePanelItem;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author akolonitsky
+ * @since -4712-01-01
+ */
+@ResourceDependencies({
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-event.js"),
+ @ResourceDependency(name = "richfaces-base-component.js"),
+ @ResourceDependency(name = "script/TogglePanelItem.js") })
+public class TogglePanelItemRenderer extends DivPanelRenderer {
+
+ @Override
+ protected void writeJavaScript(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ // All script must be written by TogglePanel using method getScriptObject
+ }
+
+ @Override
+ protected JSObject getScriptObject(FacesContext context, UIComponent component) {
+ return new JSObject("RichFaces.ui.TogglePanelItem", component.getClientId(), getScriptObjectOptions(context, component));
+ }
+
+ @Override
+ protected Map<String, Object> getScriptObjectOptions(FacesContext context, UIComponent component) {
+ AbstractTogglePanelItem panelItem = (AbstractTogglePanelItem) component;
+
+ Map<String, Object> options = new HashMap<String, Object>(2);
+ options.put("name", panelItem.getName());
+ options.put("switchMode", panelItem.getSwitchType());
+
+ return options;
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return AbstractTogglePanelItem.class;
+ }
+}
+
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,228 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.renderkit.html;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSObject;
+import org.ajax4jsf.renderkit.AjaxEventOptions;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.component.AbstractTogglePanel;
+import org.richfaces.component.AbstractTogglePanelItem;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.ajax4jsf.renderkit.RendererUtils.HTML;
+
+/**
+ * @author akolonitsky
+ * @since -4712-01-01
+ */
+@ResourceDependencies({
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-event.js"),
+ @ResourceDependency(name = "richfaces-base-component.js"),
+ @ResourceDependency(name = "script/TogglePanel.js") })
+public class TogglePanelRenderer extends DivPanelRenderer {
+
+ private static final String VALUE_POSTFIX = "-value";
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ Map<String, String> requestMap =
+ context.getExternalContext().getRequestParameterMap();
+
+ // Don't overwrite the value unless you have to!
+ String newValue = requestMap.get(getSelectedItemRequestParamName(context, component));
+ if (newValue != null) {
+ setSubmittedValue(component, newValue);
+
+// if (logger.isLoggable(Level.FINE)) {
+// logger.log(Level.FINE, "new value after decoding {0}", newValue);
+// }
+ }
+
+ String compClientId = component.getClientId(context);
+ String clientId = requestMap.get(compClientId);
+ if (clientId != null && clientId.equals(compClientId)) {
+ AbstractTogglePanel panel = (AbstractTogglePanel) component;
+ AbstractTogglePanelItem panelItem = panel.getItem(newValue);
+ if (panelItem != null) {
+ context.getPartialViewContext().getRenderIds().add(panelItem.getClientId(context));
+
+ addOnCompleteParam(newValue, panel);
+ }
+ }
+ }
+
+ private void addOnCompleteParam(String newValue, AbstractTogglePanel panel) {
+ StringBuilder onComplete = new StringBuilder();
+ onComplete.append("RichFaces.$('").append(panel.getClientId()).append("').onCompleteHandler('")
+ .append(panel.getSelectedItem()).append("','").append(newValue).append("'); return false;");
+
+ AjaxContext.getCurrentInstance().appendOncomplete(onComplete.toString());
+ }
+
+ private static String getSelectedItemRequestParamName(FacesContext context, UIComponent component) {
+ return component.getClientId(context) + VALUE_POSTFIX;
+ }
+
+// @Override
+ public void setSubmittedValue(UIComponent component, Object value) {
+ if (component instanceof AbstractTogglePanel) {
+ ((AbstractTogglePanel) component).setSubmittedSelectedItem((String) value);
+
+// if (logger.isLoggable(Level.FINE)) {
+// logger.fine("Set submitted value " + value + " on component ");
+// }
+ }
+
+ }
+
+
+// @Override
+// public boolean getRendersChildren() {
+// return true;
+// }
+
+ @Override
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent comp) throws IOException {
+ super.doEncodeBegin(writer, context, comp);
+ AbstractTogglePanel panel = (AbstractTogglePanel) comp;
+
+ writer.startElement(HTML.INPUT_ELEM, comp);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.writeAttribute(HTML.VALUE_ATTRIBUTE, panel.getSelectedItem(), "selectedItem");
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, getSelectedItemRequestParamName(context, comp), null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, getSelectedItemRequestParamName(context, comp), null);
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+
+ @Override
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ if (component.getChildCount() <= 0) {
+ return;
+ }
+
+ for (UIComponent child : component.getChildren()) {
+ if (!(child instanceof AbstractTogglePanelItem)) {
+ throw new IllegalStateException("Child of TogglePanel can be only TogglePanelItem");
+ }
+
+ doEncodeChild(context, (AbstractTogglePanel) component, (AbstractTogglePanelItem) child);
+ }
+ }
+
+ private void doEncodeChild(FacesContext facesContext, AbstractTogglePanel panel, AbstractTogglePanelItem item)
+ throws IOException {
+
+ boolean isSelected = panel.getSelectedItem().equals(item.getName());
+ if (isSelected) {
+ item.encodeAll(facesContext);
+
+ } else {
+
+ switch (item.getSwitchType()) {
+ case client:
+ hidePanelItem(item);
+
+ item.encodeAll(facesContext);
+ break;
+
+ case ajax:
+ if (!item.isRendered()) {
+ break;
+ }
+
+ hidePanelItem(item);
+ item.encodeBegin(facesContext);
+ item.encodeEnd(facesContext);
+ break;
+
+ case server:
+ break;
+
+ default:
+ throw new IllegalStateException("Unknown switch type : " + item.getSwitchType());
+ }
+ }
+
+
+ }
+
+ private static void hidePanelItem(UIComponent item) {
+ item.getAttributes().put(HTML.STYLE_ATTRIBUTE, "display:none");
+ }
+
+ @Override
+ protected JSObject getScriptObject(FacesContext context, UIComponent component) {
+ return new JSObject("RichFaces.ui.TogglePanel", component.getClientId(), getScriptObjectOptions(context, component));
+ }
+
+ @Override
+ protected Map<String, Object> getScriptObjectOptions(FacesContext context, UIComponent component) {
+ AbstractTogglePanel panel = (AbstractTogglePanel) component;
+
+ Map<String, Object> options = new HashMap<String, Object>(3);
+ options.put("selectedItem", panel.getValue());
+ options.put("switchMode", panel.getSwitchType());
+ options.put("items", getChildrenScriptObjects(context, panel));
+
+ options.put("ajax", getAjaxOptions(context, panel));
+
+ return options;
+ }
+
+ private static AjaxEventOptions getAjaxOptions(FacesContext context, UIComponent panel) {
+ return AjaxRendererUtils.buildEventOptions(context, panel);
+ }
+
+ private List<JSObject> getChildrenScriptObjects(FacesContext context, UIComponent component) {
+ List<JSObject> res = new ArrayList<JSObject>(component.getChildCount());
+ for (UIComponent child : component.getChildren()) {
+ res.add(getChildScriptObject(context, (AbstractTogglePanelItem) child));
+ }
+ return res;
+ }
+
+ private JSObject getChildScriptObject(FacesContext context, AbstractTogglePanelItem child) {
+ return ((TogglePanelItemRenderer) child.getRenderer(context))
+ .getScriptObject(context, child);
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return AbstractTogglePanel.class;
+ }
+}
+
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/taglib/SelectedItemChangeListenerHandler.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/taglib/SelectedItemChangeListenerHandler.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/taglib/SelectedItemChangeListenerHandler.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,209 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.taglib;
+
+import javax.el.ValueExpression;
+import javax.faces.application.Resource;
+import org.richfaces.component.AbstractTogglePanel;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import org.richfaces.event.SelectedItemChangeEvent;
+import org.richfaces.event.SelectedItemChangeListener;
+
+import javax.faces.view.AttachedObjectHandler;
+import javax.faces.view.EditableValueHolderAttachedObjectHandler;
+import javax.faces.view.facelets.*;
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author akolonitsky
+ * @version 1.0
+ * @since -4712-01-01
+ */
+public final class SelectedItemChangeListenerHandler extends TagHandler implements EditableValueHolderAttachedObjectHandler {
+
+ private static final String[] PRIMITIVE_NAMES = new String[] {"boolean",
+ "byte", "char", "double", "float", "int", "long", "short", "void" };
+
+ private static final Class[] PRIMITIVES = new Class[] {boolean.class,
+ byte.class, char.class, double.class, float.class, int.class, long.class, short.class, Void.TYPE };
+
+ private static class LazySelectedItemChangeListener implements SelectedItemChangeListener, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String type;
+
+ private final ValueExpression binding;
+
+ LazySelectedItemChangeListener(String type, ValueExpression binding) {
+ this.type = type;
+ this.binding = binding;
+ }
+
+ public void processSelectedItemChange(SelectedItemChangeEvent event)
+ throws AbortProcessingException {
+
+ FacesContext faces = FacesContext.getCurrentInstance();
+ if (faces == null) {
+ return;
+ }
+
+ SelectedItemChangeListener instance = null;
+ if (this.binding != null) {
+ instance = (SelectedItemChangeListener) binding.getValue(faces.getELContext());
+ }
+ if (instance == null && this.type != null) {
+ try {
+ instance = (SelectedItemChangeListener) forName(this.type).newInstance();
+ } catch (Exception e) {
+ throw new AbortProcessingException("Couldn't Lazily instantiate SelectedItemChangeListener", e);
+ }
+ if (this.binding != null) {
+ binding.setValue(faces.getELContext(), instance);
+ }
+ }
+ if (instance != null) {
+ instance.processSelectedItemChange(event);
+ }
+ }
+ }
+
+ private final TagAttribute binding;
+
+ private final String listenerType;
+
+ public SelectedItemChangeListenerHandler(TagConfig config) {
+ super(config);
+ this.binding = this.getAttribute("binding");
+ TagAttribute type = this.getAttribute("type");
+ if (type != null) {
+ if (type.isLiteral()) {
+ try {
+ forName(type.getValue());
+ } catch (ClassNotFoundException e) {
+ throw new TagAttributeException(type, "Couldn't qualify SelectedItemChangeListener", e);
+ }
+ } else {
+ throw new TagAttributeException(type, "Must be a literal class name of type SelectedItemChangeListener");
+ }
+ this.listenerType = type.getValue();
+ } else {
+ this.listenerType = null;
+ }
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
+
+ // only process if it's been created
+ if (parent == null || !ComponentHandler.isNew(parent)) {
+ return;
+ }
+
+ if (parent instanceof AbstractTogglePanel) {
+ applyAttachedObject(ctx.getFacesContext(), parent);
+ } else if (parent.getAttributes().containsKey(Resource.COMPONENT_RESOURCE_KEY)) {
+ // Allow the composite component to know about the target component.
+ getAttachedObjectHandlers(parent).add(this);
+ } else {
+ throw new TagException(this.tag, "Parent is not of type EditableValueHolder, type is: " + parent);
+ }
+ }
+
+ public void applyAttachedObject(FacesContext context, UIComponent parent) {
+ ValueExpression b = null;
+ if (this.binding != null) {
+ FaceletContext ctx = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
+ b = this.binding.getValueExpression(ctx, SelectedItemChangeListener.class);
+ }
+
+ AbstractTogglePanel evh = (AbstractTogglePanel) parent;
+ evh.addSelectedItemChangeListener(new LazySelectedItemChangeListener(this.listenerType, b));
+ }
+
+ public String getFor() {
+ TagAttribute attr = this.getAttribute("for");
+ return attr == null ? null : attr.getValue();
+ }
+
+ // TODO Move to utility class
+ public static List<AttachedObjectHandler> getAttachedObjectHandlers(UIComponent component) {
+ return getAttachedObjectHandlers(component, true);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public static List<AttachedObjectHandler> getAttachedObjectHandlers(UIComponent component,
+ boolean create) {
+ Map<String, Object> attrs = component.getAttributes();
+ List<AttachedObjectHandler> result = (List<AttachedObjectHandler>)
+ attrs.get("javax.faces.RetargetableHandlers");
+
+ if (result == null) {
+ if (create) {
+ result = new ArrayList<AttachedObjectHandler>();
+ attrs.put("javax.faces.RetargetableHandlers", result);
+ } else {
+ result = Collections.EMPTY_LIST;
+ }
+ }
+ return result;
+
+ }
+
+ public static Class forName(String name) throws ClassNotFoundException {
+ if (null == name || "".equals(name)) {
+ return null;
+ }
+ Class c = forNamePrimitive(name);
+ if (c == null) {
+ if (name.endsWith("[]")) {
+ String nc = name.substring(0, name.length() - 2);
+ c = Class.forName(nc, false, Thread.currentThread().getContextClassLoader());
+ c = Array.newInstance(c, 0).getClass();
+ } else {
+ c = Class.forName(name, false, Thread.currentThread().getContextClassLoader());
+ }
+ }
+ return c;
+ }
+
+ protected static Class forNamePrimitive(String name) {
+ if (name.length() <= 8) {
+ int p = Arrays.binarySearch(PRIMITIVE_NAMES, name);
+ if (p >= 0) {
+ return PRIMITIVES[p];
+ }
+ }
+ return null;
+ }
+}
+
Added: root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/taglib/TogglePanelTagHandler.java
===================================================================
--- root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/taglib/TogglePanelTagHandler.java (rev 0)
+++ root/ui-sandbox/panels/trunk/ui/src/main/java/org/richfaces/taglib/TogglePanelTagHandler.java 2010-07-07 11:32:06 UTC (rev 17755)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.taglib;
+
+import org.richfaces.component.AbstractTogglePanel;
+
+import org.richfaces.event.MethodExpressionSelectedItemChangeListener;
+import org.richfaces.event.SelectedItemChangeEvent;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+/**
+ * @author akolonitsky
+ * @version 1.0
+ * @since -4712-01-01
+ */
+public class TogglePanelTagHandler extends ComponentHandler {
+
+ private static final MetaRule META_RULE = new TogglePanelMetaRule();
+
+
+ public TogglePanelTagHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRuleset = super.createMetaRuleset(type);
+ metaRuleset.addRule(META_RULE);
+ return metaRuleset;
+ }
+
+ private static class TogglePanelMetaRule extends MetaRule{
+
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(AbstractTogglePanel.class)) {
+ if ("selectedItemChangeListener".equals(name)) {
+ return new SelectedItemChangeExpressionMetadata(attribute);
+ }
+
+ }
+ return null;
+ }
+ }
+
+ private static final class SelectedItemChangeExpressionMetadata extends Metadata {
+ private static final Class<?>[] SELECTED_ITEM_CHANGE_SIG = new Class[] {SelectedItemChangeEvent.class };
+
+ private final TagAttribute attr;
+
+ SelectedItemChangeExpressionMetadata(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ @Override
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((AbstractTogglePanel) instance).addSelectedItemChangeListener(new MethodExpressionSelectedItemChangeListener(
+ this.attr.getMethodExpression(ctx, null, SELECTED_ITEM_CHANGE_SIG)));
+ }
+ }
+
+
+
+}
+
14 years, 6 months