JBoss Rich Faces SVN: r20225 - sandbox/trunk/ui.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-11-30 04:16:10 -0500 (Tue, 30 Nov 2010)
New Revision: 20225
Removed:
sandbox/trunk/ui/toolbar/
Log:
remove toolbar from sandbox
14 years, 3 months
JBoss Rich Faces SVN: r20224 - trunk/ui/output/ui/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-11-30 04:13:18 -0500 (Tue, 30 Nov 2010)
New Revision: 20224
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/component/package-info.java
Log:
Added: trunk/ui/output/ui/src/main/java/org/richfaces/component/package-info.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/package-info.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/package-info.java 2010-11-30 09:13:18 UTC (rev 20224)
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+(a)org.richfaces.cdk.annotations.TagLibrary(uri="http://richfaces.org/output", shortName="output")
+package org.richfaces.component;
14 years, 3 months
JBoss Rich Faces SVN: r20223 - in sandbox/trunk/ui/toolbar/ui/src/main: java/org/richfaces/renderkit/html and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-11-30 04:12:20 -0500 (Tue, 30 Nov 2010)
New Revision: 20223
Removed:
sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/component/AbstractToolBar.java
sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/component/AbstractToolBarGroup.java
sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java
sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java
sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/images/
sandbox/trunk/ui/toolbar/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss
sandbox/trunk/ui/toolbar/ui/src/main/templates/toolBar.template.xml
Log:
Deleted: sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/component/AbstractToolBar.java
===================================================================
--- sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/component/AbstractToolBar.java 2010-11-30 09:11:39 UTC (rev 20222)
+++ sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/component/AbstractToolBar.java 2010-11-30 09:12:20 UTC (rev 20223)
@@ -1,60 +0,0 @@
-package org.richfaces.component;
-
-import javax.faces.component.UIComponentBase;
-
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.renderkit.html.ToolBarRendererBase;
-
-@JsfComponent(family = AbstractToolBar.COMPONENT_FAMILY, type = AbstractToolBar.COMPONENT_TYPE,
- renderer=@JsfRenderer(type = ToolBarRendererBase.RENDERER_TYPE), tag = @Tag(name="toolBar")
-)
-public abstract class AbstractToolBar extends UIComponentBase {
-
- public static final String COMPONENT_TYPE = "org.richfaces.ToolBar";
-
- public static final String COMPONENT_FAMILY = "org.richfaces.ToolBar";
-
- @Attribute
- public abstract String getHeight();
-
- @Attribute
- public abstract String getWidth();
-
- @Attribute
- public abstract String getItemSeparator();
-
- @Attribute(events=@EventName("itemclick"))
- public abstract String getOnitemclick();
-
- @Attribute(events=@EventName("itemdblclick"))
- public abstract String getOnitemdblclick();
-
- @Attribute(events=@EventName("itemmousedown"))
- public abstract String getOnitemmousedown();
-
- @Attribute(events=@EventName("itemmouseup"))
- public abstract String getOnitemmouseup();
-
- @Attribute(events=@EventName("itemmouseover"))
- public abstract String getOnitemmouseover();
-
- @Attribute(events=@EventName("itemmousemove"))
- public abstract String getOnitemmousemove();
-
- @Attribute(events=@EventName("itemmouseout"))
- public abstract String getOnitemmouseout();
-
- @Attribute(events=@EventName("itemkeypress"))
- public abstract String getOnitemkeypress();
-
- @Attribute(events=@EventName("itemkeydown"))
- public abstract String getOnitemkeydown();
-
- @Attribute(events=@EventName("itemkeyup"))
- public abstract String getOnitemkeyup();
-
-}
Deleted: sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/component/AbstractToolBarGroup.java
===================================================================
--- sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/component/AbstractToolBarGroup.java 2010-11-30 09:11:39 UTC (rev 20222)
+++ sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/component/AbstractToolBarGroup.java 2010-11-30 09:12:20 UTC (rev 20223)
@@ -1,84 +0,0 @@
-package org.richfaces.component;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.renderkit.html.ToolBarGroupRenderer;
-
-@JsfComponent(family = AbstractToolBar.COMPONENT_FAMILY, type = AbstractToolBarGroup.COMPONENT_TYPE,
- renderer=@JsfRenderer(type = ToolBarGroupRenderer.RENDERER_TYPE), tag = @Tag(name="toolBarGroup"))
-public abstract class AbstractToolBarGroup extends UIComponentBase {
-
- public static final String COMPONENT_TYPE = "org.richfaces.ToolBarGroup";
-
- @Attribute
- public abstract String getItemSeparator();
-
- @Attribute
- public abstract String getLocation();
-
- @Attribute(events=@EventName("itemclick"))
- public abstract String getOnitemclick();
-
- @Attribute(events=@EventName("itemdblclick"))
- public abstract String getOnitemdblclick();
-
- @Attribute(events=@EventName("itemmousedown"))
- public abstract String getOnitemmousedown();
-
- @Attribute(events=@EventName("itemmouseup"))
- public abstract String getOnitemmouseup();
-
- @Attribute(events=@EventName("itemmouseover"))
- public abstract String getOnitemmouseover();
-
- @Attribute(events=@EventName("itemmousemove"))
- public abstract String getOnitemmousemove();
-
- @Attribute(events=@EventName("itemmouseout"))
- public abstract String getOnitemmouseout();
-
- @Attribute(events=@EventName("itemkeypress"))
- public abstract String getOnitemkeypress();
-
- @Attribute(events=@EventName("itemkeydown"))
- public abstract String getOnitemkeydown();
-
- @Attribute(events=@EventName("itemkeyup"))
- public abstract String getOnitemkeyup();
-
- public AbstractToolBar getToolBar() {
- UIComponent component = this.getParent();
- if (component == null) {
- throw new FacesException("The component: " + this.getClientId(getFacesContext()) +
- " is not nested within " + AbstractToolBar.class.getSimpleName());
- } else if (!(component instanceof AbstractToolBar)) {
- throw new FacesException("The component: " + this.getClientId(getFacesContext()) +
- " is not a direct child of " + AbstractToolBar.class.getSimpleName());
- }
- return (AbstractToolBar) component;
- }
-
- public List<UIComponent> getRenderedChildren() {
- List<UIComponent> children = this.getChildren();
- List<UIComponent> renderedChildren = new ArrayList<UIComponent>(children.size());
-
- for (UIComponent child : children) {
- if (child.isRendered()) {
- renderedChildren.add(child);
- }
- }
-
- return renderedChildren;
- }
-
-}
Deleted: sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java
===================================================================
--- sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java 2010-11-30 09:11:39 UTC (rev 20222)
+++ sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java 2010-11-30 09:12:20 UTC (rev 20223)
@@ -1,99 +0,0 @@
-package org.richfaces.renderkit.html;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.component.AbstractToolBar;
-import org.richfaces.component.AbstractToolBarGroup;
-import org.richfaces.renderkit.HtmlConstants;
-
-@JsfRenderer(type = ToolBarGroupRenderer.RENDERER_TYPE, family = AbstractToolBar.COMPONENT_FAMILY)
-public class ToolBarGroupRenderer extends ToolBarRendererBase {
-
- public static final String RENDERER_TYPE = "org.richfaces.ToolBarGroupRenderer";
-
- protected Class<? extends UIComponent> getComponentClass() {
- return AbstractToolBarGroup.class;
- }
-
- public boolean getRendersChildren() {
- return true;
- }
-
- public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
- AbstractToolBarGroup toolBarGroup = (AbstractToolBarGroup) component;
- List<UIComponent> renderedChildren = toolBarGroup.getRenderedChildren();
- if (renderedChildren.size() <= 0) {
- return;
- }
-
- ResponseWriter writer = facesContext.getResponseWriter();
- renderChild(facesContext, toolBarGroup, writer, renderedChildren.get(0));
- for (int i = 1; i < renderedChildren.size(); i++) {
- insertSeparatorIfNeed(facesContext, toolBarGroup, writer);
- renderChild(facesContext, toolBarGroup, writer, renderedChildren.get(i));
- }
- }
-
- private void renderChild(FacesContext facesContext, AbstractToolBarGroup toolBarGroup, ResponseWriter writer,
- UIComponent child) throws IOException {
- writer.startElement(HtmlConstants.TD_ELEM, toolBarGroup);
- writeClassValue(toolBarGroup, writer);
- writeStyleValue(toolBarGroup, writer);
- encodeEventsAttributes(facesContext, toolBarGroup);
- child.encodeAll(facesContext);
- writer.endElement(HtmlConstants.TD_ELEM);
- }
-
- private void writeStyleValue(AbstractToolBarGroup toolBarGroup, ResponseWriter writer) throws IOException {
- String style = getStringAttribute(toolBarGroup, HtmlConstants.STYLE_ATTRIBUTE);
- String contentStyle = getStringAttribute(getParentToolBar(toolBarGroup), "contentStyle");
-
- String value = getCompoundStyleValue(contentStyle, style);
-
- if (isPropertyRendered(value)) {
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, value, null);
- }
- }
-
- private String getCompoundStyleValue(String... styles) {
- if (styles != null) {
- StringBuilder result = new StringBuilder();
- for (int styleIndex = 0; styleIndex < styles.length; styleIndex++) {
- result.append(styles[styleIndex]);
- if (styleIndex != styles.length - 1) {
- result.append("; ");
- }
- }
- return result.toString();
- }
- return "";
- }
-
- private void writeClassValue(AbstractToolBarGroup toolBarGroup, ResponseWriter writer) throws IOException {
- String styleClass = getStringAttribute(toolBarGroup, HtmlConstants.STYLE_CLASS_ATTR);
- AbstractToolBar toolBar = getParentToolBar(toolBarGroup);
- String contentClass = null;
-
- if(toolBar != null) {
- contentClass = getStringAttribute(toolBar, "contentClass");
- }
-
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", contentClass, styleClass), null);
- }
-
- private String getStringAttribute(UIComponent toolBarGroup, String attribute) {
- String value = (String) toolBarGroup.getAttributes().get(attribute);
- return null == value ? "" : value;
- }
-
- public AbstractToolBar getParentToolBar(UIComponent component) {
- return (component instanceof AbstractToolBarGroup) ? ((AbstractToolBarGroup) component).getToolBar() : null;
- }
-
-}
\ No newline at end of file
Deleted: sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java
===================================================================
--- sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java 2010-11-30 09:11:39 UTC (rev 20222)
+++ sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java 2010-11-30 09:12:20 UTC (rev 20223)
@@ -1,254 +0,0 @@
-package org.richfaces.renderkit.html;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.richfaces.component.AbstractToolBar;
-import org.richfaces.component.AbstractToolBarGroup;
-import org.richfaces.component.util.ViewUtil;
-import org.richfaces.renderkit.ComponentAttribute;
-import org.richfaces.renderkit.HtmlConstants;
-import org.richfaces.renderkit.RenderKitUtils;
-import org.richfaces.renderkit.RendererBase;
-
-
-@ResourceDependency(library = "org.richfaces", name = "toolBar.ecss")
-public abstract class ToolBarRendererBase extends RendererBase {
-
- public static final String RENDERER_TYPE = "org.richfaces.ToolBarRenderer";
-
- public static final Map<String, ComponentAttribute> ITEMS_HANDLER_ATTRIBUTES = Collections
- .unmodifiableMap(ComponentAttribute.createMap(
- new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
- .setEventNames("itemclick")
- .setComponentAttributeName("onitemclick"),
- new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE)
- .setEventNames("itemdblclick")
- .setComponentAttributeName("onitemdblclick"),
- new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE)
- .setEventNames("itemmousedown")
- .setComponentAttributeName("onitemmousedown"),
- new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE)
- .setEventNames("itemmouseup")
- .setComponentAttributeName("onitemmouseup"),
- new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE)
- .setEventNames("itemmouseover")
- .setComponentAttributeName("onitemmouseover"),
- new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE)
- .setEventNames("itemmousemove")
- .setComponentAttributeName("onitemmousemove"),
- new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE)
- .setEventNames("itemmouseout")
- .setComponentAttributeName("onitemmouseout"),
- new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE)
- .setEventNames("itemkeypress")
- .setComponentAttributeName("onitemkeypress"),
- new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE)
- .setEventNames("itemkeydown")
- .setComponentAttributeName("onitemkeydown"),
- new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE)
- .setEventNames("itemkeyup")
- .setComponentAttributeName("onitemkeyup")
- ));
-
- public enum ItemSeparators {
- NONE, SQUARE, DISC, GRID, LINE
- }
-
- public enum Locations {
- RIGHT, LEFT
- }
-
- @Override
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- AbstractToolBar toolBar = (AbstractToolBar) component;
- String contentClass = (String) toolBar.getAttributes().get("contentClass");
- String contentStyle = (String) toolBar.getAttributes().get("contentStyle");
-
- List<UIComponent> children = toolBar.getChildren();
-
- if (children != null) {
- List<UIComponent> childrenToTheLeft = new LinkedList<UIComponent>();
- List<UIComponent> childrenToTheRight = new LinkedList<UIComponent>();
- for (UIComponent child : children) {
- if (child.isRendered()) {
- if (child instanceof AbstractToolBarGroup) {
- AbstractToolBarGroup group = (AbstractToolBarGroup) child;
- String location = group.getLocation();
- if (location != null && location.equalsIgnoreCase(Locations.RIGHT.toString())) {
- childrenToTheRight.add(child);
- } else {
- childrenToTheLeft.add(child);
- }
- } else {
- childrenToTheLeft.add(child);
- }
- }
- }
-
- ResponseWriter writer = context.getResponseWriter();
- for (Iterator<UIComponent> it = childrenToTheLeft.iterator(); it.hasNext();) {
-
- UIComponent child = it.next();
-
- if (!(child instanceof AbstractToolBarGroup)) {
- writer.startElement(HtmlConstants.TD_ELEM, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", contentClass), null);
- if (isPropertyRendered(contentStyle)) {
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, contentStyle, null);
- }
- encodeEventsAttributes(context, toolBar);
- }
-
- child.encodeAll(context);
-
- if (!(child instanceof AbstractToolBarGroup)) {
- writer.endElement(HtmlConstants.TD_ELEM);
- }
-
-
-
- if (it.hasNext()) {
- insertSeparatorIfNeed(context, toolBar, writer);
- }
- }
-
- writer.startElement(HtmlConstants.TD_ELEM, component);
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, "width:100%", null);
- writer.endElement(HtmlConstants.TD_ELEM);
-
- for (Iterator<UIComponent> it = childrenToTheRight.iterator(); it.hasNext();) {
- UIComponent child = it.next();
- child.encodeAll(context);
- if (it.hasNext()) {
- insertSeparatorIfNeed(context, toolBar, writer);
- }
- }
- }
- }
-
- public void encodeItem(FacesContext facesContext, UIComponent component, ResponseWriter writer, String contentStyle, String contentClass) throws IOException {
- if (!(component instanceof AbstractToolBarGroup)) {
- writer.startElement(HtmlConstants.TD_ELEM, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", contentClass), null);
- if (isPropertyRendered(contentStyle)) {
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, contentStyle, null);
- }
- encodeEventsAttributes(facesContext, component);
- }
-
- component.encodeAll(facesContext);
-
- if (!(component instanceof AbstractToolBarGroup)) {
- writer.endElement(HtmlConstants.TD_ELEM);
- }
- }
-
- /**
- * Inserts separator between toolbar items. Uses facet "itemSeparator" if it
- * is set and default separator implementation if facet is not set.
- *
- * @param context
- * - faces context
- * @param component
- * - component
- * @param writer
- * - response writer
- * @throws IOException
- * - in case of IOException during writing to the ResponseWriter
- */
- protected void insertSeparatorIfNeed(FacesContext context, UIComponent component, ResponseWriter writer)
- throws IOException {
- UIComponent separatorFacet = component.getFacet("itemSeparator");
- boolean isSeparatorFacetRendered = (separatorFacet != null) ? separatorFacet.isRendered() : false;
- if (isSeparatorFacetRendered) {
- writer.startElement(HtmlConstants.TD_ELEM, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-tb-sep", null);
- separatorFacet.encodeAll(context);
- writer.endElement(HtmlConstants.TD_ELEM);
- } else {
- insertDefaultSeparatorIfNeed(context, component, writer);
- }
- }
-
- /**
- * Inserts default separator. Possible values are: "square", "disc", "grid",
- * "line" - for separators provided by component implementation; "none" -
- * for no separators between toolbar items; URI string value - for custom
- * images specified by the page author.
- *
- * @param context
- * - faces context
- * @param component
- * - component
- * @param writer
- * - response writer
- * @throws IOException
- * - in case of IOException during writing to the ResponseWriter
- */
- protected void insertDefaultSeparatorIfNeed(FacesContext context, UIComponent component, ResponseWriter writer)
- throws IOException {
- String itemSeparator = (String) component.getAttributes().get("itemSeparator");
-
- if (itemSeparator != null && itemSeparator.trim().length() != 0
- && !itemSeparator.equalsIgnoreCase(ItemSeparators.NONE.toString())) {
-
- ItemSeparators separator = null;
- if (itemSeparator.equalsIgnoreCase(ItemSeparators.SQUARE.toString())) {
- separator = ItemSeparators.SQUARE;
- } else if (itemSeparator.equalsIgnoreCase(ItemSeparators.DISC.toString())) {
- separator = ItemSeparators.DISC;
- } else if (itemSeparator.equalsIgnoreCase(ItemSeparators.GRID.toString())) {
- separator = ItemSeparators.GRID;
- } else if (itemSeparator.equalsIgnoreCase(ItemSeparators.LINE.toString())) {
- separator = ItemSeparators.LINE;
- }
-
- writer.startElement(HtmlConstants.TD_ELEM, component);
- String separatorClass = "rf-tb-sep";
-
- if (separator != null) {
- String itemSeparatorClass = "rf-tb-sep-" + separator.toString().toLowerCase();
- separatorClass = concatClasses(separatorClass, itemSeparatorClass, (String) component.getAttributes().get("separatorClass"));
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, separatorClass, null);
- } else {
- concatClasses(separatorClass, (String) component.getAttributes().get("separatorClass"));
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, separatorClass, null);
-
- String uri = ViewUtil.getResourceURL(itemSeparator);
- writer.startElement(HtmlConstants.IMG_ELEMENT, component);
- writer.writeAttribute(HtmlConstants.SRC_ATTRIBUTE, uri, null);
- writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
- writer.endElement(HtmlConstants.IMG_ELEMENT);
- }
-
- writer.endElement(HtmlConstants.TD_ELEM);
- }
- }
-
- protected Class<? extends javax.faces.component.UIComponent> getComponentClass() {
- return AbstractToolBar.class;
- }
-
- public boolean getRendersChildren() {
- return true;
- }
-
- protected void encodeEventsAttributes(FacesContext facesContext, UIComponent component)
- throws IOException {
- RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component, ITEMS_HANDLER_ATTRIBUTES);
- }
-
- protected boolean isPropertyRendered(String property) {
- return ((null != property && !"".equals(property)));
- }
-}
Deleted: sandbox/trunk/ui/toolbar/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss
===================================================================
--- sandbox/trunk/ui/toolbar/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss 2010-11-30 09:11:39 UTC (rev 20222)
+++ sandbox/trunk/ui/toolbar/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss 2010-11-30 09:12:20 UTC (rev 20223)
@@ -1,48 +0,0 @@
-.rf-tb {
- border:1px solid;
- border-color:'#{richSkin.panelBorderColor}';
- color:'#{richSkin.headerTextColor}';
- font-family:'#{richSkin.headerFamilyFont}';
- font-size:'#{richSkin.headerSizeFont}';
- font-weight:'#{richSkin.headerWeightFont}';
- padding:0px;
- background-color:'#{richSkin.headerBackgroundColor}';
- background-position:left top;
- background-repeat:repeat-x;
- /*check gradient from headerGradientColor to headerBackgroundColor*/
- background-image:url("#{resource['org.richfaces.renderkit.html.GradientA']}");
- height:36px;
- width:100%;
-}
-
-.rf-tb-itm {
- padding:0 8px;
- white-space:nowrap;
-}
-
-.rf-tb-sep {
- padding:0 10px;
- text-align:center;
- background-repeat:no-repeat;
- background-position:center center;
-}
-
-.rf-tb-cntr{
- vertical-align:middle;
-}
-
-.rf-tb-sep-grid {
- background-image:url("#{resource['org.richfaces.renderkit.html.images.GridSeparatorImage']}");
-}
-
-.rf-tb-sep-line {
- background-image:url("#{resource['org.richfaces.renderkit.html.images.LineSeparatorImage']}");
-}
-
-.rf-tb-sep-disc {
- background-image:url("#{resource['org.richfaces.renderkit.html.images.DotSeparatorImage']}");
-}
-
-.rf-tb-sep-square {
- background-image:url("#{resource['org.richfaces.renderkit.html.images.SquareSeparatorImage']}");
-}
\ No newline at end of file
Deleted: sandbox/trunk/ui/toolbar/ui/src/main/templates/toolBar.template.xml
===================================================================
--- sandbox/trunk/ui/toolbar/ui/src/main/templates/toolBar.template.xml 2010-11-30 09:11:39 UTC (rev 20222)
+++ sandbox/trunk/ui/toolbar/ui/src/main/templates/toolBar.template.xml 2010-11-30 09:12:20 UTC (rev 20223)
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<cdk:root xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el"
- xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
- xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
- xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite"
- xmlns:javaee="http://java.sun.com/xml/ns/javaee">
-
- <cc:interface>
- <cdk:class>org.richfaces.renderkit.html.ToolBarRenderer</cdk:class>
- <cdk:superclass>org.richfaces.renderkit.html.ToolBarRendererBase</cdk:superclass>
- <cdk:component-family>org.richfaces.ToolBar</cdk:component-family>
- <cdk:renderer-type>org.richfaces.ToolBarRenderer</cdk:renderer-type>
- </cc:interface>
-
- <cc:implementation>
- <table border="0" cellpadding="0" cellspacing="0" id="#{clientId}" width="#{component.attributes['width']}"
- height="#{component.attributes['height']}" class="rf-tb #{component.attributes['styleClass']}"
- style="#{component.attributes['style']}"
- cdk:passThroughWithExclusions="">
- <tr class="rf-tb-cntr">
- <cdk:body />
- </tr>
- </table>
- </cc:implementation>
-</cdk:root>
14 years, 3 months
JBoss Rich Faces SVN: r20222 - in trunk/ui/output/ui/src/main: java/org/richfaces/renderkit/html and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-11-30 04:11:39 -0500 (Tue, 30 Nov 2010)
New Revision: 20222
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolBar.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolBarGroup.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images/
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss
trunk/ui/output/ui/src/main/templates/toolBar.template.xml
Log:
move from sandbox
Copied: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolBar.java (from rev 20044, sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/component/AbstractToolBar.java)
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolBar.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolBar.java 2010-11-30 09:11:39 UTC (rev 20222)
@@ -0,0 +1,60 @@
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.renderkit.html.ToolBarRendererBase;
+
+@JsfComponent(family = AbstractToolBar.COMPONENT_FAMILY, type = AbstractToolBar.COMPONENT_TYPE,
+ renderer=@JsfRenderer(type = ToolBarRendererBase.RENDERER_TYPE), tag = @Tag(name="toolBar")
+)
+public abstract class AbstractToolBar extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.ToolBar";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.ToolBar";
+
+ @Attribute
+ public abstract String getHeight();
+
+ @Attribute
+ public abstract String getWidth();
+
+ @Attribute
+ public abstract String getItemSeparator();
+
+ @Attribute(events=@EventName("itemclick"))
+ public abstract String getOnitemclick();
+
+ @Attribute(events=@EventName("itemdblclick"))
+ public abstract String getOnitemdblclick();
+
+ @Attribute(events=@EventName("itemmousedown"))
+ public abstract String getOnitemmousedown();
+
+ @Attribute(events=@EventName("itemmouseup"))
+ public abstract String getOnitemmouseup();
+
+ @Attribute(events=@EventName("itemmouseover"))
+ public abstract String getOnitemmouseover();
+
+ @Attribute(events=@EventName("itemmousemove"))
+ public abstract String getOnitemmousemove();
+
+ @Attribute(events=@EventName("itemmouseout"))
+ public abstract String getOnitemmouseout();
+
+ @Attribute(events=@EventName("itemkeypress"))
+ public abstract String getOnitemkeypress();
+
+ @Attribute(events=@EventName("itemkeydown"))
+ public abstract String getOnitemkeydown();
+
+ @Attribute(events=@EventName("itemkeyup"))
+ public abstract String getOnitemkeyup();
+
+}
Copied: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolBarGroup.java (from rev 20044, sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/component/AbstractToolBarGroup.java)
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolBarGroup.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractToolBarGroup.java 2010-11-30 09:11:39 UTC (rev 20222)
@@ -0,0 +1,84 @@
+package org.richfaces.component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.renderkit.html.ToolBarGroupRenderer;
+
+@JsfComponent(family = AbstractToolBar.COMPONENT_FAMILY, type = AbstractToolBarGroup.COMPONENT_TYPE,
+ renderer=@JsfRenderer(type = ToolBarGroupRenderer.RENDERER_TYPE), tag = @Tag(name="toolBarGroup"))
+public abstract class AbstractToolBarGroup extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.ToolBarGroup";
+
+ @Attribute
+ public abstract String getItemSeparator();
+
+ @Attribute
+ public abstract String getLocation();
+
+ @Attribute(events=@EventName("itemclick"))
+ public abstract String getOnitemclick();
+
+ @Attribute(events=@EventName("itemdblclick"))
+ public abstract String getOnitemdblclick();
+
+ @Attribute(events=@EventName("itemmousedown"))
+ public abstract String getOnitemmousedown();
+
+ @Attribute(events=@EventName("itemmouseup"))
+ public abstract String getOnitemmouseup();
+
+ @Attribute(events=@EventName("itemmouseover"))
+ public abstract String getOnitemmouseover();
+
+ @Attribute(events=@EventName("itemmousemove"))
+ public abstract String getOnitemmousemove();
+
+ @Attribute(events=@EventName("itemmouseout"))
+ public abstract String getOnitemmouseout();
+
+ @Attribute(events=@EventName("itemkeypress"))
+ public abstract String getOnitemkeypress();
+
+ @Attribute(events=@EventName("itemkeydown"))
+ public abstract String getOnitemkeydown();
+
+ @Attribute(events=@EventName("itemkeyup"))
+ public abstract String getOnitemkeyup();
+
+ public AbstractToolBar getToolBar() {
+ UIComponent component = this.getParent();
+ if (component == null) {
+ throw new FacesException("The component: " + this.getClientId(getFacesContext()) +
+ " is not nested within " + AbstractToolBar.class.getSimpleName());
+ } else if (!(component instanceof AbstractToolBar)) {
+ throw new FacesException("The component: " + this.getClientId(getFacesContext()) +
+ " is not a direct child of " + AbstractToolBar.class.getSimpleName());
+ }
+ return (AbstractToolBar) component;
+ }
+
+ public List<UIComponent> getRenderedChildren() {
+ List<UIComponent> children = this.getChildren();
+ List<UIComponent> renderedChildren = new ArrayList<UIComponent>(children.size());
+
+ for (UIComponent child : children) {
+ if (child.isRendered()) {
+ renderedChildren.add(child);
+ }
+ }
+
+ return renderedChildren;
+ }
+
+}
Copied: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java (from rev 20044, sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java)
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolBarGroupRenderer.java 2010-11-30 09:11:39 UTC (rev 20222)
@@ -0,0 +1,99 @@
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.component.AbstractToolBar;
+import org.richfaces.component.AbstractToolBarGroup;
+import org.richfaces.renderkit.HtmlConstants;
+
+@JsfRenderer(type = ToolBarGroupRenderer.RENDERER_TYPE, family = AbstractToolBar.COMPONENT_FAMILY)
+public class ToolBarGroupRenderer extends ToolBarRendererBase {
+
+ public static final String RENDERER_TYPE = "org.richfaces.ToolBarGroupRenderer";
+
+ protected Class<? extends UIComponent> getComponentClass() {
+ return AbstractToolBarGroup.class;
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
+ AbstractToolBarGroup toolBarGroup = (AbstractToolBarGroup) component;
+ List<UIComponent> renderedChildren = toolBarGroup.getRenderedChildren();
+ if (renderedChildren.size() <= 0) {
+ return;
+ }
+
+ ResponseWriter writer = facesContext.getResponseWriter();
+ renderChild(facesContext, toolBarGroup, writer, renderedChildren.get(0));
+ for (int i = 1; i < renderedChildren.size(); i++) {
+ insertSeparatorIfNeed(facesContext, toolBarGroup, writer);
+ renderChild(facesContext, toolBarGroup, writer, renderedChildren.get(i));
+ }
+ }
+
+ private void renderChild(FacesContext facesContext, AbstractToolBarGroup toolBarGroup, ResponseWriter writer,
+ UIComponent child) throws IOException {
+ writer.startElement(HtmlConstants.TD_ELEM, toolBarGroup);
+ writeClassValue(toolBarGroup, writer);
+ writeStyleValue(toolBarGroup, writer);
+ encodeEventsAttributes(facesContext, toolBarGroup);
+ child.encodeAll(facesContext);
+ writer.endElement(HtmlConstants.TD_ELEM);
+ }
+
+ private void writeStyleValue(AbstractToolBarGroup toolBarGroup, ResponseWriter writer) throws IOException {
+ String style = getStringAttribute(toolBarGroup, HtmlConstants.STYLE_ATTRIBUTE);
+ String contentStyle = getStringAttribute(getParentToolBar(toolBarGroup), "contentStyle");
+
+ String value = getCompoundStyleValue(contentStyle, style);
+
+ if (isPropertyRendered(value)) {
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, value, null);
+ }
+ }
+
+ private String getCompoundStyleValue(String... styles) {
+ if (styles != null) {
+ StringBuilder result = new StringBuilder();
+ for (int styleIndex = 0; styleIndex < styles.length; styleIndex++) {
+ result.append(styles[styleIndex]);
+ if (styleIndex != styles.length - 1) {
+ result.append("; ");
+ }
+ }
+ return result.toString();
+ }
+ return "";
+ }
+
+ private void writeClassValue(AbstractToolBarGroup toolBarGroup, ResponseWriter writer) throws IOException {
+ String styleClass = getStringAttribute(toolBarGroup, HtmlConstants.STYLE_CLASS_ATTR);
+ AbstractToolBar toolBar = getParentToolBar(toolBarGroup);
+ String contentClass = null;
+
+ if(toolBar != null) {
+ contentClass = getStringAttribute(toolBar, "contentClass");
+ }
+
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", contentClass, styleClass), null);
+ }
+
+ private String getStringAttribute(UIComponent toolBarGroup, String attribute) {
+ String value = (String) toolBarGroup.getAttributes().get(attribute);
+ return null == value ? "" : value;
+ }
+
+ public AbstractToolBar getParentToolBar(UIComponent component) {
+ return (component instanceof AbstractToolBarGroup) ? ((AbstractToolBarGroup) component).getToolBar() : null;
+ }
+
+}
\ No newline at end of file
Copied: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java (from rev 20044, sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java)
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolBarRendererBase.java 2010-11-30 09:11:39 UTC (rev 20222)
@@ -0,0 +1,254 @@
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.richfaces.component.AbstractToolBar;
+import org.richfaces.component.AbstractToolBarGroup;
+import org.richfaces.component.util.ViewUtil;
+import org.richfaces.renderkit.ComponentAttribute;
+import org.richfaces.renderkit.HtmlConstants;
+import org.richfaces.renderkit.RenderKitUtils;
+import org.richfaces.renderkit.RendererBase;
+
+
+@ResourceDependency(library = "org.richfaces", name = "toolBar.ecss")
+public abstract class ToolBarRendererBase extends RendererBase {
+
+ public static final String RENDERER_TYPE = "org.richfaces.ToolBarRenderer";
+
+ public static final Map<String, ComponentAttribute> ITEMS_HANDLER_ATTRIBUTES = Collections
+ .unmodifiableMap(ComponentAttribute.createMap(
+ new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
+ .setEventNames("itemclick")
+ .setComponentAttributeName("onitemclick"),
+ new ComponentAttribute(HtmlConstants.ONDBLCLICK_ATTRIBUTE)
+ .setEventNames("itemdblclick")
+ .setComponentAttributeName("onitemdblclick"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEDOWN_ATTRIBUTE)
+ .setEventNames("itemmousedown")
+ .setComponentAttributeName("onitemmousedown"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEUP_ATTRIBUTE)
+ .setEventNames("itemmouseup")
+ .setComponentAttributeName("onitemmouseup"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOVER_ATTRIBUTE)
+ .setEventNames("itemmouseover")
+ .setComponentAttributeName("onitemmouseover"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEMOVE_ATTRIBUTE)
+ .setEventNames("itemmousemove")
+ .setComponentAttributeName("onitemmousemove"),
+ new ComponentAttribute(HtmlConstants.ONMOUSEOUT_ATTRIBUTE)
+ .setEventNames("itemmouseout")
+ .setComponentAttributeName("onitemmouseout"),
+ new ComponentAttribute(HtmlConstants.ONKEYPRESS_ATTRIBUTE)
+ .setEventNames("itemkeypress")
+ .setComponentAttributeName("onitemkeypress"),
+ new ComponentAttribute(HtmlConstants.ONKEYDOWN_ATTRIBUTE)
+ .setEventNames("itemkeydown")
+ .setComponentAttributeName("onitemkeydown"),
+ new ComponentAttribute(HtmlConstants.ONKEYUP_ATTRIBUTE)
+ .setEventNames("itemkeyup")
+ .setComponentAttributeName("onitemkeyup")
+ ));
+
+ public enum ItemSeparators {
+ NONE, SQUARE, DISC, GRID, LINE
+ }
+
+ public enum Locations {
+ RIGHT, LEFT
+ }
+
+ @Override
+ public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
+ AbstractToolBar toolBar = (AbstractToolBar) component;
+ String contentClass = (String) toolBar.getAttributes().get("contentClass");
+ String contentStyle = (String) toolBar.getAttributes().get("contentStyle");
+
+ List<UIComponent> children = toolBar.getChildren();
+
+ if (children != null) {
+ List<UIComponent> childrenToTheLeft = new LinkedList<UIComponent>();
+ List<UIComponent> childrenToTheRight = new LinkedList<UIComponent>();
+ for (UIComponent child : children) {
+ if (child.isRendered()) {
+ if (child instanceof AbstractToolBarGroup) {
+ AbstractToolBarGroup group = (AbstractToolBarGroup) child;
+ String location = group.getLocation();
+ if (location != null && location.equalsIgnoreCase(Locations.RIGHT.toString())) {
+ childrenToTheRight.add(child);
+ } else {
+ childrenToTheLeft.add(child);
+ }
+ } else {
+ childrenToTheLeft.add(child);
+ }
+ }
+ }
+
+ ResponseWriter writer = context.getResponseWriter();
+ for (Iterator<UIComponent> it = childrenToTheLeft.iterator(); it.hasNext();) {
+
+ UIComponent child = it.next();
+
+ if (!(child instanceof AbstractToolBarGroup)) {
+ writer.startElement(HtmlConstants.TD_ELEM, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", contentClass), null);
+ if (isPropertyRendered(contentStyle)) {
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, contentStyle, null);
+ }
+ encodeEventsAttributes(context, toolBar);
+ }
+
+ child.encodeAll(context);
+
+ if (!(child instanceof AbstractToolBarGroup)) {
+ writer.endElement(HtmlConstants.TD_ELEM);
+ }
+
+
+
+ if (it.hasNext()) {
+ insertSeparatorIfNeed(context, toolBar, writer);
+ }
+ }
+
+ writer.startElement(HtmlConstants.TD_ELEM, component);
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, "width:100%", null);
+ writer.endElement(HtmlConstants.TD_ELEM);
+
+ for (Iterator<UIComponent> it = childrenToTheRight.iterator(); it.hasNext();) {
+ UIComponent child = it.next();
+ child.encodeAll(context);
+ if (it.hasNext()) {
+ insertSeparatorIfNeed(context, toolBar, writer);
+ }
+ }
+ }
+ }
+
+ public void encodeItem(FacesContext facesContext, UIComponent component, ResponseWriter writer, String contentStyle, String contentClass) throws IOException {
+ if (!(component instanceof AbstractToolBarGroup)) {
+ writer.startElement(HtmlConstants.TD_ELEM, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", contentClass), null);
+ if (isPropertyRendered(contentStyle)) {
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, contentStyle, null);
+ }
+ encodeEventsAttributes(facesContext, component);
+ }
+
+ component.encodeAll(facesContext);
+
+ if (!(component instanceof AbstractToolBarGroup)) {
+ writer.endElement(HtmlConstants.TD_ELEM);
+ }
+ }
+
+ /**
+ * Inserts separator between toolbar items. Uses facet "itemSeparator" if it
+ * is set and default separator implementation if facet is not set.
+ *
+ * @param context
+ * - faces context
+ * @param component
+ * - component
+ * @param writer
+ * - response writer
+ * @throws IOException
+ * - in case of IOException during writing to the ResponseWriter
+ */
+ protected void insertSeparatorIfNeed(FacesContext context, UIComponent component, ResponseWriter writer)
+ throws IOException {
+ UIComponent separatorFacet = component.getFacet("itemSeparator");
+ boolean isSeparatorFacetRendered = (separatorFacet != null) ? separatorFacet.isRendered() : false;
+ if (isSeparatorFacetRendered) {
+ writer.startElement(HtmlConstants.TD_ELEM, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-tb-sep", null);
+ separatorFacet.encodeAll(context);
+ writer.endElement(HtmlConstants.TD_ELEM);
+ } else {
+ insertDefaultSeparatorIfNeed(context, component, writer);
+ }
+ }
+
+ /**
+ * Inserts default separator. Possible values are: "square", "disc", "grid",
+ * "line" - for separators provided by component implementation; "none" -
+ * for no separators between toolbar items; URI string value - for custom
+ * images specified by the page author.
+ *
+ * @param context
+ * - faces context
+ * @param component
+ * - component
+ * @param writer
+ * - response writer
+ * @throws IOException
+ * - in case of IOException during writing to the ResponseWriter
+ */
+ protected void insertDefaultSeparatorIfNeed(FacesContext context, UIComponent component, ResponseWriter writer)
+ throws IOException {
+ String itemSeparator = (String) component.getAttributes().get("itemSeparator");
+
+ if (itemSeparator != null && itemSeparator.trim().length() != 0
+ && !itemSeparator.equalsIgnoreCase(ItemSeparators.NONE.toString())) {
+
+ ItemSeparators separator = null;
+ if (itemSeparator.equalsIgnoreCase(ItemSeparators.SQUARE.toString())) {
+ separator = ItemSeparators.SQUARE;
+ } else if (itemSeparator.equalsIgnoreCase(ItemSeparators.DISC.toString())) {
+ separator = ItemSeparators.DISC;
+ } else if (itemSeparator.equalsIgnoreCase(ItemSeparators.GRID.toString())) {
+ separator = ItemSeparators.GRID;
+ } else if (itemSeparator.equalsIgnoreCase(ItemSeparators.LINE.toString())) {
+ separator = ItemSeparators.LINE;
+ }
+
+ writer.startElement(HtmlConstants.TD_ELEM, component);
+ String separatorClass = "rf-tb-sep";
+
+ if (separator != null) {
+ String itemSeparatorClass = "rf-tb-sep-" + separator.toString().toLowerCase();
+ separatorClass = concatClasses(separatorClass, itemSeparatorClass, (String) component.getAttributes().get("separatorClass"));
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, separatorClass, null);
+ } else {
+ concatClasses(separatorClass, (String) component.getAttributes().get("separatorClass"));
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, separatorClass, null);
+
+ String uri = ViewUtil.getResourceURL(itemSeparator);
+ writer.startElement(HtmlConstants.IMG_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.SRC_ATTRIBUTE, uri, null);
+ writer.writeAttribute(HtmlConstants.ALT_ATTRIBUTE, "", null);
+ writer.endElement(HtmlConstants.IMG_ELEMENT);
+ }
+
+ writer.endElement(HtmlConstants.TD_ELEM);
+ }
+ }
+
+ protected Class<? extends javax.faces.component.UIComponent> getComponentClass() {
+ return AbstractToolBar.class;
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ protected void encodeEventsAttributes(FacesContext facesContext, UIComponent component)
+ throws IOException {
+ RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component, ITEMS_HANDLER_ATTRIBUTES);
+ }
+
+ protected boolean isPropertyRendered(String property) {
+ return ((null != property && !"".equals(property)));
+ }
+}
Copied: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/images (from rev 20044, sandbox/trunk/ui/toolbar/ui/src/main/java/org/richfaces/renderkit/html/images)
Copied: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss (from rev 20044, sandbox/trunk/ui/toolbar/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss)
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss (rev 0)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss 2010-11-30 09:11:39 UTC (rev 20222)
@@ -0,0 +1,48 @@
+.rf-tb {
+ border:1px solid;
+ border-color:'#{richSkin.panelBorderColor}';
+ color:'#{richSkin.headerTextColor}';
+ font-family:'#{richSkin.headerFamilyFont}';
+ font-size:'#{richSkin.headerSizeFont}';
+ font-weight:'#{richSkin.headerWeightFont}';
+ padding:0px;
+ background-color:'#{richSkin.headerBackgroundColor}';
+ background-position:left top;
+ background-repeat:repeat-x;
+ /*check gradient from headerGradientColor to headerBackgroundColor*/
+ background-image:url("#{resource['org.richfaces.renderkit.html.GradientA']}");
+ height:36px;
+ width:100%;
+}
+
+.rf-tb-itm {
+ padding:0 8px;
+ white-space:nowrap;
+}
+
+.rf-tb-sep {
+ padding:0 10px;
+ text-align:center;
+ background-repeat:no-repeat;
+ background-position:center center;
+}
+
+.rf-tb-cntr{
+ vertical-align:middle;
+}
+
+.rf-tb-sep-grid {
+ background-image:url("#{resource['org.richfaces.renderkit.html.images.GridSeparatorImage']}");
+}
+
+.rf-tb-sep-line {
+ background-image:url("#{resource['org.richfaces.renderkit.html.images.LineSeparatorImage']}");
+}
+
+.rf-tb-sep-disc {
+ background-image:url("#{resource['org.richfaces.renderkit.html.images.DotSeparatorImage']}");
+}
+
+.rf-tb-sep-square {
+ background-image:url("#{resource['org.richfaces.renderkit.html.images.SquareSeparatorImage']}");
+}
\ No newline at end of file
Copied: trunk/ui/output/ui/src/main/templates/toolBar.template.xml (from rev 20044, sandbox/trunk/ui/toolbar/ui/src/main/templates/toolBar.template.xml)
===================================================================
--- trunk/ui/output/ui/src/main/templates/toolBar.template.xml (rev 0)
+++ trunk/ui/output/ui/src/main/templates/toolBar.template.xml 2010-11-30 09:11:39 UTC (rev 20222)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el"
+ xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
+ xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
+ xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite"
+ xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.ToolBarRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.html.ToolBarRendererBase</cdk:superclass>
+ <cdk:component-family>org.richfaces.ToolBar</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.ToolBarRenderer</cdk:renderer-type>
+ </cc:interface>
+
+ <cc:implementation>
+ <table border="0" cellpadding="0" cellspacing="0" id="#{clientId}" width="#{component.attributes['width']}"
+ height="#{component.attributes['height']}" class="rf-tb #{component.attributes['styleClass']}"
+ style="#{component.attributes['style']}"
+ cdk:passThroughWithExclusions="">
+ <tr class="rf-tb-cntr">
+ <cdk:body />
+ </tr>
+ </table>
+ </cc:implementation>
+</cdk:root>
14 years, 3 months
JBoss Rich Faces SVN: r20221 - trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/tag.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-11-30 03:48:10 -0500 (Tue, 30 Nov 2010)
New Revision: 20221
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/tag/AjaxBehaviorRule.java
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/tag/BehaviorRule.java
Log:
fix rules
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/tag/AjaxBehaviorRule.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/tag/AjaxBehaviorRule.java 2010-11-30 00:36:07 UTC (rev 20220)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/tag/AjaxBehaviorRule.java 2010-11-30 08:48:10 UTC (rev 20221)
@@ -72,15 +72,15 @@
return new ValueExpressionMetadata(name, type, attribute);
} else if (meta != null && meta.getWriteMethod(name) != null) {
- if (EXECUTE.equals(name) || RENDER.equals(name)) {
- return new LiteralAttributeMetadata(name, attribute.getValue());
- }
+ return new LiteralAttributeMetadata(name, attribute.getValue());
}
}
return null;
}
-
+
+
+
public static final class AjaxBehaviorListenerMapper extends Metadata {
private final TagAttribute attr;
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/tag/BehaviorRule.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/tag/BehaviorRule.java 2010-11-30 00:36:07 UTC (rev 20220)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/tag/BehaviorRule.java 2010-11-30 08:48:10 UTC (rev 20221)
@@ -83,7 +83,7 @@
}
return new ValueExpressionMetadata(name, type, attribute);
- } else {
+ } else if(meta != null && meta.getWriteMethod(name) != null) {
return new LiteralAttributeMetadata(name, attribute.getValue());
}
}
14 years, 3 months
JBoss Rich Faces SVN: r20220 - in branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces: validator and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-29 19:36:07 -0500 (Mon, 29 Nov 2010)
New Revision: 20220
Added:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UITransient.java
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/BeanValidator.java
Log:
CODING IN PROGRESS - issue RF-9612: Create JSF 2.0 resource loading extension to dynamically add scripts and its dependencies.
https://jira.jboss.org/browse/RF-9612
Added: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UITransient.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UITransient.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UITransient.java 2010-11-30 00:36:07 UTC (rev 20220)
@@ -0,0 +1,402 @@
+package org.richfaces.component;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.el.ValueExpression;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.UniqueIdVendor;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.render.Renderer;
+
+import org.richfaces.renderkit.html.ValidatorScriptRenderer;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterators;
+
+public abstract class UITransient extends UIComponent {
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Script";
+ private String id;
+
+ private UIComponent parent;
+
+ private String target = "form";
+
+ private final Map<String, Object> attributesMap = new AttributesMap();
+
+
+ private String clientId;
+
+ public UITransient() {
+ super();
+ }
+
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public Object saveState(FacesContext context) {
+ // This is transient component
+ return null;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ // Do nothing, this component never saved
+
+ }
+
+ public boolean isTransient() {
+ return true;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+
+ }
+
+ @Override
+ public Map<String, Object> getAttributes() {
+ return attributesMap;
+ }
+
+ @Override
+ public ValueBinding getValueBinding(String name) {
+ return null;
+ }
+
+ @Override
+ public void setValueBinding(String name, ValueBinding binding) {
+ // do nothing
+
+ }
+
+ @Override
+ public ValueExpression getValueExpression(String name) {
+ return null;
+ }
+
+ @Override
+ public void setValueExpression(String name, ValueExpression binding) {
+ // do nothing
+ }
+
+ @Override
+ public String getClientId(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ // if the clientId is not yet set
+ if (this.clientId == null) {
+ UIComponent namingContainerAncestor = this.getNamingContainerAncestor();
+ String parentId = null;
+
+ // give the parent the opportunity to first
+ // grab a unique clientId
+ if (namingContainerAncestor != null) {
+ parentId = namingContainerAncestor.getContainerClientId(context);
+ }
+
+ // now resolve our own client id
+ String clientId = getId();
+ if (clientId == null) {
+ if (null != namingContainerAncestor && namingContainerAncestor instanceof UniqueIdVendor) {
+ clientId = ((UniqueIdVendor) namingContainerAncestor).createUniqueId(context, null);
+ } else {
+ clientId = context.getViewRoot().createUniqueId();
+ }
+ setId(clientId);
+ }
+ if (parentId != null) {
+ StringBuilder idBuilder = new StringBuilder(parentId.length() + 1 + clientId.length());
+ clientId = idBuilder.append(parentId).append(UINamingContainer.getSeparatorChar(context))
+ .append(clientId).toString();
+ }
+
+ // allow the renderer to convert the clientId
+ Renderer renderer = this.getRenderer(context);
+ if (renderer != null) {
+ this.clientId = renderer.convertClientId(context, clientId);
+ } else {
+ this.clientId = clientId;
+ }
+ }
+ return this.clientId;
+ }
+
+ private UIComponent getNamingContainerAncestor() {
+ UIComponent namingContainer = this.getParent();
+ while (namingContainer != null) {
+ if (namingContainer instanceof NamingContainer) {
+ return namingContainer;
+ }
+ namingContainer = namingContainer.getParent();
+ }
+ return null;
+ }
+
+ @Override
+ public String getId() {
+ return this.id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+
+ }
+
+ @Override
+ public UIComponent getParent() {
+ return this.parent;
+ }
+
+ @Override
+ public void setParent(UIComponent parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public boolean isRendered() {
+ return true;
+ }
+
+ @Override
+ public void setRendered(boolean rendered) {
+ // always rendered
+ }
+
+ @Override
+ public String getRendererType() {
+ return ValidatorScriptRenderer.RENDERER_TYPE;
+ }
+
+ @Override
+ public void setRendererType(String rendererType) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean getRendersChildren() {
+ return false;
+ }
+
+ @Override
+ public List<UIComponent> getChildren() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public int getChildCount() {
+ return 0;
+ }
+
+ @Override
+ public UIComponent findComponent(String expr) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Map<String, UIComponent> getFacets() {
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public UIComponent getFacet(String name) {
+ return null;
+ }
+
+ @Override
+ public Iterator<UIComponent> getFacetsAndChildren() {
+ return Iterators.emptyIterator();
+ }
+
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ // Do nothing
+ }
+
+ @Override
+ public void decode(FacesContext context) {
+ // Do nothing
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void encodeChildren(FacesContext context) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context) throws IOException {
+ Renderer renderer = getRenderer(context);
+ if(null != renderer){
+ renderer.encodeEnd(context, this);
+ }
+ }
+
+ @Override
+ protected void addFacesListener(FacesListener listener) {
+ }
+
+ @Override
+ protected FacesListener[] getFacesListeners(Class clazz) {
+ return new FacesListener[0];
+ }
+
+ @Override
+ protected void removeFacesListener(FacesListener listener) {
+ }
+
+ @Override
+ public void queueEvent(FacesEvent event) {
+ if (null != getParent()) {
+ getParent().queueEvent(event);
+ }
+
+ }
+
+ @Override
+ public void processRestoreState(FacesContext context, Object state) {
+ // Do nothing, this component does not have state.
+
+ }
+
+ @Override
+ public void processDecodes(FacesContext context) {
+ // Do nothing
+
+ }
+
+ @Override
+ public void processValidators(FacesContext context) {
+ // Do nothing
+
+ }
+
+ @Override
+ public void processUpdates(FacesContext context) {
+ // Do nothing
+ }
+
+ @Override
+ public Object processSaveState(FacesContext context) {
+ // Should never be used
+ return null;
+ }
+
+ @Override
+ protected FacesContext getFacesContext() {
+ return FacesContext.getCurrentInstance();
+ }
+
+ @Override
+ protected Renderer getRenderer(FacesContext context) {
+ String rendererType = getRendererType();
+ Renderer result = null;
+ if (rendererType != null) {
+ result = context.getRenderKit().getRenderer(getFamily(), rendererType);
+ }
+ return result;
+ }
+
+ final class AttributesMap implements Map<String, Object> {
+ public void clear() {
+ // do nothing
+
+ }
+
+ public boolean containsKey(Object key) {
+
+ return "target".equals(key)||"id".equals(key)||"clientId".equals(key);
+ }
+
+ public boolean containsValue(Object value) {
+ return false;
+ }
+
+ public Set<java.util.Map.Entry<String, Object>> entrySet() {
+ return Collections.emptySet();
+ }
+
+ public Object get(Object key) {
+ if("target".equals(key)){
+ return getTarget();
+ } else if ("id".equals(key)) {
+ return getId();
+ } else if ("clientId".equals(key)) {
+ return getClientId();
+ }
+ return null;
+ }
+
+ public boolean isEmpty() {
+ return false;
+ }
+
+ public Set<String> keySet() {
+ return ImmutableSet.of("target","id","clientId");
+ }
+
+ public Object put(String key, Object value) {
+ if("target".equals(key)){
+ String target = getTarget();
+ setTarget((String) value);
+ return target;
+ } else if ("id".equals(key)) {
+ String id = getId();
+ setId((String) value);
+ return id;
+ }
+ return null;
+ }
+
+ public void putAll(Map<? extends String, ? extends Object> m) {
+
+
+ }
+
+ public Object remove(Object key) {
+ return null;
+ }
+
+ public int size() {
+ return 3;
+ }
+
+ public Collection<Object> values() {
+ return ImmutableList.<Object>of(getTarget(),getId(),getClientId());
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UITransient.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java 2010-11-30 00:05:46 UTC (rev 20219)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java 2010-11-30 00:36:07 UTC (rev 20220)
@@ -23,32 +23,17 @@
package org.richfaces.component;
-import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import javax.el.ValueExpression;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UINamingContainer;
-import javax.faces.component.UniqueIdVendor;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-import javax.faces.render.Renderer;
import org.richfaces.renderkit.html.ComponentValidatorScript;
-import org.richfaces.renderkit.html.ValidatorScriptRenderer;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
/**
@@ -60,94 +45,17 @@
* @author asmirnov(a)exadel.com
*
*/
-public class UIValidatorScript extends UIComponent {
+public class UIValidatorScript extends UITransient {
- private final class AttributesMap implements Map<String, Object> {
- public void clear() {
- // do nothing
-
- }
- public boolean containsKey(Object key) {
-
- return "target".equals(key)||"id".equals(key)||"clientId".equals(key);
- }
-
- public boolean containsValue(Object value) {
- return false;
- }
-
- public Set<java.util.Map.Entry<String, Object>> entrySet() {
- return Collections.emptySet();
- }
-
- public Object get(Object key) {
- if("target".equals(key)){
- return getTarget();
- } else if ("id".equals(key)) {
- return getId();
- } else if ("clientId".equals(key)) {
- return getClientId();
- }
- return null;
- }
-
- public boolean isEmpty() {
- return false;
- }
-
- public Set<String> keySet() {
- return ImmutableSet.of("target","id","clientId");
- }
-
- public Object put(String key, Object value) {
- if("target".equals(key)){
- String target = getTarget();
- setTarget((String) value);
- return target;
- } else if ("id".equals(key)) {
- String id = getId();
- setId((String) value);
- return id;
- }
- return null;
- }
-
- public void putAll(Map<? extends String, ? extends Object> m) {
-
-
- }
-
- public Object remove(Object key) {
- return null;
- }
-
- public int size() {
- return 3;
- }
-
- public Collection<Object> values() {
- return ImmutableList.<Object>of(getTarget(),getId(),getClientId());
- }
- }
-
public static final String COMPONENT_TYPE = "org.richfaces.ValidatorScript";
- public static final String COMPONENT_FAMILY = "org.richfaces.Script";
-
- private String id;
- private UIComponent parent;
- private String target="form";
- private final List<ComponentValidatorScript> scripts = Lists.newArrayList();
+ final List<ComponentValidatorScript> scripts = Lists.newArrayList();
- private final Map<String, Object> attributesMap = new AttributesMap();
-
- private String clientId;
-
public Collection<ComponentValidatorScript> getScripts() {
return scripts;
}
-
+
public ComponentValidatorScript addOrFindScript(ComponentValidatorScript validatorScript) {
// TODO optimize
for (ComponentValidatorScript script : this.scripts) {
@@ -159,288 +67,4 @@
return validatorScript;
}
- public void setTarget(String target) {
- this.target = target;
- }
-
- public String getTarget() {
- return target;
- }
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
- public Object saveState(FacesContext context) {
- // This is transient component
- return null;
- }
-
- public void restoreState(FacesContext context, Object state) {
- // Do nothing, this component never saved
-
- }
-
- public boolean isTransient() {
- return true;
- }
-
- public void setTransient(boolean newTransientValue) {
-
- }
-
- @Override
- public Map<String, Object> getAttributes() {
- return attributesMap;
- }
-
- @Override
- public ValueBinding getValueBinding(String name) {
- return null;
- }
-
- @Override
- public void setValueBinding(String name, ValueBinding binding) {
- // do nothing
-
- }
-
- @Override
- public ValueExpression getValueExpression(String name) {
- return null;
- }
-
- @Override
- public void setValueExpression(String name, ValueExpression binding) {
- // do nothing
- }
-
- @Override
- public String getClientId(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
-
- // if the clientId is not yet set
- if (this.clientId == null) {
- UIComponent namingContainerAncestor = this.getNamingContainerAncestor();
- String parentId = null;
-
- // give the parent the opportunity to first
- // grab a unique clientId
- if (namingContainerAncestor != null) {
- parentId = namingContainerAncestor.getContainerClientId(context);
- }
-
- // now resolve our own client id
- String clientId = getId();
- if (clientId == null) {
- if (null != namingContainerAncestor && namingContainerAncestor instanceof UniqueIdVendor) {
- clientId = ((UniqueIdVendor) namingContainerAncestor).createUniqueId(context, null);
- } else {
- clientId = context.getViewRoot().createUniqueId();
- }
- setId(clientId);
- }
- if (parentId != null) {
- StringBuilder idBuilder = new StringBuilder(parentId.length() + 1 + clientId.length());
- clientId = idBuilder.append(parentId).append(UINamingContainer.getSeparatorChar(context))
- .append(clientId).toString();
- }
-
- // allow the renderer to convert the clientId
- Renderer renderer = this.getRenderer(context);
- if (renderer != null) {
- this.clientId = renderer.convertClientId(context, clientId);
- } else {
- this.clientId = clientId;
- }
- }
- return this.clientId;
- }
-
- private UIComponent getNamingContainerAncestor() {
- UIComponent namingContainer = this.getParent();
- while (namingContainer != null) {
- if (namingContainer instanceof NamingContainer) {
- return namingContainer;
- }
- namingContainer = namingContainer.getParent();
- }
- return null;
- }
-
- @Override
- public String getId() {
- return this.id;
- }
-
- @Override
- public void setId(String id) {
- this.id = id;
-
- }
-
- @Override
- public UIComponent getParent() {
- return this.parent;
- }
-
- @Override
- public void setParent(UIComponent parent) {
- this.parent = parent;
- }
-
- @Override
- public boolean isRendered() {
- return true;
- }
-
- @Override
- public void setRendered(boolean rendered) {
- // always rendered
- }
-
- @Override
- public String getRendererType() {
- return ValidatorScriptRenderer.RENDERER_TYPE;
- }
-
- @Override
- public void setRendererType(String rendererType) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public boolean getRendersChildren() {
- return false;
- }
-
- @Override
- public List<UIComponent> getChildren() {
- return Collections.emptyList();
- }
-
- @Override
- public int getChildCount() {
- return 0;
- }
-
- @Override
- public UIComponent findComponent(String expr) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Map<String, UIComponent> getFacets() {
- return Collections.emptyMap();
- }
-
- @Override
- public UIComponent getFacet(String name) {
- return null;
- }
-
- @Override
- public Iterator<UIComponent> getFacetsAndChildren() {
- return Iterators.emptyIterator();
- }
-
- @Override
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- // Do nothing
- }
-
- @Override
- public void decode(FacesContext context) {
- // Do nothing
- }
-
- @Override
- public void encodeBegin(FacesContext context) throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void encodeChildren(FacesContext context) throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void encodeEnd(FacesContext context) throws IOException {
- Renderer renderer = getRenderer(context);
- if(null != renderer){
- renderer.encodeEnd(context, this);
- }
- }
-
- @Override
- protected void addFacesListener(FacesListener listener) {
- }
-
- @Override
- protected FacesListener[] getFacesListeners(Class clazz) {
- return new FacesListener[0];
- }
-
- @Override
- protected void removeFacesListener(FacesListener listener) {
- }
-
- @Override
- public void queueEvent(FacesEvent event) {
- if (null != getParent()) {
- getParent().queueEvent(event);
- }
-
- }
-
- @Override
- public void processRestoreState(FacesContext context, Object state) {
- // Do nothing, this component does not have state.
-
- }
-
- @Override
- public void processDecodes(FacesContext context) {
- // Do nothing
-
- }
-
- @Override
- public void processValidators(FacesContext context) {
- // Do nothing
-
- }
-
- @Override
- public void processUpdates(FacesContext context) {
- // Do nothing
- }
-
- @Override
- public Object processSaveState(FacesContext context) {
- // Should never be used
- return null;
- }
-
- @Override
- protected FacesContext getFacesContext() {
- return FacesContext.getCurrentInstance();
- }
-
- @Override
- protected Renderer getRenderer(FacesContext context) {
- String rendererType = getRendererType();
- Renderer result = null;
- if (rendererType != null) {
- result = context.getRenderKit().getRenderer(getFamily(), rendererType);
- }
- return result;
- }
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/BeanValidator.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/BeanValidator.java 2010-11-30 00:05:46 UTC (rev 20219)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/BeanValidator.java 2010-11-30 00:36:07 UTC (rev 20220)
@@ -36,7 +36,9 @@
@Override
protected Collection<String> validate(FacesContext facesContext, Object base, String property, Object value,
Set<String> profiles) {
+ @SuppressWarnings("rawtypes")
Class beanType = base.getClass();
+ @SuppressWarnings("unchecked")
Set<ConstraintViolation<Object>> constrains =
getValidator(facesContext).validateValue(beanType, property, value, getGroups(profiles));
return extractMessages(constrains);
14 years, 3 months
JBoss Rich Faces SVN: r20219 - in branches/RF-8742-1: ui/validator/ui/src/main/java/org/richfaces/renderkit/html and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-29 19:05:46 -0500 (Mon, 29 Nov 2010)
New Revision: 20219
Modified:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
Log:
RESOLVED - issue RF-9565: Optimize JavaScript utils
https://jira.jboss.org/browse/RF-9565
Modified: branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java
===================================================================
--- branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java 2010-11-29 23:32:20 UTC (rev 20218)
+++ branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSLiteral.java 2010-11-30 00:05:46 UTC (rev 20219)
@@ -31,19 +31,17 @@
* @author Andrey Markavtsov
*
*/
+@SuppressWarnings("serial")
public class JSLiteral extends ScriptStringBase implements Serializable{
- public static final JSLiteral EMPTY_HASH = new ImmutableJSLiteral("{}");
- public static final JSLiteral EMPTY_LIST = new ImmutableJSLiteral("[]");
+
+ public static final JSLiteral EMPTY_HASH = new JSLiteral("{}");
+
+ public static final JSLiteral EMPTY_LIST = new JSLiteral("[]");
+
/** Javascript literal text */
- private String literal;
+ private final String literal;
- /**
- * Default constructor
- */
- public JSLiteral() {
- super();
- }
/**
* Constructor using literal parameter
@@ -65,21 +63,5 @@
return literal;
}
- /**
- * @param literal the literal to set
- */
- public void setLiteral(String literal) {
- this.literal = literal;
- }
- private static final class ImmutableJSLiteral extends JSLiteral {
- public ImmutableJSLiteral(String literal) {
- super(literal);
- }
-
- @Override
- public void setLiteral(String literal) {
- throw new UnsupportedOperationException();
- }
- }
}
Modified: branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java
===================================================================
--- branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java 2010-11-29 23:32:20 UTC (rev 20218)
+++ branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/JSReference.java 2010-11-30 00:05:46 UTC (rev 20219)
@@ -37,16 +37,16 @@
public static final JSReference TRUE = new JSReference("true");
public static final JSReference NULL = new JSReference("null");
public static final JSReference FALSE = new JSReference("false");
- private Object index = null;
- private String name;
+
+ private final Object index;
+ private final String name;
/**
* @param name
*/
public JSReference(String name) {
-
- // TODO Auto-generated constructor stub
this.name = name;
+ this.index = null;
}
/**
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-29 23:32:20 UTC (rev 20218)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-30 00:05:46 UTC (rev 20219)
@@ -18,7 +18,7 @@
import javax.faces.event.PhaseId;
import javax.faces.render.ClientBehaviorRenderer;
-import org.ajax4jsf.javascript.JSLiteral;
+import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.application.ServiceTracker;
import org.richfaces.component.UIValidatorScript;
@@ -46,9 +46,9 @@
public static final String CONVERTED_VALUE_VAR = "convertedValue";
- public static final JSLiteral VALUE_LITERAL = new JSLiteral("value");
+ public static final JSReference VALUE_LITERAL = new JSReference("value");
- public static final JSLiteral CONVERTED_VALUE_LITERAL = new JSLiteral("convertedValue");
+ public static final JSReference CONVERTED_VALUE_LITERAL = new JSReference("convertedValue");
public ClientValidatorRenderer() {
super();
@@ -278,7 +278,7 @@
}
private LibraryScriptString createClientFunction(FacesContext facesContext, FacesObjectDescriptor descriptor,
- JSLiteral variable, ClientScriptService clientScriptService) throws ScriptNotFoundException {
+ JSReference variable, ClientScriptService clientScriptService) throws ScriptNotFoundException {
LibraryFunction script = clientScriptService.getScript(facesContext, descriptor.getImplementationClass());
return new LibraryScriptFunction(script, variable, descriptor.getMessage(), descriptor.getAdditionalParameters());
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2010-11-29 23:32:20 UTC (rev 20218)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2010-11-30 00:05:46 UTC (rev 20219)
@@ -4,25 +4,24 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.JSLiteral;
+import org.ajax4jsf.javascript.JSReference;
public abstract class ValidatorScriptBase extends JSFunctionDefinition implements ComponentValidatorScript {
protected static final String ELEMENT = "element";
protected static final String EVENT = "event";
- protected static final JSLiteral EVENT_LITERAL = new JSLiteral(EVENT);
- protected static final JSLiteral THIS = new JSLiteral("this");
+ protected static final JSReference EVENT_LITERAL = new JSReference(EVENT);
protected static final String DISABLE_AJAX = "disableAjax";
protected static final String EOL = "\n;";
protected static final String CLIENT_ID = "clientId";
- protected static final JSLiteral CLIENT_ID_LITERAL = new JSLiteral(CLIENT_ID);
+ protected static final JSReference CLIENT_ID_LITERAL = new JSReference(CLIENT_ID);
protected static final String SOURCE_ID = "sourceId";
- protected static final JSLiteral SOURCE_ID_LITERAL = new JSLiteral(SOURCE_ID);
+ protected static final JSReference SOURCE_ID_LITERAL = new JSReference(SOURCE_ID);
protected static final NullConverterScript NULL_CONVERTER_SCRIPT = new NullConverterScript();
protected static final String CSV_NAMESPACE = "RichFaces.csv.";
protected static final String VALUE_FUNCTION_NAME = CSV_NAMESPACE+"getValue";
protected static final JSFunction GET_VALUE_FUNCTION = new JSFunction(VALUE_FUNCTION_NAME,CLIENT_ID_LITERAL);
- protected static final JSFunction SEND_ERROR_FUNCTION = new JSFunction(CSV_NAMESPACE+"sendMessage",CLIENT_ID_LITERAL,new JSLiteral("e"));
+ protected static final JSFunction SEND_ERROR_FUNCTION = new JSFunction(CSV_NAMESPACE+"sendMessage",CLIENT_ID_LITERAL,new JSReference("e"));
protected static final JSFunction CLEAR_ERROR_FUNCTION = new JSFunction(CSV_NAMESPACE+"clearMessage",CLIENT_ID_LITERAL);
private boolean bodyProcessed = false;
@@ -43,7 +42,7 @@
protected abstract Object buildBody();
public String createCallScript(String clientId,String sourceId) {
- JSFunction callFunction = new JSFunction(getName(),clientId,null!=sourceId?sourceId:THIS,EVENT_LITERAL);
+ JSFunction callFunction = new JSFunction(getName(),clientId,null!=sourceId?sourceId:JSReference.THIS,EVENT_LITERAL);
return callFunction.toScript();
}
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-29 23:32:20 UTC (rev 20218)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-30 00:05:46 UTC (rev 20219)
@@ -16,7 +16,7 @@
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
-import org.ajax4jsf.javascript.JSLiteral;
+import org.ajax4jsf.javascript.JSReference;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
@@ -220,7 +220,7 @@
return CLIENT_VALIDATOR_LIBRARY;
}
};
- return new LibraryScriptFunction(libraryScript, new JSLiteral(var), validatorMessage, VALIDATOR_PARAMS);
+ return new LibraryScriptFunction(libraryScript, new JSReference(var), validatorMessage, VALIDATOR_PARAMS);
}
private ClientValidatorRenderer createStubRenderer(final LibraryScriptFunction converterFunction,
14 years, 3 months
JBoss Rich Faces SVN: r20218 - in branches/RF-8742-1: core/impl/src/main/java/org/richfaces/renderkit/html and 10 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-29 18:32:20 -0500 (Mon, 29 Nov 2010)
New Revision: 20218
Removed:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java
Modified:
branches/RF-8742-1/core/api/src/main/java/org/richfaces/resource/ResourceLibrary.java
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/html/ResourceLibraryRenderer.java
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/resource/StaticResourceLibrary.java
branches/RF-8742-1/core/impl/src/test/java/org/richfaces/resource/DynamicResourceLibrary.java
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
Log:
CODING IN PROGRESS - issue RF-9799: CSV code review
https://jira.jboss.org/browse/RF-9799
Modified: branches/RF-8742-1/core/api/src/main/java/org/richfaces/resource/ResourceLibrary.java
===================================================================
--- branches/RF-8742-1/core/api/src/main/java/org/richfaces/resource/ResourceLibrary.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/core/api/src/main/java/org/richfaces/resource/ResourceLibrary.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -21,7 +21,6 @@
*/
package org.richfaces.resource;
-import javax.faces.context.FacesContext;
/**
* @author Nick Belaevski
@@ -29,6 +28,6 @@
*/
public interface ResourceLibrary {
- public Iterable<ResourceKey> getResources(FacesContext context);
+ public Iterable<ResourceKey> getResources();
}
Modified: branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/html/ResourceLibraryRenderer.java
===================================================================
--- branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/html/ResourceLibraryRenderer.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/core/impl/src/main/java/org/richfaces/renderkit/html/ResourceLibraryRenderer.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -95,7 +95,7 @@
Application application = context.getApplication();
UIComponent resourceComponent = null;
- for (ResourceKey resourceKey: resourceLibrary.getResources(context)) {
+ for (ResourceKey resourceKey: resourceLibrary.getResources()) {
String rendererType = application.getResourceHandler().getRendererTypeForResourceName(resourceKey.getResourceName());
if (resourceComponent == null) {
Modified: branches/RF-8742-1/core/impl/src/main/java/org/richfaces/resource/StaticResourceLibrary.java
===================================================================
--- branches/RF-8742-1/core/impl/src/main/java/org/richfaces/resource/StaticResourceLibrary.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/core/impl/src/main/java/org/richfaces/resource/StaticResourceLibrary.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -21,7 +21,6 @@
*/
package org.richfaces.resource;
-import javax.faces.context.FacesContext;
import com.google.common.collect.ImmutableList;
@@ -38,7 +37,7 @@
this.keys = ImmutableList.copyOf(keys);
}
- public Iterable<ResourceKey> getResources(FacesContext context) {
+ public Iterable<ResourceKey> getResources() {
return keys;
}
Modified: branches/RF-8742-1/core/impl/src/test/java/org/richfaces/resource/DynamicResourceLibrary.java
===================================================================
--- branches/RF-8742-1/core/impl/src/test/java/org/richfaces/resource/DynamicResourceLibrary.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/core/impl/src/test/java/org/richfaces/resource/DynamicResourceLibrary.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -21,7 +21,6 @@
*/
package org.richfaces.resource;
-import javax.faces.context.FacesContext;
import com.google.common.collect.ImmutableList;
@@ -33,7 +32,7 @@
private ImmutableList<ResourceKey> keys = ImmutableList.of(ResourceKey.create("skinning_classes.ecss"), ResourceKey.create("jquery.js", null));
- public Iterable<ResourceKey> getResources(FacesContext context) {
+ public Iterable<ResourceKey> getResources() {
return keys;
}
Modified: branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java
===================================================================
--- branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -25,6 +25,7 @@
import javax.faces.context.FacesContext;
+
import org.richfaces.application.CommonComponentsConfiguration;
import com.google.common.collect.ImmutableList;
@@ -42,8 +43,9 @@
private static final ImmutableList<ResourceKey> AJAX_WITH_QUEUE_KEYS = ImmutableList.<ResourceKey>builder().addAll(AJAX_ONLY_KEYS).add(ResourceKey.create("richfaces-queue.js", null)).build();
- public Iterable<ResourceKey> getResources(FacesContext context) {
- if (getBooleanConfigurationValue(context, CommonComponentsConfiguration.Items.queueEnabled)) {
+ public Iterable<ResourceKey> getResources() {
+ // TODO - initialize at creation.
+ if (getBooleanConfigurationValue(FacesContext.getCurrentInstance(), CommonComponentsConfiguration.Items.queueEnabled)) {
return AJAX_WITH_QUEUE_KEYS;
}
Modified: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -23,6 +23,8 @@
package org.richfaces.javascript;
+import org.richfaces.resource.ResourceLibrary;
+
/**
* <p class="changed_added_4_0">
* This class contains information about JavaScript function in external library ( resource )
@@ -31,9 +33,13 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface LibraryFunction extends LibraryScript {
+public interface LibraryFunction extends ResourceLibrary {
+ /**
+ * <p class="changed_added_4_0">JavaScript function name in resource library</p>
+ * @return
+ */
String getName();
}
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -1,40 +0,0 @@
-/*
- * $Id$
- * 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.javascript;
-
-import org.richfaces.resource.ResourceKey;
-
-/**
- * <p class="changed_added_4_0">
- * This class contains information about JavaScript associated with JSF object ( converter or validator )
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public interface LibraryScript {
-
- ResourceKey getResource();
-
-}
Modified: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -1,13 +1,14 @@
package org.richfaces.javascript;
import org.ajax4jsf.javascript.ScriptString;
+import org.richfaces.resource.ResourceLibrary;
/**
- * This interface describes JavaScript object with possible dependent resource.
+ * This interface describes JavaScript object with optional dependent resources.
* @author asmirnov
*
*/
-public interface LibraryScriptString extends LibraryScript, ScriptString {
+public interface LibraryScriptString extends ResourceLibrary, ScriptString {
}
\ No newline at end of file
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -1,23 +1,25 @@
package org.richfaces.javascript;
+import java.util.Collections;
+
import org.richfaces.resource.ResourceKey;
final class LibraryFunctionImplementation implements LibraryFunction {
- private final ResourceKey library;
+ private final Iterable<ResourceKey> library;
private final String functionName;
LibraryFunctionImplementation(String functionName, ResourceKey library) {
- this.library = library;
+ this.library = Collections.singleton(library);
this.functionName = functionName;
}
LibraryFunctionImplementation(String functionName, String resource, String library) {
- this.library = ResourceKey.create(resource,library);
+ this.library = Collections.singleton(ResourceKey.create(resource,library));
this.functionName = functionName;
}
- public ResourceKey getResource() {
+ public Iterable<ResourceKey> getResources() {
return library;
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -2,6 +2,8 @@
import java.util.Collections;
+import javax.faces.context.FacesContext;
+
import org.richfaces.resource.ResourceKey;
public class AjaxOnlyScript extends ValidatorScriptBase {
@@ -15,7 +17,7 @@
}
- public Iterable<ResourceKey> getResources() {
+ public Iterable<ResourceKey> getResources(FacesContext context) {
return Collections.emptySet();
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -3,9 +3,12 @@
import java.util.Collection;
import java.util.LinkedHashSet;
+import javax.faces.context.FacesContext;
+
import org.richfaces.javascript.LibraryScriptString;
import org.richfaces.resource.ResourceKey;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
public class ClientOnlyScript extends ValidatorScriptBase{
@@ -25,12 +28,12 @@
}
- public Iterable<ResourceKey> getResources() {
+ public Iterable<ResourceKey> getResources(FacesContext context) {
// TODO - make immutable.
LinkedHashSet<ResourceKey> resources = Sets.newLinkedHashSet();
- resources.add(converter.getResource());
+ Iterables.addAll(resources,converter.getResources());
for (LibraryScriptString scriptString : validators) {
- resources.add(scriptString.getResource());
+ Iterables.addAll(resources,scriptString.getResources());
}
return resources;
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -1,5 +1,7 @@
package org.richfaces.renderkit.html;
+import javax.faces.context.FacesContext;
+
import org.ajax4jsf.javascript.ScriptString;
import org.richfaces.resource.ResourceKey;
@@ -7,7 +9,7 @@
String getName();
- Iterable<ResourceKey> getResources();
+ Iterable<ResourceKey> getResources(FacesContext context);
/**
* <p class="changed_added_4_0">Creates JavasCript that calls validator function.</p>
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -38,12 +38,12 @@
*/
public class LibraryScriptFunction extends JSFunction implements LibraryScriptString {
- private final ResourceKey resource;
+ private final Iterable<ResourceKey> resources;
private final String name;
public LibraryScriptFunction(LibraryFunction libraryScript, Object... parameters) {
super(libraryScript.getName(), parameters);
- this.resource = libraryScript.getResource();
+ this.resources = libraryScript.getResources();
this.name = libraryScript.getName();
}
@@ -56,8 +56,8 @@
*
* @see org.richfaces.renderkit.html.LibraryScriptString#getResource()
*/
- public ResourceKey getResource() {
- return resource;
+ public Iterable<ResourceKey> getResources() {
+ return resources;
}
/*
@@ -70,7 +70,7 @@
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((resource == null) ? 0 : resource.hashCode());
+ result = prime * result + ((resources == null) ? 0 : resources.hashCode());
result = prime * result + getParameters().hashCode();
return result;
}
@@ -99,11 +99,11 @@
} else if (!name.equals(other.name)) {
return false;
}
- if (resource == null) {
- if (other.resource != null) {
+ if (resources == null) {
+ if (other.resources != null) {
return false;
}
- } else if (!resource.equals(other.resource)) {
+ } else if (!resources.equals(other.resources)) {
return false;
} else if (!getParameters().equals(other.getParameters())) {
return false;
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -3,6 +3,8 @@
*/
package org.richfaces.renderkit.html;
+import java.util.Collections;
+
import org.ajax4jsf.javascript.JSLiteral;
import org.richfaces.javascript.LibraryScriptString;
import org.richfaces.resource.ResourceKey;
@@ -30,8 +32,8 @@
*
* @see org.richfaces.renderkit.html.LibraryScriptString#getResource()
*/
- public ResourceKey getResource() {
- return null;
+ public Iterable<ResourceKey> getResources() {
+ return Collections.emptySet();
}
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -41,7 +41,7 @@
// flatten all dependent resources.
LinkedHashSet<ResourceKey> resources = Sets.newLinkedHashSet();
for (ComponentValidatorScript script : scripts) {
- Iterables.addAll(resources, script.getResources());
+ Iterables.addAll(resources, script.getResources(context));
}
// render dependencies
for (ResourceKey resource : resources) {
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -49,7 +49,7 @@
}
}
- public Collection<ResourceKey> getResources() {
+ public Collection<ResourceKey> getResources(FacesContext context) {
return Collections.singleton(TEST_RESOURCE);
}
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -1,10 +1,14 @@
package org.richfaces.component;
import java.io.IOException;
+import java.util.Collections;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.javascript.LibraryScriptString;
import org.richfaces.resource.ResourceKey;
-final class Script implements org.richfaces.javascript.LibraryScriptString {
+final class Script implements LibraryScriptString {
private final String name;
Script(String name) {
@@ -27,8 +31,8 @@
}
}
- public ResourceKey getResource() {
- return UIValidatorScriptCollectionTest.FOO_RESOURCE;
+ public Iterable<ResourceKey> getResources() {
+ return Collections.singleton(UIValidatorScriptCollectionTest.FOO_RESOURCE);
}
/* (non-Javadoc)
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/el/ValueExpressionAnalayserTest.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -34,6 +34,7 @@
@After
public void tearDownAnalayser() throws Exception {
analayser = null;
+ facesContext.release();
}
@Test
public void testGetDescriptionPositive() throws Exception {
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -11,6 +11,7 @@
import javax.faces.application.Resource;
import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
import javax.validation.constraints.Max;
import org.jboss.test.faces.mock.Environment;
@@ -26,9 +27,11 @@
import org.richfaces.javascript.ClientScriptServiceImpl;
import org.richfaces.javascript.LibraryFunction;
import org.richfaces.javascript.ScriptNotFoundException;
+import org.richfaces.resource.ResourceKey;
import org.richfaces.validator.ValidatorWithFacesResource;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
/**
* @author asmirnov
@@ -88,16 +91,20 @@
@Test
public void testGetScriptAsJsfResource() throws Exception {
LibraryFunction script = getScript(resource, ValidatorWithFacesResource.class);
- assertEquals(RESOURCE_NAME, script.getResource().getResourceName());
- assertEquals(ORG_RICHFACES_CSV, script.getResource().getLibraryName());
+ assertEquals(RESOURCE_NAME, getOnlyResource(script).getResourceName());
+ assertEquals(ORG_RICHFACES_CSV, getOnlyResource(script).getLibraryName());
assertEquals("validatorWithFacesResource", script.getName());
}
+ private ResourceKey getOnlyResource(LibraryFunction script) {
+ return Iterables.getOnlyElement(script.getResources());
+ }
+
@Test
public void testGetScriptFromAnnotation() throws Exception {
LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
- assertEquals("baz.js", script.getResource().getResourceName());
- assertEquals("bar", script.getResource().getLibraryName());
+ assertEquals("baz.js", getOnlyResource(script).getResourceName());
+ assertEquals("bar", getOnlyResource(script).getLibraryName());
assertEquals("foo", script.getName());
}
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -11,7 +11,10 @@
import org.junit.Test;
import org.richfaces.javascript.ClientServiceConfigParser;
import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.resource.ResourceKey;
+import com.google.common.collect.Iterables;
+
public class ServiceConfigParserTest {
@Before
@@ -29,8 +32,9 @@
assertTrue(parseConfig.containsKey(String.class));
LibraryFunction libraryFunction = parseConfig.get(String.class);
assertEquals("stringConverter", libraryFunction.getName());
- assertEquals("csv.js", libraryFunction.getResource().getResourceName());
- assertEquals("org.richfaces", libraryFunction.getResource().getLibraryName());
+ ResourceKey resource = Iterables.getOnlyElement(libraryFunction.getResources());
+ assertEquals("csv.js", resource.getResourceName());
+ assertEquals("org.richfaces", resource.getLibraryName());
}
@Test(expected=FacesException.class)
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -86,14 +86,14 @@
(Map<String, Object>) VALIDATOR_PARAMS);
expect(scriptService.getScript(environment.getFacesContext(), RegexValidator.class)).andReturn(script);
expect(script.getName()).andReturn(REGEX_VALIDATOR).atLeastOnce();
- expect(script.getResource()).andReturn(CLIENT_VALIDATOR_LIBRARY);
+ expect(script.getResources()).andReturn(CLIENT_VALIDATOR_LIBRARY);
controller.replay();
Collection<? extends LibraryScriptString> clientSideScripts = renderer.getClientSideValidatorScript(environment.getFacesContext(), descriptors);
LibraryScriptFunction clientSideScript = (LibraryScriptFunction) Iterables.getOnlyElement(clientSideScripts);
assertEquals(ClientValidatorRenderer.CONVERTED_VALUE_LITERAL, clientSideScript.getParameters().get(0));
assertEquals(VALIDATOR_MESSAGE, clientSideScript.getParameters().get(1));
assertEquals(VALIDATOR_PARAMS, clientSideScript.getParameters().get(2));
- assertEquals(CLIENT_VALIDATOR_LIBRARY, clientSideScript.getResource());
+ assertEquals(CLIENT_VALIDATOR_LIBRARY, clientSideScript.getResources());
controller.verify();
}
@@ -105,14 +105,14 @@
(Map<String, Object>) VALIDATOR_PARAMS);
expect(scriptService.getScript(environment.getFacesContext(), NumberConverter.class)).andReturn(script);
expect(script.getName()).andReturn(REGEX_VALIDATOR).atLeastOnce();
- expect(script.getResource()).andReturn(CLIENT_VALIDATOR_LIBRARY);
+ expect(script.getResources()).andReturn(CLIENT_VALIDATOR_LIBRARY);
controller.replay();
LibraryScriptFunction clientSideScript =
(LibraryScriptFunction) renderer.getClientSideConverterScript(environment.getFacesContext(), converterDescriptor);
assertEquals(ClientValidatorRenderer.VALUE_LITERAL, clientSideScript.getParameters().get(0));
assertEquals(VALIDATOR_MESSAGE, clientSideScript.getParameters().get(1));
assertEquals(VALIDATOR_PARAMS, clientSideScript.getParameters().get(2));
- assertEquals(CLIENT_VALIDATOR_LIBRARY, clientSideScript.getResource());
+ assertEquals(CLIENT_VALIDATOR_LIBRARY, clientSideScript.getResources());
controller.verify();
}
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -139,7 +139,7 @@
// check what generated script contains ajax and client side scripts.
assertThat(script,
allOf(containsString(JSF_AJAX_REQUEST), containsString(REGEX_VALIDATOR), containsString(NUMBER_CONVERTER)));
- assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
+ assertThat(validatorScript.getResources(environment.getFacesContext()), hasItem(CORE_LIBRARY_MATCHER));
}
/**
@@ -175,7 +175,7 @@
script,
allOf(not(containsString(JSF_AJAX_REQUEST)), containsString(REGEX_VALIDATOR),
not(containsString(NUMBER_CONVERTER))));
- assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
+ assertThat(validatorScript.getResources(environment.getFacesContext()), hasItem(CORE_LIBRARY_MATCHER));
}
/**
@@ -196,7 +196,7 @@
script,
allOf(not(containsString(JSF_AJAX_REQUEST)), containsString(REGEX_VALIDATOR),
containsString(NUMBER_CONVERTER)));
- assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
+ assertThat(validatorScript.getResources(environment.getFacesContext()), hasItem(CORE_LIBRARY_MATCHER));
}
private LibraryScriptFunction createValidatorFunction() {
@@ -216,7 +216,7 @@
return name;
}
- public ResourceKey getResource() {
+ public Iterable<ResourceKey> getResources() {
return CLIENT_VALIDATOR_LIBRARY;
}
};
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-11-29 20:58:34 UTC (rev 20217)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-11-29 23:32:20 UTC (rev 20218)
@@ -1,5 +1,6 @@
package org.richfaces.renderkit.html;
+import java.util.Collections;
import java.util.Map;
import javax.faces.application.FacesMessage;
@@ -18,7 +19,7 @@
protected static final String REGEX_VALIDATOR = "regexValidator";
protected static final FacesMessage VALIDATOR_MESSAGE = new FacesMessage("Validator Message");
protected static final Map<String, ? extends Object> VALIDATOR_PARAMS = ImmutableMap.of("foo", "value", "bar", 10);
- protected static final ResourceKey CLIENT_VALIDATOR_LIBRARY = ResourceKey.create(CLIENT_VALIDATORS_JS,ORG_RICHFACES);
+ protected static final Iterable<ResourceKey> CLIENT_VALIDATOR_LIBRARY = Collections.singleton(ResourceKey.create(CLIENT_VALIDATORS_JS,ORG_RICHFACES));
protected ClientValidatorRenderer renderer = new ClientValidatorRenderer();
14 years, 3 months
JBoss Rich Faces SVN: r20217 - in trunk: ui/common/ui/src/main/java/org/richfaces/component and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-29 15:58:34 -0500 (Mon, 29 Nov 2010)
New Revision: 20217
Added:
trunk/ui/iteration/api/src/main/java/org/richfaces/model/DeclarativeTreeDataModelTuple.java
trunk/ui/iteration/api/src/main/java/org/richfaces/model/DeclarativeTreeModel.java
Modified:
trunk/examples/iteration-demo/src/main/webapp/treeModel.xhtml
trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModelTuple.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
Log:
https://jira.jboss.org/browse/RF-9680
Modified: trunk/examples/iteration-demo/src/main/webapp/treeModel.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/treeModel.xhtml 2010-11-29 20:52:25 UTC (rev 20216)
+++ trunk/examples/iteration-demo/src/main/webapp/treeModel.xhtml 2010-11-29 20:58:34 UTC (rev 20217)
@@ -59,7 +59,7 @@
</it:tree>
</h:form>
- <h:panelGroup style="position: absolute; bottom: 20px; left: 20px; right: 20px;">
+ <h:panelGroup style="margin-top: 20px;">
<hr />
This demo uses icons taken from <a href="http://www.famfamfam.com/lab/icons/silk/">http://www.famfamfam.com/lab/icons/silk/</a>
</h:panelGroup>
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-11-29 20:52:25 UTC (rev 20216)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-11-29 20:58:34 UTC (rev 20217)
@@ -246,10 +246,6 @@
private Object rowKey = null;
- private boolean rowDataIsSet = false;
-
- private Object rowData;
-
private String clientId;
private Object originalVarValue;
@@ -371,20 +367,22 @@
return rowKey;
}
- private void setRowKeyAndData(FacesContext facesContext, Object rowKey, boolean localRowDataAvailable, Object localRowData) {
+ /**
+ * Setup current row by key. Perform same functionality as
+ * {@link javax.faces.component.UIData#setRowIndex(int)}, but for key object - it may be not only
+ * row number in sequence data, but, for example - path to current node in
+ * tree.
+ *
+ * @param faces -
+ * current FacesContext
+ * @param key new key value.
+ */
+ public void setRowKey(FacesContext facesContext, Object rowKey) {
this.saveChildState(facesContext);
this.rowKey = rowKey;
- if (localRowDataAvailable) {
- this.rowData = localRowData;
- this.rowDataIsSet = (rowKey != null);
- } else {
- this.rowData = null;
- this.rowDataIsSet = false;
-
- getExtendedDataModel().setRowKey(rowKey);
- }
+ getExtendedDataModel().setRowKey(rowKey);
this.clientId = null;
@@ -394,24 +392,6 @@
this.restoreChildState(facesContext);
}
-
- protected void setRowKeyAndData(FacesContext facesContext, Object rowKey, Object localRowData) {
- setRowKeyAndData(facesContext, rowKey, true, localRowData);
- }
-
- /**
- * Setup current row by key. Perform same functionality as
- * {@link javax.faces.component.UIData#setRowIndex(int)}, but for key object - it may be not only
- * row number in sequence data, but, for example - path to current node in
- * tree.
- *
- * @param faces -
- * current FacesContext
- * @param key new key value.
- */
- public void setRowKey(FacesContext facesContext, Object rowKey) {
- setRowKeyAndData(facesContext, rowKey, false, null);
- }
/**
* Save values of {@link EditableValueHolder} fields before change current
@@ -635,15 +615,11 @@
}
public Object getRowData() {
- if (rowDataIsSet) {
- return rowData;
- }
-
return getExtendedDataModel().getRowData();
}
public boolean isRowAvailable() {
- return rowDataIsSet || getExtendedDataModel().isRowAvailable();
+ return getExtendedDataModel().isRowAvailable();
}
/**
Copied: trunk/ui/iteration/api/src/main/java/org/richfaces/model/DeclarativeTreeDataModelTuple.java (from rev 20216, trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModelTuple.java)
===================================================================
--- trunk/ui/iteration/api/src/main/java/org/richfaces/model/DeclarativeTreeDataModelTuple.java (rev 0)
+++ trunk/ui/iteration/api/src/main/java/org/richfaces/model/DeclarativeTreeDataModelTuple.java 2010-11-29 20:58:34 UTC (rev 20217)
@@ -0,0 +1,50 @@
+/*
+ * 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.model;
+
+import javax.faces.component.UIComponent;
+
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class DeclarativeTreeDataModelTuple extends TreeDataModelTuple {
+
+ private UIComponent component;
+
+ public DeclarativeTreeDataModelTuple(Object rowKey, Object data, UIComponent component) {
+ super(rowKey, data);
+ this.component = component;
+ }
+
+ public UIComponent getComponent() {
+ return component;
+ }
+
+ @Override
+ protected ToStringHelper createToStringHelper() {
+ return super.createToStringHelper().add("component", component);
+ }
+
+}
Copied: trunk/ui/iteration/api/src/main/java/org/richfaces/model/DeclarativeTreeModel.java (from rev 20216, trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java)
===================================================================
--- trunk/ui/iteration/api/src/main/java/org/richfaces/model/DeclarativeTreeModel.java (rev 0)
+++ trunk/ui/iteration/api/src/main/java/org/richfaces/model/DeclarativeTreeModel.java 2010-11-29 20:58:34 UTC (rev 20217)
@@ -0,0 +1,34 @@
+/*
+ * 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.model;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface DeclarativeTreeModel<E> extends TreeDataModel<E> {
+
+ public UIComponent getCurrentComponent();
+
+}
Modified: trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
===================================================================
--- trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java 2010-11-29 20:52:25 UTC (rev 20216)
+++ trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java 2010-11-29 20:58:34 UTC (rev 20217)
@@ -48,5 +48,9 @@
public Object getWrappedData();
public void setWrappedData(Object data);
+
+ public TreeDataModelTuple createSnapshot();
+
+ public void restoreFromSnapshot(TreeDataModelTuple tuple);
}
Modified: trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModelTuple.java
===================================================================
--- trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModelTuple.java 2010-11-29 20:52:25 UTC (rev 20216)
+++ trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModelTuple.java 2010-11-29 20:58:34 UTC (rev 20217)
@@ -47,13 +47,17 @@
public Object getData() {
return data;
}
-
- @Override
- public String toString() {
+
+ protected ToStringHelper createToStringHelper() {
ToStringHelper helper = Objects.toStringHelper(this);
helper.add("rowKey", rowKey);
helper.add("data", data);
-
- return helper.toString();
+
+ return helper;
}
+
+ @Override
+ public String toString() {
+ return createToStringHelper().toString();
+ }
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-29 20:52:25 UTC (rev 20216)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-29 20:58:34 UTC (rev 20217)
@@ -236,21 +236,13 @@
return converter;
}
- protected AbstractTreeNode findTreeNodeComponent(String nodeType, UIComponent parentComponent) {
- Iterator<UIComponent> matchingNodes = Iterators.filter(parentComponent.getChildren().iterator(),
- new MatchingTreeNodePredicate(nodeType));
-
- boolean hasNodes = matchingNodes.hasNext();
- if (hasNodes) {
- Iterator<UIComponent> renderedTreeNodes = Iterators.filter(matchingNodes, ComponentPredicates.isRendered());
- if (renderedTreeNodes.hasNext()) {
- return (AbstractTreeNode) renderedTreeNodes.next();
- } else {
- return null;
- }
+ protected Iterator<UIComponent> findMatchingTreeNodeComponent(String nodeType, UIComponent parentComponent) {
+ Iterator<UIComponent> children = parentComponent.getChildren().iterator();
+ if (parentComponent != this) {
+ children = Iterators.concat(children, this.getChildren().iterator());
}
- return null;
+ return Iterators.filter(children, new MatchingTreeNodePredicate(nodeType));
}
protected UIComponent getCurrentComponent() {
@@ -262,27 +254,22 @@
return this;
}
- @Override
- public void setRowKeyAndData(FacesContext facesContext, Object rowKey, Object localRowData) {
- super.setRowKeyAndData(facesContext, rowKey, localRowData);
- }
-
public AbstractTreeNode findTreeNodeComponent() {
FacesContext facesContext = getFacesContext();
String nodeType = getNodeType();
- UIComponent component = getCurrentComponent();
+ Iterator<UIComponent> nodesItr = findMatchingTreeNodeComponent(nodeType, getCurrentComponent());
- AbstractTreeNode treeNodeComponent = findTreeNodeComponent(nodeType, component);
- if (treeNodeComponent == null && component != this) {
- treeNodeComponent = findTreeNodeComponent(nodeType, this);
+ if (nodesItr.hasNext()) {
+ Iterator<UIComponent> renderedNodesItr = Iterators.filter(nodesItr, ComponentPredicates.isRendered());
+ if (renderedNodesItr.hasNext()) {
+ return (AbstractTreeNode) renderedNodesItr.next();
+ }
+
+ return null;
}
- if (treeNodeComponent != null) {
- return treeNodeComponent;
- }
-
if (Strings.isNullOrEmpty(nodeType)) {
if (getAttributes().put(DEFAULT_TREE_NODE_CREATED, Boolean.TRUE) != null) {
return null;
@@ -497,13 +484,9 @@
}
public void beforeChildrenVisit() {
- // TODO Auto-generated method stub
-
}
public void afterChildrenVisit() {
- // TODO Auto-generated method stub
-
}
});
@@ -555,7 +538,7 @@
while (childrenTuples.hasNext()) {
TreeDataModelTuple tuple = childrenTuples.next();
- setRowKeyAndData(context, tuple.getRowKey(), tuple.getData());
+ restoreFromSnapshot(context, tuple);
if (!getTreeRange().shouldProcessNode()) {
continue;
@@ -576,4 +559,14 @@
super.resetDataModel();
treeRange = null;
}
+
+ public TreeDataModelTuple createSnapshot() {
+ return getTreeDataModel().createSnapshot();
+ }
+
+ public void restoreFromSnapshot(FacesContext context, TreeDataModelTuple tuple) {
+ getTreeDataModel().restoreFromSnapshot(tuple);
+ setRowKey(context, tuple.getRowKey());
+ }
+
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java 2010-11-29 20:52:25 UTC (rev 20216)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java 2010-11-29 20:58:34 UTC (rev 20217)
@@ -45,7 +45,7 @@
* @author Nick Belaevski
*
*/
-public class DeclarativeTreeDataModelImpl extends TreeSequenceKeyModel<DeclarativeModelKey, Object> implements DeclarativeTreeModel {
+public class DeclarativeTreeDataModelImpl extends TreeSequenceKeyModel<DeclarativeModelKey, Object> implements DeclarativeTreeModel<Object> {
private static final Logger LOGGER = RichfacesLogger.MODEL.getLogger();
@@ -71,9 +71,8 @@
DeclarativeModelKey key = new DeclarativeModelKey(component.getId(), counter++);
SequenceRowKey<DeclarativeModelKey> newKey = baseKey.append(key);
- setCurrentState(newKey, nextNode, component);
- return new TreeDataModelTuple(newKey, nextNode);
+ return new DeclarativeTreeDataModelTuple(newKey, nextNode, component);
}
public boolean hasNext() {
@@ -163,8 +162,7 @@
return currentComponent;
}
- protected void setCurrentState(SequenceRowKey<DeclarativeModelKey> key, Object data, UIComponent currentComponent) {
- setRowKeyAndData(key, data);
+ protected void setCurrentComponent(UIComponent currentComponent) {
this.currentComponent = currentComponent;
}
@@ -180,9 +178,6 @@
return Iterables.contains(currentComponent.getChildren(), Predicates.instanceOf(TreeModelAdaptor.class));
}
- /* (non-Javadoc)
- * @see org.richfaces.model.TreeDataModel#children()
- */
public Iterator<TreeDataModelTuple> children() {
return new DeclarativeModelCompositeIterator(currentComponent, safeGetRowKey());
}
@@ -255,11 +250,23 @@
}
Object data = Iterables.get((Iterable<?>) nodes, (Integer) segment.getModelKey());
- setCurrentState(safeGetRowKey().append(segment), data, modelComponent);
-
+ setRowKeyAndData(safeGetRowKey().append(segment), data);
+ setCurrentComponent(modelComponent);
+
if (var != null) {
contextMap.put(var, data);
}
}
+
+ public TreeDataModelTuple createSnapshot() {
+ return new DeclarativeTreeDataModelTuple(getRowKey(), getData(), getCurrentComponent());
+ }
+
+ public void restoreFromSnapshot(TreeDataModelTuple tuple) {
+ DeclarativeTreeDataModelTuple declarativeModelTuple = (DeclarativeTreeDataModelTuple) tuple;
+
+ super.restoreFromSnapshot(declarativeModelTuple);
+ setCurrentComponent(declarativeModelTuple.getComponent());
+ }
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-11-29 20:52:25 UTC (rev 20216)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-11-29 20:58:34 UTC (rev 20217)
@@ -70,8 +70,6 @@
key = new SequenceRowKey<Integer>(getNextCounterValue());
}
- setRowKeyAndData(key, node);
-
return new TreeDataModelTuple(key, node);
}
@@ -190,5 +188,5 @@
//TODO - optimize - remove partial keys creation
setRowKeyAndData(safeGetRowKey().append(segment), child);
}
-
+
}
\ No newline at end of file
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java 2010-11-29 20:52:25 UTC (rev 20216)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java 2010-11-29 20:58:34 UTC (rev 20217)
@@ -138,4 +138,13 @@
public void setRowIndex(int rowIndex) {
throw new UnsupportedOperationException();
}
+
+ public TreeDataModelTuple createSnapshot() {
+ return new TreeDataModelTuple(getRowKey(), getData());
+ }
+
+ public void restoreFromSnapshot(TreeDataModelTuple tuple) {
+ setRowKeyAndData((SequenceRowKey<K>) tuple.getRowKey(), (V) tuple.getData());
+ }
+
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-29 20:52:25 UTC (rev 20216)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-29 20:58:34 UTC (rev 20217)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.util.LinkedList;
+import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -37,50 +38,41 @@
abstract class TreeEncoderBase implements TreeDataVisitor {
- /**
- * @author Nick Belaevski
- *
- */
private static final class QueuedData {
- private boolean encoded = false;
-
- private boolean visited = false;
+ private enum State {
+ initial, visited, encoded
+ }
- //TODO - should be part of tree state
- private boolean leaf;
+ private State state = State.initial;
private TreeDataModelTuple tuple;
- public QueuedData(TreeDataModelTuple tuple, boolean leaf) {
+ public QueuedData(TreeDataModelTuple tuple) {
super();
this.tuple = tuple;
- this.leaf = leaf;
}
public boolean isEncoded() {
- return encoded;
+ return state == State.encoded;
}
- public void setEncoded(boolean encoded) {
- this.encoded = encoded;
+ public void makeEncoded() {
+ this.state = State.encoded;
}
public void makeVisited() {
- this.visited = true;
+ this.state = State.visited;
}
public boolean isVisited() {
- return visited;
+ return state == State.visited;
}
public TreeDataModelTuple getTuple() {
return tuple;
}
- public boolean isLeaf() {
- return leaf;
- }
}
static final String TREE_NODE_STATE_ATTRIBUTE = "__treeNodeState";
@@ -111,10 +103,10 @@
QueuedData data = queuedDataList.getLast();
if (!data.isEncoded()) {
- data.setEncoded(true);
- tree.setRowKeyAndData(context, data.getTuple().getRowKey(), data.getTuple().getData());
+ data.makeEncoded();
+ tree.restoreFromSnapshot(context, data.getTuple());
- TreeNodeState nodeState = getNodeState(data.isLeaf(), false);
+ TreeNodeState nodeState = getNodeState(tree.isLeaf(), false);
writeTreeNodeStartElement(nodeState);
tree.findTreeNodeComponent().encodeAll(context);
@@ -141,48 +133,36 @@
}
}
- /* (non-Javadoc)
- * @see org.richfaces.model.TreeDataVisitor#afterChildrenVisit()
- */
public void afterChildrenVisit() {
- // TODO Auto-generated method stub
-
}
public void enterNode() {
- TreeDataModelTuple tuple = new TreeDataModelTuple(tree.getRowKey(), tree.getRowData());
- QueuedData queuedData = new QueuedData(tuple, tree.isLeaf());
+ TreeDataModelTuple tuple = tree.createSnapshot();
+ QueuedData queuedData = new QueuedData(tuple);
try {
flushParentNode();
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new FacesException(e.getMessage(), e);
}
- tree.setRowKeyAndData(context, tuple.getRowKey(), tuple.getData());
+ tree.restoreFromSnapshot(context, tuple);
queuedDataList.add(queuedData);
}
public void exitNode() {
QueuedData data = queuedDataList.removeLast();
-
- tree.setRowKeyAndData(context, data.getTuple().getRowKey(), data.getTuple().getData());
- if (!data.isEncoded()) {
- try {
- writeTreeNodeStartElement(getNodeState(data.isLeaf(), data.isVisited()));
+
+ tree.restoreFromSnapshot(context, data.getTuple());
+ try {
+ if (!data.isEncoded()) {
+ writeTreeNodeStartElement(getNodeState(tree.isLeaf(), data.isVisited()));
tree.findTreeNodeComponent().encodeAll(context);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
- }
- try {
writeTreeNodeEndElement();
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new FacesException(e.getMessage(), e);
}
}
14 years, 3 months
JBoss Rich Faces SVN: r20216 - in trunk: examples/iteration-demo/src/main/java/org/richfaces/demo/model/tree/adaptors and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-29 15:52:25 -0500 (Mon, 29 Nov 2010)
New Revision: 20216
Added:
trunk/examples/iteration-demo/src/main/webapp/images/compress.png
trunk/examples/iteration-demo/src/main/webapp/images/folder.png
trunk/examples/iteration-demo/src/main/webapp/images/folder_key.png
trunk/examples/iteration-demo/src/main/webapp/images/folder_page.png
trunk/examples/iteration-demo/src/main/webapp/images/page_white_cup.png
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java
Modified:
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/model/tree/TreeModelBean.java
trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/model/tree/adaptors/Entry.java
trunk/examples/iteration-demo/src/main/resources/org/richfaces/demo/model/tree/tree-model-data.xml
trunk/examples/iteration-demo/src/main/webapp/treeModel.xhtml
trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModelTuple.java
trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataVisitor.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeModelKey.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeState.java
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
Log:
https://jira.jboss.org/browse/RF-9680
Modified: trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/model/tree/TreeModelBean.java
===================================================================
--- trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/model/tree/TreeModelBean.java 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/model/tree/TreeModelBean.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -3,10 +3,15 @@
*/
package org.richfaces.demo.model.tree;
+import javax.faces.FacesException;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
-import javax.xml.bind.JAXB;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.Unmarshaller.Listener;
+import org.richfaces.demo.model.tree.adaptors.Entry;
import org.richfaces.demo.model.tree.adaptors.Root;
/**
@@ -22,7 +27,27 @@
private Root root;
private void initializeRoot() {
- root = JAXB.unmarshal(TreeModelBean.class.getResource("tree-model-data.xml"), Root.class);
+
+ try {
+ JAXBContext context = JAXBContext.newInstance(Root.class);
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+ unmarshaller.setListener(new Listener() {
+ @Override
+ public void afterUnmarshal(Object target, Object parent) {
+ super.afterUnmarshal(target, parent);
+
+ if (parent instanceof Entry) {
+ ((Entry) target).setParent((Entry) parent);
+ }
+
+ }
+ });
+
+
+ root = (Root) unmarshaller.unmarshal(TreeModelBean.class.getResource("tree-model-data.xml"));
+ } catch (JAXBException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
}
public Root getRoot() {
Modified: trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/model/tree/adaptors/Entry.java
===================================================================
--- trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/model/tree/adaptors/Entry.java 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/model/tree/adaptors/Entry.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -21,11 +21,18 @@
*/
package org.richfaces.demo.model.tree.adaptors;
+import java.util.List;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+
/**
* @author Nick Belaevski
* mailto:nbelaevski@exadel.com
@@ -38,8 +45,28 @@
@XmlAttribute
private String name;
+ private Entry parent;
+
+ public String getPath() {
+ List<Entry> entries = Lists.newLinkedList();
+
+ Entry entry = this;
+ while (entry != null) {
+ entries.add(0, entry);
+ entry = entry.getParent();
+ }
+
+ return Joiner.on(" -> ").join(entries);
+ }
+
+ public void processClick() {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ context.addMessage(null, new FacesMessage(getPath()));
+ }
+
public String toString() {
- return this.getClass().getSimpleName() + "[" + name + "]";
+ return getClass().getSimpleName() + " [" + getName() + "]";
}
public String getName() {
@@ -53,4 +80,12 @@
public void click() {
}
+ public Entry getParent() {
+ return parent;
+ }
+
+ public void setParent(Entry parent) {
+ this.parent = parent;
+ }
+
}
Modified: trunk/examples/iteration-demo/src/main/resources/org/richfaces/demo/model/tree/tree-model-data.xml
===================================================================
--- trunk/examples/iteration-demo/src/main/resources/org/richfaces/demo/model/tree/tree-model-data.xml 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/examples/iteration-demo/src/main/resources/org/richfaces/demo/model/tree/tree-model-data.xml 2010-11-29 20:52:25 UTC (rev 20216)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
- <!-- project name="ajax4jsf">
+ <project name="ajax4jsf">
<sourceDirectory name="src/main/java">
<package name="org.ajax4jsf">
<class name="FastFilter.java" />
@@ -22,10 +22,10 @@
<package name="org.ajax4jsf.javascript">
</package>
</sourceDirectory>
- </project -->
+ </project>
<project name="richfaces">
- <!-- sourceDirectory name="src/main/java">
+ <sourceDirectory name="src/main/java">
<package name="org.richfaces">
</package>
<package name="org.richfaces.component">
@@ -52,7 +52,7 @@
<file name="FunctionalSpecification-1.0.doc" />
<file name="Requirements-1.0.doc" />
</directory>
- </directory -->
+ </directory>
<directory name="src">
<directory name="main">
<directory name="config">
Added: trunk/examples/iteration-demo/src/main/webapp/images/compress.png
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/images/compress.png (rev 0)
+++ trunk/examples/iteration-demo/src/main/webapp/images/compress.png 2010-11-29 20:52:25 UTC (rev 20216)
@@ -0,0 +1,7 @@
+�PNG
+
+
+��BQA�t#��݈��U+YH]�.��6�,��.�t�BJ7""�U�-b��̴�������I�����܇��������3`���V��T�>wGU���ca��^=v���u�������js��kO�m�T�֘�؉�cf�n�ŕ��o��S�
+�w����{�&���
\ No newline at end of file
Added: trunk/examples/iteration-demo/src/main/webapp/images/folder.png
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/images/folder.png (rev 0)
+++ trunk/examples/iteration-demo/src/main/webapp/images/folder.png 2010-11-29 20:52:25 UTC (rev 20216)
@@ -0,0 +1,11 @@
+�PNG
+
+
+���ݬ����2OT�O�1W��/�`z����8%�;O;�9P#�9B�����}�^��nO������;�����Ǫo��~
+���d���~�Ed�p�ɳ_��_
+�u�I�
+��B�
+�!
+CF(N��߃J,$���k����(!���TA��F*$X����(�}�f�R�/�x�Q��
+�E�q��x!��i3,�mf?Oԓn����A�Q�
\ No newline at end of file
Added: trunk/examples/iteration-demo/src/main/webapp/images/folder_key.png
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/images/folder_key.png (rev 0)
+++ trunk/examples/iteration-demo/src/main/webapp/images/folder_key.png 2010-11-29 20:52:25 UTC (rev 20216)
@@ -0,0 +1,7 @@
+�PNG
+
+
+b�������l���Hɜ�#�->����J�-������
\ No newline at end of file
Added: trunk/examples/iteration-demo/src/main/webapp/images/folder_page.png
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/images/folder_page.png (rev 0)
+++ trunk/examples/iteration-demo/src/main/webapp/images/folder_page.png 2010-11-29 20:52:25 UTC (rev 20216)
@@ -0,0 +1,9 @@
+�PNG
+
+
+�+��Z�։�����啗�9��n��@MLk�Z!�jȅ֯-\1�eS�s~�������J-��0e����U�l���ʖ����?]:���fh�BU�
+s��w��v����[���d@ʤ�����p Z�jU��睼p �L�9z��)d���k`Z6��j���B�{
+ h�E?�\�F�~0_����XŻ���{lc�^-e��@&mesm�t)��P�����ԛ�ō˯����#��H��-i�s9��@�r|�
\ No newline at end of file
Added: trunk/examples/iteration-demo/src/main/webapp/images/page_white_cup.png
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/images/page_white_cup.png (rev 0)
+++ trunk/examples/iteration-demo/src/main/webapp/images/page_white_cup.png 2010-11-29 20:52:25 UTC (rev 20216)
@@ -0,0 +1,7 @@
+�PNG
+
+
+>������,i6��V�g�ш�p����>���G�.��ç�O�m�5~}�B���yt:�3��f���9'L�\�ە��i��n�h4�e����I�R��Ár���Z.�C"��q*�b(Db�/�N���~
+�/�J铠�n�l6�|6�q��@�R�ŽL&�
+�ڥHB�$�z��=*>'�5�RyW���b1�h�Z, �Bp:����Z!NO��B�KX�V�g�d���� h >���=��Yp*�%�h�2��#��k�M�\�:�����{�F`k��
\ No newline at end of file
Modified: trunk/examples/iteration-demo/src/main/webapp/treeModel.xhtml
===================================================================
--- trunk/examples/iteration-demo/src/main/webapp/treeModel.xhtml 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/examples/iteration-demo/src/main/webapp/treeModel.xhtml 2010-11-29 20:52:25 UTC (rev 20216)
@@ -12,19 +12,44 @@
</h:head>
<h:body>
- <h:messages id="messages" />
+ <a4j:outputPanel ajaxRendered="true">
+ <h:messages id="messages" />
+ </a4j:outputPanel>
<h:form id="form">
<it:tree id="tree" var="node" toggleType="ajax">
+ <it:treeNode>
+ <a4j:commandLink value="#{node}" action="#{node.processClick}" />
+ </it:treeNode>
+
<it:treeModelAdaptor nodes="#{treeModelBean.root.projects}">
+ <it:treeNode iconExpanded="/images/folder_key.png" iconCollapsed="/images/folder_key.png">
+ <a4j:commandLink value="#{node}" action="#{node.processClick}" />
+ </it:treeNode>
+
<it:treeModelAdaptor nodes="#{node.sourceDirectories}">
+ <it:treeNode iconExpanded="/images/page_white_cup.png" iconCollapsed="/images/page_white_cup.png">
+ <a4j:commandLink value="#{node}" action="#{node.processClick}" />
+ </it:treeNode>
+
<it:treeModelAdaptor nodes="#{node.packages}">
<it:treeModelAdaptor nodes="#{node.classes}" />
</it:treeModelAdaptor>
</it:treeModelAdaptor>
<it:treeModelRecursiveAdaptor roots="#{node.commonDirectories}" nodes="#{node.directories}">
+ <it:treeNode iconExpanded="/images/folder_page.png" iconCollapsed="/images/folder.png">
+ <a4j:commandLink value="#{node}" action="#{node.processClick}" />
+ </it:treeNode>
+
<it:treeModelRecursiveAdaptor roots="#{node.archiveFiles}" nodes="#{node.archiveEntries}">
+
+ <it:treeNode rendered="#{node.class.simpleName eq 'ArchiveFile'}"
+ iconExpanded="/images/compress.png"
+ iconCollapsed="/images/compress.png">
+ <a4j:commandLink value="#{node}" action="#{node.processClick}" />
+ </it:treeNode>
+
<it:treeModelAdaptor rendered="#{node.class.simpleName eq 'ArchiveEntry'}"
nodes="#{node.archiveEntryFiles}" />
</it:treeModelRecursiveAdaptor>
@@ -33,5 +58,10 @@
</it:treeModelAdaptor>
</it:tree>
</h:form>
+
+ <h:panelGroup style="position: absolute; bottom: 20px; left: 20px; right: 20px;">
+ <hr />
+ This demo uses icons taken from <a href="http://www.famfamfam.com/lab/icons/silk/">http://www.famfamfam.com/lab/icons/silk/</a>
+ </h:panelGroup>
</h:body>
</html>
Modified: trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModelTuple.java
===================================================================
--- trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModelTuple.java 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModelTuple.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -21,6 +21,9 @@
*/
package org.richfaces.model;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
/**
* @author Nick Belaevski
*
@@ -44,5 +47,13 @@
public Object getData() {
return data;
}
-
+
+ @Override
+ public String toString() {
+ ToStringHelper helper = Objects.toStringHelper(this);
+ helper.add("rowKey", rowKey);
+ helper.add("data", data);
+
+ return helper.toString();
+ }
}
Modified: trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataVisitor.java
===================================================================
--- trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataVisitor.java 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataVisitor.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -31,5 +31,8 @@
public void enterNode();
public void exitNode();
-
+
+ public void beforeChildrenVisit();
+
+ public void afterChildrenVisit();
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -69,6 +69,7 @@
import org.richfaces.event.TreeToggleListener;
import org.richfaces.event.TreeToggleSource;
import org.richfaces.model.DeclarativeTreeDataModelImpl;
+import org.richfaces.model.DeclarativeTreeModel;
import org.richfaces.model.SwingTreeNodeDataModelImpl;
import org.richfaces.model.TreeDataModel;
import org.richfaces.model.TreeDataModelTuple;
@@ -131,9 +132,11 @@
selection
}
+ @SuppressWarnings("unused")
@Attribute(generate = false, signature = @Signature(returnType = Void.class, parameters = TreeSelectionChangeEvent.class))
private MethodExpression selectionChangeListener;
+ @SuppressWarnings("unused")
@Attribute(generate = false, signature = @Signature(returnType = Void.class, parameters = TreeToggleListener.class))
private MethodExpression toggleListener;
@@ -233,13 +236,10 @@
return converter;
}
- public AbstractTreeNode findTreeNodeComponent() {
- FacesContext facesContext = getFacesContext();
-
- String nodeType = getNodeType();
- Iterator<UIComponent> matchingNodes = Iterators.filter(getChildren().iterator(),
+ protected AbstractTreeNode findTreeNodeComponent(String nodeType, UIComponent parentComponent) {
+ Iterator<UIComponent> matchingNodes = Iterators.filter(parentComponent.getChildren().iterator(),
new MatchingTreeNodePredicate(nodeType));
-
+
boolean hasNodes = matchingNodes.hasNext();
if (hasNodes) {
Iterator<UIComponent> renderedTreeNodes = Iterators.filter(matchingNodes, ComponentPredicates.isRendered());
@@ -249,7 +249,40 @@
return null;
}
}
+
+ return null;
+ }
+ protected UIComponent getCurrentComponent() {
+ ExtendedDataModel<?> dataModel = getExtendedDataModel();
+ if (dataModel instanceof DeclarativeTreeModel) {
+ return ((DeclarativeTreeModel) dataModel).getCurrentComponent();
+ }
+
+ return this;
+ }
+
+ @Override
+ public void setRowKeyAndData(FacesContext facesContext, Object rowKey, Object localRowData) {
+ super.setRowKeyAndData(facesContext, rowKey, localRowData);
+ }
+
+ public AbstractTreeNode findTreeNodeComponent() {
+ FacesContext facesContext = getFacesContext();
+
+ String nodeType = getNodeType();
+
+ UIComponent component = getCurrentComponent();
+
+ AbstractTreeNode treeNodeComponent = findTreeNodeComponent(nodeType, component);
+ if (treeNodeComponent == null && component != this) {
+ treeNodeComponent = findTreeNodeComponent(nodeType, this);
+ }
+
+ if (treeNodeComponent != null) {
+ return treeNodeComponent;
+ }
+
if (Strings.isNullOrEmpty(nodeType)) {
if (getAttributes().put(DEFAULT_TREE_NODE_CREATED, Boolean.TRUE) != null) {
return null;
@@ -462,6 +495,16 @@
public void exitNode() {
}
+
+ public void beforeChildrenVisit() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void afterChildrenVisit() {
+ // TODO Auto-generated method stub
+
+ }
});
}
@@ -506,6 +549,8 @@
return;
}
+ dataVisitor.beforeChildrenVisit();
+
Iterator<TreeDataModelTuple> childrenTuples = model.children();
while (childrenTuples.hasNext()) {
TreeDataModelTuple tuple = childrenTuples.next();
@@ -522,6 +567,8 @@
dataVisitor.exitNode();
}
+
+ dataVisitor.afterChildrenVisit();
}
@Override
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeModelKey.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeModelKey.java 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeModelKey.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -89,6 +89,6 @@
@Override
public String toString() {
- return getModelId() + '.' + getModelKey();
+ return getModelId() + "." + getModelKey();
}
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -45,7 +45,7 @@
* @author Nick Belaevski
*
*/
-public class DeclarativeTreeDataModelImpl extends TreeSequenceKeyModel<DeclarativeModelKey, Object> {
+public class DeclarativeTreeDataModelImpl extends TreeSequenceKeyModel<DeclarativeModelKey, Object> implements DeclarativeTreeModel {
private static final Logger LOGGER = RichfacesLogger.MODEL.getLogger();
@@ -159,7 +159,7 @@
this.contextMap = contextMap;
}
- protected UIComponent getCurrentComponent() {
+ public UIComponent getCurrentComponent() {
return currentComponent;
}
Copied: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java (from rev 20215, trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataVisitor.java)
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java (rev 0)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeModel.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -0,0 +1,34 @@
+/*
+ * 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.model;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface DeclarativeTreeModel {
+
+ public UIComponent getCurrentComponent();
+
+}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -22,6 +22,7 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.LinkedList;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -31,10 +32,57 @@
import org.richfaces.component.AbstractTree;
import org.richfaces.component.AbstractTreeNode;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.model.TreeDataModelTuple;
import org.richfaces.model.TreeDataVisitor;
abstract class TreeEncoderBase implements TreeDataVisitor {
+ /**
+ * @author Nick Belaevski
+ *
+ */
+ private static final class QueuedData {
+
+ private boolean encoded = false;
+
+ private boolean visited = false;
+
+ //TODO - should be part of tree state
+ private boolean leaf;
+
+ private TreeDataModelTuple tuple;
+
+ public QueuedData(TreeDataModelTuple tuple, boolean leaf) {
+ super();
+ this.tuple = tuple;
+ this.leaf = leaf;
+ }
+
+ public boolean isEncoded() {
+ return encoded;
+ }
+
+ public void setEncoded(boolean encoded) {
+ this.encoded = encoded;
+ }
+
+ public void makeVisited() {
+ this.visited = true;
+ }
+
+ public boolean isVisited() {
+ return visited;
+ }
+
+ public TreeDataModelTuple getTuple() {
+ return tuple;
+ }
+
+ public boolean isLeaf() {
+ return leaf;
+ }
+ }
+
static final String TREE_NODE_STATE_ATTRIBUTE = "__treeNodeState";
protected final FacesContext context;
@@ -43,6 +91,8 @@
protected final AbstractTree tree;
+ private LinkedList<QueuedData> queuedDataList = new LinkedList<QueuedData>();
+
public TreeEncoderBase(FacesContext context, AbstractTree tree) {
super();
this.context = context;
@@ -54,28 +104,80 @@
tree.walkModel(context, this);
}
- public void enterNode() {
- TreeNodeState state;
- if (tree.isLeaf()) {
- state = TreeNodeState.leaf;
+ protected void flushParentNode() throws IOException {
+ if (queuedDataList.isEmpty()) {
+ return;
+ }
+
+ QueuedData data = queuedDataList.getLast();
+ if (!data.isEncoded()) {
+ data.setEncoded(true);
+ tree.setRowKeyAndData(context, data.getTuple().getRowKey(), data.getTuple().getData());
+
+ TreeNodeState nodeState = getNodeState(data.isLeaf(), false);
+
+ writeTreeNodeStartElement(nodeState);
+ tree.findTreeNodeComponent().encodeAll(context);
+ }
+ }
+
+ private TreeNodeState getNodeState(boolean leaf, boolean visited) {
+ TreeNodeState nodeState;
+ if (leaf) {
+ nodeState = TreeNodeState.leaf;
+ } else if (visited) {
+ nodeState = TreeNodeState.expandedNoChildren;
+ } else if (tree.isExpanded()) {
+ nodeState = TreeNodeState.expanded;
} else {
- if (tree.isExpanded()) {
- state = TreeNodeState.expanded;
- } else {
- state = TreeNodeState.collapsed;
- }
+ nodeState = TreeNodeState.collapsed;
}
+ return nodeState;
+ }
+
+ public void beforeChildrenVisit() {
+ if (!queuedDataList.isEmpty()) {
+ queuedDataList.getLast().makeVisited();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.model.TreeDataVisitor#afterChildrenVisit()
+ */
+ public void afterChildrenVisit() {
+ // TODO Auto-generated method stub
+ }
+
+ public void enterNode() {
+ TreeDataModelTuple tuple = new TreeDataModelTuple(tree.getRowKey(), tree.getRowData());
+ QueuedData queuedData = new QueuedData(tuple, tree.isLeaf());
+
try {
- writeTreeNodeStartElement(state);
- tree.findTreeNodeComponent().encodeAll(context);
+ flushParentNode();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+
+ tree.setRowKeyAndData(context, tuple.getRowKey(), tuple.getData());
+ queuedDataList.add(queuedData);
}
public void exitNode() {
+ QueuedData data = queuedDataList.removeLast();
+
+ tree.setRowKeyAndData(context, data.getTuple().getRowKey(), data.getTuple().getData());
+ if (!data.isEncoded()) {
+ try {
+ writeTreeNodeStartElement(getNodeState(data.isLeaf(), data.isVisited()));
+ tree.findTreeNodeComponent().encodeAll(context);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
try {
writeTreeNodeEndElement();
} catch (IOException e) {
@@ -106,10 +208,9 @@
private void emitClientToggleEvent(AbstractTreeNode treeNode, TreeNodeState nodeState) {
if (treeNode.getClientId(context).equals(context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_ATTRIBUTE))) {
- TreeNodeState submittedState = ((Boolean) (context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_STATE_ATTRIBUTE)))
- ? TreeNodeState.expanded : TreeNodeState.collapsed;
+ TreeNodeState initialState = (TreeNodeState) context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_STATE_ATTRIBUTE);
- if (submittedState == nodeState || nodeState == TreeNodeState.leaf) {
+ if (initialState.isDifferentThan(nodeState)) {
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
ajaxContext.appendOncomplete(new JSFunction("RichFaces.ui.TreeNode.emitToggleEvent", treeNode.getClientId(context)));
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -63,9 +63,10 @@
AbstractTreeNode treeNode = (AbstractTreeNode) component;
- boolean expanded = Boolean.valueOf(newToggleState);
- if (treeNode.isExpanded() ^ expanded) {
- new TreeToggleEvent(treeNode, expanded).queue();
+ boolean initialState = treeNode.isExpanded();
+ boolean newState = Boolean.valueOf(newToggleState);
+ if (initialState ^ newState) {
+ new TreeToggleEvent(treeNode, newState).queue();
}
PartialViewContext pvc = context.getPartialViewContext();
@@ -73,7 +74,7 @@
pvc.getRenderIds().add(treeNode.getClientId(context) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + AbstractTreeNode.SUBTREE_META_COMPONENT_ID);
context.getAttributes().put(AJAX_TOGGLED_NODE_ATTRIBUTE, component.getClientId(context));
- context.getAttributes().put(AJAX_TOGGLED_NODE_STATE_ATTRIBUTE, expanded);
+ context.getAttributes().put(AJAX_TOGGLED_NODE_STATE_ATTRIBUTE, initialState ? TreeNodeState.expanded : TreeNodeState.collapsed);
}
}
}
@@ -141,8 +142,8 @@
if (toggleType == SwitchType.client || nodeState == TreeNodeState.collapsed) {
encodeIconForNodeState(context, tree, treeNode, TreeNodeState.collapsed, iconCollapsed);
}
-
- if (toggleType == SwitchType.client || nodeState == TreeNodeState.expanded) {
+
+ if (toggleType == SwitchType.client || nodeState == TreeNodeState.expanded || nodeState == TreeNodeState.expandedNoChildren) {
encodeIconForNodeState(context, tree, treeNode, TreeNodeState.expanded, iconExpanded);
}
}
@@ -162,6 +163,7 @@
protected void addClientEventHandlers(FacesContext facesContext, UIComponent component) {
AbstractTreeNode treeNode = (AbstractTreeNode) component;
+ //TODO check node state
//TODO check toggle/selection types
TreeRenderingContext renderingContext = TreeRenderingContext.get(facesContext);
renderingContext.addHandlers(treeNode);
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeState.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeState.java 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeState.java 2010-11-29 20:52:25 UTC (rev 20216)
@@ -29,28 +29,46 @@
public boolean isLeaf() {
return false;
}
- },
+
+ @Override
+ public boolean isDifferentThan(TreeNodeState anotherState) {
+ return anotherState != expandedNoChildren && super.isDifferentThan(anotherState);
+ }
+
+ },
+ expandedNoChildren("rf-tr-nd-exp rf-tr-nd-exp-nc", "rf-trn-hnd-lf", "rf-trn-ico-exp") {
+ @Override
+ public boolean isLeaf() {
+ return false;
+ }
+
+ @Override
+ public boolean isDifferentThan(TreeNodeState anotherState) {
+ return anotherState != expanded && super.isDifferentThan(anotherState);
+ }
+ },
collapsed("rf-tr-nd-colps", "rf-trn-hnd-colps", "rf-trn-ico-colps") {
@Override
public boolean isLeaf() {
return false;
}
- },
+ },
leaf("rf-tr-nd-lf", "rf-trn-hnd-lf", "rf-trn-ico-lf") {
@Override
public boolean isLeaf() {
return true;
}
+
};
private String nodeClass;
private String handleClass;
-
+
private String iconClass;
private String customIconClass;
-
+
private TreeNodeState(String nodeClass, String defaultHandleClass, String iconClass) {
this.nodeClass = nodeClass;
this.handleClass = HtmlUtil.concatClasses(defaultHandleClass, "rf-trn-hnd");
@@ -59,7 +77,11 @@
}
public abstract boolean isLeaf();
-
+
+ public boolean isDifferentThan(TreeNodeState anotherState) {
+ return anotherState != this;
+ }
+
public String getNodeClass() {
return nodeClass;
}
Modified: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-29 20:44:15 UTC (rev 20215)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-11-29 20:52:25 UTC (rev 20216)
@@ -153,8 +153,12 @@
return this.__rootElt.hasClass("rf-tr-nd-lf");
},
+ __canBeToggled: function() {
+ return !this.isLeaf() && !this.__rootElt.hasClass("rf-tr-nd-exp-nc");
+ },
+
toggle: function() {
- if (this.isLeaf()) {
+ if (!this.__canBeToggled()) {
return;
}
14 years, 3 months