JBoss Rich Faces SVN: r19727 - in trunk: examples/output-demo/src/main/webapp/examples and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-10-28 09:58:50 -0400 (Thu, 28 Oct 2010)
New Revision: 19727
Added:
trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml
trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js
trunk/ui/output/api/src/main/java/org/richfaces/TooltipDirection.java
trunk/ui/output/api/src/main/java/org/richfaces/TooltipLayout.java
trunk/ui/output/api/src/main/java/org/richfaces/TooltipMode.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTooltip.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlTooltip.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/Tooltip.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.ecss
trunk/ui/output/ui/src/test/java/org/richfaces/component/UITooltipTest.java
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/TooltipRendererTest.java
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xhtml
trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xmlunit.xml
Modified:
trunk/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml
trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-accordion-item-qunit.js
trunk/examples/output-demo/src/main/webapp/templates/template.xhtml
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
Log:
RF-9474 Tooltip component
Modified: trunk/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml 2010-10-28 13:55:25 UTC (rev 19726)
+++ trunk/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml 2010-10-28 13:58:50 UTC (rev 19727)
@@ -9,7 +9,20 @@
</managed-bean>
<navigation-rule>
- <!-- Examples -->
+ <navigation-case>
+ <from-outcome>panel</from-outcome>
+ <to-view-id>/examples/panel.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>popup</from-outcome>
+ <to-view-id>/examples/popupPanel.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>progressbar</from-outcome>
+ <to-view-id>/examples/progressbar.xhtml</to-view-id>
+ </navigation-case>
+
+ <!-- TogglePanel navigation -->
<navigation-case>
<from-outcome>togglePanel</from-outcome>
<to-view-id>/examples/togglePanel.xhtml</to-view-id>
@@ -31,32 +44,6 @@
<to-view-id>/examples/togglePanel-mixed.xhtml</to-view-id>
</navigation-case>
<navigation-case>
- <from-outcome>accordion</from-outcome>
- <to-view-id>/examples/accordion.xhtml</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-outcome>collapsiblePanel</from-outcome>
- <to-view-id>/examples/collapsiblePanel.xhtml</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-outcome>tabPanel</from-outcome>
- <to-view-id>/examples/tabPanel.xhtml</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-outcome>panel</from-outcome>
- <to-view-id>/examples/panel.xhtml</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-outcome>popup</from-outcome>
- <to-view-id>/examples/popupPanel.xhtml</to-view-id>
- </navigation-case>
- <navigation-case>
- <from-outcome>progressbar</from-outcome>
- <to-view-id>/examples/progressbar.xhtml</to-view-id>
- </navigation-case>
-
- <!-- QUnit -->
- <navigation-case>
<from-outcome>qunit/togglePanel</from-outcome>
<to-view-id>/qunit/togglePanel.xhtml</to-view-id>
</navigation-case>
@@ -64,7 +51,13 @@
<from-outcome>qunit/togglePanelItem</from-outcome>
<to-view-id>/qunit/togglePanelItem.xhtml</to-view-id>
</navigation-case>
+
+ <!-- Accordion navigation -->
<navigation-case>
+ <from-outcome>accordion</from-outcome>
+ <to-view-id>/examples/accordion.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
<from-outcome>qunit/accordion</from-outcome>
<to-view-id>/qunit/accordion.xhtml</to-view-id>
</navigation-case>
@@ -72,13 +65,35 @@
<from-outcome>qunit/accordionHeaders</from-outcome>
<to-view-id>/qunit/accordionHeaders.xhtml</to-view-id>
</navigation-case>
+
+ <!-- CollapsiblePanel navigation -->
<navigation-case>
+ <from-outcome>collapsiblePanel</from-outcome>
+ <to-view-id>/examples/collapsiblePanel.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
<from-outcome>qunit/collapsiblePanel</from-outcome>
<to-view-id>/qunit/collapsiblePanel.xhtml</to-view-id>
</navigation-case>
+
+ <!-- TabPanel navigation -->
<navigation-case>
+ <from-outcome>tabPanel</from-outcome>
+ <to-view-id>/examples/tabPanel.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
<from-outcome>qunit/tabPanel</from-outcome>
<to-view-id>/qunit/tabPanel.xhtml</to-view-id>
</navigation-case>
+
+ <!-- Tooltip navigation -->
+ <navigation-case>
+ <from-outcome>tooltip</from-outcome>
+ <to-view-id>/examples/tooltip.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>qunit/tooltip</from-outcome>
+ <to-view-id>/qunit/tooltip.xhtml</to-view-id>
+ </navigation-case>
</navigation-rule>
</faces-config>
Added: trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml (rev 0)
+++ trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,51 @@
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright ${year}, Red Hat, Inc. and individual contributors
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:pn="http://richfaces.org/output">
+
+<body>
+<ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="scripts">
+ <h:outputScript name="Tooltip.js" />
+ </ui:define>
+
+ <ui:define name="title">TOOLTIP JS Development</ui:define>
+ <ui:define name="body_head">TOOLTIP JS Development</ui:define>
+
+ <ui:define name="body">
+ <h:form id="f" style="border:blue solid thin;">
+ <pn:tooltip id="tooltip">
+ <!-- TODO -->
+ </pn:tooltip>
+ </h:form>
+ </ui:define>
+</ui:composition>
+</body>
+</html>
+
Added: trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml (rev 0)
+++ trunk/examples/output-demo/src/main/webapp/qunit/tooltip.xhtml 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,71 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+
+
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:pn="http://richfaces.org/output">
+
+<body>
+<ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="scripts">
+ <h:outputScript name="qunit/qunit.js"/>
+ <h:outputScript name="qunit/richfaces-qunit.js"/>
+
+ <h:outputStylesheet name="qunit/qunit.css"/>
+ </ui:define>
+
+ <ui:define name="title">Tooltip Example</ui:define>
+ <ui:define name="body_head">Tooltip Example</ui:define>
+
+ <ui:define name="body">
+ <p>Page</p>
+
+ <h:form id="f" style="border:blue solid thin;">
+ <div id="div" style="border: 2px solid red; background-color: #adff2f; width:300px; height:300px">
+ Hello
+
+ <pn:tooltip id="tooltip">
+ ToolTip Yo!!!
+ </pn:tooltip>
+ </div>
+
+
+ </h:form>
+ <p>Result</p>
+
+ <div>
+ <ol id="qunit-tests"></ol>
+
+ <div id="testDiv" style="margin-top:10px; border:1px solid #a0a0a0">Main Test Div</div>
+ </div>
+ <!--<h:outputScript name="tests/richfaces-tooltip-qunit.js" />-->
+ </ui:define>
+</ui:composition>
+</body>
+</html>
+
Modified: trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-accordion-item-qunit.js
===================================================================
--- trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-accordion-item-qunit.js 2010-10-28 13:55:25 UTC (rev 19726)
+++ trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-accordion-item-qunit.js 2010-10-28 13:58:50 UTC (rev 19727)
@@ -41,7 +41,7 @@
for (i in PUBLIC_API) {
var funcName = PUBLIC_API[i];
- ok(c.[funcName], funcName + "present in component")
+ ok(c[funcName], funcName + "present in component")
// TODO check other functions + check is it function
}
});
Added: trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js
===================================================================
--- trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js (rev 0)
+++ trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-tooltip-qunit.js 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+RichFaces.QUnit.run(function() {
+ module("richfaces-tooltip");
+
+ var TOOLTIP_ID = "f:tooltip";
+
+ function handler (msg, returnValue) {
+ return function () {
+ ok(true, msg);
+
+ if (returnValue != undefined) {
+ return returnValue;
+ }
+ };
+ }
+
+ test("RichFaces.ui.Tooltip test constructor", function () {
+ var c = RichFaces.$(TOOLTIP_ID);
+
+ ok(c instanceof RichFaces.ui.Tooltip, "instance of RichFaces.ui.Tooltip");
+ equals(c.id, TOOLTIP_ID, "id");
+
+ // test default options
+ same(c.options.direction, RichFaces.ui.TooltipDirection.DEFAULT, "Direction");
+ same(c.options.attached, true, "Attached");
+ same(c.options.offset, {}, "Offset");
+ same(c.options.mode, RichFaces.ui.TooltipMode.DEFAULT, "Mode");
+ same(c.options.disabled, false, "Disabled");
+ same(c.options.hideDelay, 0, "Hide Delay");
+ same(c.options.hideEvent, "leave", "Hide Event");
+ same(c.options.showDelay, 0, "Show Delay");
+ same(c.options.showEvent, "enter", "Show Event");
+ same(c.options.followMouse, true, "Follow Mouse");
+
+ });
+
+ test("RichFaces.ui.Tooltip test public api", function () {
+ var c = RichFaces.$(TOOLTIP_ID);
+
+ var PUBLIC_API = ["hide", "show"];
+
+ for (var i in PUBLIC_API) {
+ var funcName = PUBLIC_API[i];
+ ok(c[funcName], funcName + "present in component");
+ equals(typeof c[funcName], "function", funcName + " is function");
+ }
+ });
+
+ function testHideEvents(cancelEvent) {
+ var c = RichFaces.$(TOOLTIP_ID);
+
+ expect(cancelEvent ? 2 : 3);
+ var beforeHideHandler = function (event, comp, data) {
+ ok(true, "beforehide handler invoked");
+ same(data.id, TOOLTIP_ID, "Component Id");
+
+ return !cancelEvent;
+ };
+ var beforeHideHandlerWrapper = RichFaces.Event.bindById(TOOLTIP_ID, "beforehide", beforeHideHandler);
+
+ var hideHandler = handler("hide handler invoked", undefined);
+ var hideHandlerWrapper = RichFaces.Event.bindById(TOOLTIP_ID, "hide", hideHandler);
+
+ c.hide();
+
+ RichFaces.Event.unbindById(TOOLTIP_ID, "beforehide", beforeHideHandlerWrapper);
+ RichFaces.Event.unbindById(TOOLTIP_ID, "hide", hideHandlerWrapper);
+
+ // TODO undo changes
+ }
+
+ test("RichFaces.ui.Tooltip.hide test", function () {
+ testHideEvents(false);
+ });
+
+ test("RichFaces.ui.Tooltip.hide test cancelable event", function () {
+ testHideEvents(true);
+ });
+
+ function testShowEvents(cancelEvent) {
+ var c = RichFaces.$(TOOLTIP_ID);
+
+ expect(cancelEvent ? 2 : 3);
+ var beforeShowHandler = function (event, comp, data) {
+ ok(true, "beforeshow handler invoked");
+ same(data.id, TOOLTIP_ID, "Component Id");
+
+ return !cancelEvent;
+ };
+ var beforeShowHandlerWrapper = RichFaces.Event.bindById(TOOLTIP_ID, "beforeshow", beforeShowHandler);
+
+ var showHandler = handler("show handler invoked", undefined);
+ var showHandlerWrapper = RichFaces.Event.bindById(TOOLTIP_ID, "show", showHandler);
+
+ c.show();
+
+ RichFaces.Event.unbindById(TOOLTIP_ID, "beforeshow", beforeShowHandlerWrapper);
+ RichFaces.Event.unbindById(TOOLTIP_ID, "show", showHandlerWrapper);
+
+ // TODO undo changes
+ }
+
+ test("RichFaces.ui.Tooltip.show test", function () {
+ testShowEvents(false);
+ });
+
+ test("RichFaces.ui.Tooltip.show test cancelable event", function () {
+ testShowEvents(true);
+ });
+
+
+});
Modified: trunk/examples/output-demo/src/main/webapp/templates/template.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/templates/template.xhtml 2010-10-28 13:55:25 UTC (rev 19726)
+++ trunk/examples/output-demo/src/main/webapp/templates/template.xhtml 2010-10-28 13:58:50 UTC (rev 19727)
@@ -77,6 +77,25 @@
<li><h:commandLink value="Tab Panel" action="tabPanel" /></li>
</ul>
</li>
+ <li>
+ <p>Tooltip</p>
+ <ul>
+ <li>
+ <p>Examples</p>
+ <ul>
+ <li>
+ <h:commandLink value="Tooltip" action="tooltip"/>
+ </li>
+ </ul>
+ <p>QUnit</p>
+ <ul>
+ <li>
+ <h:commandLink value="Tooltip" action="qunit/tooltip"/>
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </li>
</ul>
<p>QUnit</p>
<ul>
Added: trunk/ui/output/api/src/main/java/org/richfaces/TooltipDirection.java
===================================================================
--- trunk/ui/output/api/src/main/java/org/richfaces/TooltipDirection.java (rev 0)
+++ trunk/ui/output/api/src/main/java/org/richfaces/TooltipDirection.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,10 @@
+package org.richfaces;
+
+/**
+ * @author amarkhel
+ */
+public enum TooltipDirection {
+ topRight, topLeft, bottomRight, bottomLeft, auto;
+
+ public static final TooltipDirection DEFAULT = bottomRight;
+}
Added: trunk/ui/output/api/src/main/java/org/richfaces/TooltipLayout.java
===================================================================
--- trunk/ui/output/api/src/main/java/org/richfaces/TooltipLayout.java (rev 0)
+++ trunk/ui/output/api/src/main/java/org/richfaces/TooltipLayout.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,10 @@
+package org.richfaces;
+
+/**
+ * @author amarkhel
+ */
+public enum TooltipLayout {
+ inline, block;
+
+ public static final TooltipLayout DEFAULT = TooltipLayout.inline;
+}
Added: trunk/ui/output/api/src/main/java/org/richfaces/TooltipMode.java
===================================================================
--- trunk/ui/output/api/src/main/java/org/richfaces/TooltipMode.java (rev 0)
+++ trunk/ui/output/api/src/main/java/org/richfaces/TooltipMode.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,10 @@
+package org.richfaces;
+
+/**
+ * @author amarkhel
+ */
+public enum TooltipMode {
+ client, ajax;
+
+ public static final TooltipMode DEFAULT = TooltipMode.client;
+}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTooltip.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTooltip.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTooltip.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import org.richfaces.TooltipLayout;
+import org.richfaces.TooltipDirection;
+import org.richfaces.TooltipMode;
+import org.richfaces.context.ExtendedVisitContext;
+import org.richfaces.context.ExtendedVisitContextMode;
+import org.richfaces.renderkit.MetaComponentRenderer;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+
+/**
+ * @author amarkhel
+ * @since 2010-10-24
+ */
+public abstract class AbstractTooltip extends AbstractDivPanel implements MetaComponentResolver, MetaComponentEncoder {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Tooltip";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Tooltip";
+
+ public static final String CONTENT_META_COMPONENT_ID = "content";
+
+ protected AbstractTooltip() {
+ setRendererType("org.richfaces.Tooltip");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public abstract String getTarget();
+
+ public abstract String getValue();
+
+ public abstract TooltipLayout getLayout();
+
+ public abstract boolean isAttached();
+
+ public abstract TooltipDirection getDirection();
+
+ public abstract boolean isDisabled();
+
+ public abstract boolean isFollowMouse();
+
+ public abstract int getHideDelay();
+
+ public abstract String getHideEvent();
+
+ public abstract int getHorizontalOffset();
+
+ public abstract TooltipMode getMode();
+
+ public abstract int getShowDelay();
+
+ public abstract String getShowEvent();
+
+ public abstract int getVerticalOffset();
+
+ public abstract boolean isBypassUpdates();
+
+ public abstract boolean isLimitToList();
+
+ public abstract Object getData();
+
+ public abstract String getStatus();
+
+ public abstract Object getExecute();
+
+ public abstract Object getRender();
+
+ @Override
+ public void encodeAll(FacesContext context) throws IOException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (!isRendered()) {
+ return;
+ }
+
+ encodeBegin(context);
+ if (getMode() == TooltipMode.client) {
+ if (getRendersChildren()) {
+ encodeChildren(context);
+ } else if (this.getChildCount() > 0) {
+ for (UIComponent kid : getChildren()) {
+ kid.encodeAll(context);
+ }
+ }
+ }
+
+ encodeEnd(context);
+ }
+
+ @Override
+ public boolean visitTree(VisitContext context, VisitCallback callback) {
+ if (context instanceof ExtendedVisitContext) {
+ ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) context;
+ if (extendedVisitContext.getVisitMode() == ExtendedVisitContextMode.RENDER) {
+
+ VisitResult result = extendedVisitContext.invokeMetaComponentVisitCallback(this, callback,
+ CONTENT_META_COMPONENT_ID);
+ if (result == VisitResult.COMPLETE) {
+ return true;
+ } else if (result == VisitResult.REJECT) {
+ return false;
+ }
+ }
+ }
+
+ return super.visitTree(context, callback);
+ }
+
+ public void encodeMetaComponent(FacesContext context, String metaComponentId) throws IOException {
+ ((MetaComponentRenderer) getRenderer(context)).encodeMetaComponent(context, this, metaComponentId);
+ }
+
+ public String getContentClientId(FacesContext context) {
+ return getClientId(context) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + CONTENT_META_COMPONENT_ID;
+ }
+
+ public String resolveClientId(FacesContext facesContext, UIComponent contextComponent, String metaComponentId) {
+ if (CONTENT_META_COMPONENT_ID.equals(metaComponentId)) {
+ return ((AbstractTooltip) contextComponent).getContentClientId(facesContext);
+ }
+
+ return null;
+ }
+}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UITooltip.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.richfaces.component;
+
+import org.richfaces.TooltipLayout;
+import org.richfaces.TooltipDirection;
+import org.richfaces.TooltipMode;
+
+/**
+ * @author amarkhel
+ * @since 2010-10-24
+ */
+public class UITooltip extends AbstractTooltip {
+
+ public enum PropertyKeys {
+ target,
+ value,
+ layout,
+ attached,
+ direction,
+ disabled,
+ followMouse,
+ hideDelay,
+ hideEvent,
+ horizontalOffset,
+ mode,
+ showDelay,
+ showEvent,
+ verticalOffset,
+ bypassUpdates,
+ limitToList,
+ data,
+ status,
+ execute,
+ render
+ }
+
+ public String getTarget() {
+ return (String) getStateHelper().eval(PropertyKeys.target);
+ }
+
+ public void setTarget(String target) {
+ getStateHelper().put(PropertyKeys.target, target);
+ }
+
+ public String getValue() {
+ return (String) getStateHelper().eval(PropertyKeys.value);
+ }
+
+ public void setValue(String value) {
+ getStateHelper().put(PropertyKeys.value, value);
+ }
+
+ public TooltipLayout getLayout() {
+ return (TooltipLayout) getStateHelper().eval(PropertyKeys.layout, TooltipLayout.DEFAULT);
+ }
+
+ public void setLayout(TooltipLayout layout) {
+ getStateHelper().put(PropertyKeys.layout, layout);
+ }
+
+ public boolean isAttached() {
+ return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.attached, true)));
+ }
+
+ public void setAttached(boolean attached) {
+ getStateHelper().put(PropertyKeys.attached, attached);
+ }
+
+ public TooltipDirection getDirection() {
+ return (TooltipDirection) getStateHelper().eval(PropertyKeys.direction, TooltipDirection.DEFAULT);
+ }
+
+ public void setDirection(TooltipDirection direction) {
+ getStateHelper().put(PropertyKeys.direction, direction);
+ }
+
+ public boolean isDisabled() {
+ return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.disabled)));
+ }
+
+ public void setDisabled(boolean disabled) {
+ getStateHelper().put(PropertyKeys.disabled, disabled);
+ }
+
+ public boolean isFollowMouse() {
+ return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.followMouse, true)));
+ }
+
+ public void setFollowMouse(boolean followMouse) {
+ getStateHelper().put(PropertyKeys.followMouse, followMouse);
+ }
+
+ public int getHideDelay() {
+ return (Integer) getStateHelper().eval(PropertyKeys.hideDelay, 0);
+ }
+
+ public void setHideDelay(int hideDelay) {
+ getStateHelper().put(PropertyKeys.hideDelay, hideDelay);
+ }
+
+ public String getHideEvent() {
+ return (String) getStateHelper().eval(PropertyKeys.hideEvent, "mouseleave");
+ }
+
+ public void setHideEvent(String hideEvent) {
+ getStateHelper().put(PropertyKeys.hideEvent, hideEvent);
+ }
+
+ public int getHorizontalOffset() {
+ return (Integer) getStateHelper().eval(PropertyKeys.horizontalOffset, 10);
+ }
+
+ public void setHorizontalOffset(int horizontalOffset) {
+ getStateHelper().put(PropertyKeys.horizontalOffset, horizontalOffset);
+ }
+
+ public TooltipMode getMode() {
+ return (TooltipMode) getStateHelper().eval(PropertyKeys.mode, TooltipMode.DEFAULT);
+ }
+
+ public void setMode(TooltipMode mode) {
+ getStateHelper().put(PropertyKeys.mode, mode);
+ }
+
+ public int getShowDelay() {
+ return (Integer) getStateHelper().eval(PropertyKeys.showDelay, 0);
+ }
+
+ public void setShowDelay(int showDelay) {
+ getStateHelper().put(PropertyKeys.showDelay, showDelay);
+ }
+
+ public String getShowEvent() {
+ return (String) getStateHelper().eval(PropertyKeys.showEvent, "mouseenter");
+ }
+
+ public void setShowEvent(String showEvent) {
+ getStateHelper().put(PropertyKeys.showEvent, showEvent);
+ }
+
+ public int getVerticalOffset() {
+ return (Integer) getStateHelper().eval(PropertyKeys.verticalOffset, 10);
+ }
+
+ public void setVerticalOffset(int verticalOffset) {
+ getStateHelper().put(PropertyKeys.verticalOffset, verticalOffset);
+ }
+
+ public boolean isBypassUpdates() {
+ return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.bypassUpdates)));
+ }
+
+ public void setBypassUpdates(boolean bypassUpdates) {
+ getStateHelper().put(PropertyKeys.bypassUpdates, bypassUpdates);
+ }
+
+ public boolean isLimitToList() {
+ return Boolean.valueOf(String.valueOf(getStateHelper().eval(PropertyKeys.limitToList)));
+ }
+
+ public void setLimitToList(boolean limitToList) {
+ getStateHelper().put(PropertyKeys.limitToList, limitToList);
+ }
+
+ public Object getData() {
+ return getStateHelper().eval(PropertyKeys.data);
+ }
+
+ public void setData(Object data) {
+ getStateHelper().put(PropertyKeys.data, data);
+ }
+
+ public String getStatus() {
+ return (String) getStateHelper().eval(PropertyKeys.status);
+ }
+
+ public void setStatus(String status) {
+ getStateHelper().put(PropertyKeys.status, status);
+ }
+
+ public Object getExecute() {
+ return getStateHelper().eval(PropertyKeys.execute);
+ }
+
+ public void setExecute(Object execute) {
+ getStateHelper().put(PropertyKeys.execute, execute);
+ }
+
+ public Object getRender() {
+ return getStateHelper().eval(PropertyKeys.render);
+ }
+
+ public void setRender(Object render) {
+ getStateHelper().put(PropertyKeys.render, render);
+ }
+
+
+}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlTooltip.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlTooltip.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlTooltip.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,203 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.richfaces.component.html;
+
+import org.richfaces.component.UITooltip;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @author amarkhel
+ * @since 2010-10-24
+ */
+public class HtmlTooltip extends UITooltip implements ClientBehaviorHolder {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Tooltip";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Tooltip";
+
+ private static final Collection<String> EVENT_NAMES = Collections.unmodifiableCollection(Arrays.asList(
+ "click",
+ "dblclick",
+ "mousedown",
+ "mousemove",
+ "mouseout",
+ "mouseover",
+ "mouseup",
+ "hide",
+ "show",
+ "beforehide",
+ "beforeshow"
+ ));
+
+
+ public enum PropertyKeys {
+ style,
+ styleClass,
+ zindex,
+ onclick,
+ ondblclick,
+ onmousedown,
+ onmousemove,
+ onmouseout,
+ onmouseover,
+ onmouseup,
+ onhide,
+ onshow,
+ onbeforehide,
+ onbeforeshow
+ }
+
+ public HtmlTooltip() {
+ setRendererType("org.richfaces.Tooltip");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public String getStyle() {
+ return (String) getStateHelper().eval(PropertyKeys.style);
+ }
+
+ public void setStyle(String style) {
+ getStateHelper().put(PropertyKeys.style, style);
+ }
+
+ public String getStyleClass() {
+ return (String) getStateHelper().eval(PropertyKeys.styleClass);
+ }
+
+ public void setStyleClass(String styleClass) {
+ getStateHelper().put(PropertyKeys.styleClass, styleClass);
+ }
+
+ public int getZindex() {
+ return (Integer) getStateHelper().eval(PropertyKeys.zindex);
+ }
+
+ public void setZindex(int zindex) {
+ getStateHelper().put(PropertyKeys.zindex, zindex);
+ }
+
+ public String getOnclick() {
+ return (String) getStateHelper().eval(PropertyKeys.onclick);
+ }
+
+ public void setOnclick(String onclick) {
+ getStateHelper().put(PropertyKeys.onclick, onclick);
+ }
+
+ public String getOndblclick() {
+ return (String) getStateHelper().eval(PropertyKeys.ondblclick);
+ }
+
+ public void setOndblclick(String ondblclick) {
+ getStateHelper().put(PropertyKeys.ondblclick, ondblclick);
+ }
+
+ public String getOnmousedown() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousedown);
+ }
+
+ public void setOnmousedown(String onmousedown) {
+ getStateHelper().put(PropertyKeys.onmousedown, onmousedown);
+ }
+
+ public String getOnmousemove() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousemove);
+ }
+
+ public void setOnmousemove(String onmousemove) {
+ getStateHelper().put(PropertyKeys.onmousemove, onmousemove);
+ }
+
+ public String getOnmouseout() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseout);
+ }
+
+ public void setOnmouseout(String onmouseout) {
+ getStateHelper().put(PropertyKeys.onmouseout, onmouseout);
+ }
+
+ public String getOnmouseover() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseover);
+ }
+
+ public void setOnmouseover(String onmouseover) {
+ getStateHelper().put(PropertyKeys.onmouseover, onmouseover);
+ }
+
+ public String getOnmouseup() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseup);
+ }
+
+ public void setOnmouseup(String onmouseup) {
+ getStateHelper().put(PropertyKeys.onmouseup, onmouseup);
+ }
+
+ public String getOnhide() {
+ return (String) getStateHelper().eval(PropertyKeys.onhide);
+ }
+
+ public void setOnhide(String onhide) {
+ getStateHelper().put(PropertyKeys.onhide, onhide);
+ }
+
+ public String getOnshow() {
+ return (String) getStateHelper().eval(PropertyKeys.onshow);
+ }
+
+ public void setOnshow(String onshow) {
+ getStateHelper().put(PropertyKeys.onshow, onshow);
+ }
+
+ public String getOnbeforehide() {
+ return (String) getStateHelper().eval(PropertyKeys.onbeforehide);
+ }
+
+ public void setOnbeforehide(String onbeforehide) {
+ getStateHelper().put(PropertyKeys.onbeforehide, onbeforehide);
+ }
+
+ public String getOnbeforeshow() {
+ return (String) getStateHelper().eval(PropertyKeys.onbeforeshow);
+ }
+
+ public void setOnbeforeshow(String onbeforeshow) {
+ getStateHelper().put(PropertyKeys.onbeforeshow, onbeforeshow);
+ }
+
+
+
+ @Override
+ public Collection<String> getEventNames() {
+ return EVENT_NAMES;
+ }
+}
+
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-10-28 13:55:25 UTC (rev 19726)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -97,7 +97,11 @@
writer.startElement(HtmlConstants.DIV_ELEM, component);
writer.writeAttribute("id", component.getClientId(context), "clientId");
writer.writeAttribute("class", getStyleClass(component), null);
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, getStyle(component), null);
+ String style = getStyle(component);
+ if (style != null) {
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, style, null);
+ }
+
renderPassThroughAttributes(context, component, getPassThroughAttributes());
}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TooltipRenderer.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,216 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.richfaces.renderkit.html;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSObject;
+import org.richfaces.component.AbstractTooltip;
+import org.richfaces.component.html.HtmlTooltip;
+import org.richfaces.renderkit.HtmlConstants;
+import org.richfaces.renderkit.MetaComponentRenderer;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.richfaces.component.util.HtmlUtil.concatClasses;
+import static org.richfaces.renderkit.RenderKitUtils.renderPassThroughAttributes;
+import static org.richfaces.renderkit.html.TogglePanelRenderer.addEventOption;
+import static org.richfaces.renderkit.html.TogglePanelRenderer.getAjaxOptions;
+
+/**
+ * @author amarkhel
+ * @since 2010-10-24
+ */
+@ResourceDependencies( { // TODO review
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "jquery.position.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-event.js"),
+ @ResourceDependency(name = "richfaces-base-component.js"),
+ @ResourceDependency(library = "org.richfaces", name = "popup.js"),
+ @ResourceDependency(library = "org.richfaces", name = "Tooltip.js"),
+ @ResourceDependency(library = "org.richfaces", name = "tooltip.ecss") })
+public class TooltipRenderer extends DivPanelRenderer implements MetaComponentRenderer {
+
+ public static final String HIDE = "hide";
+ public static final String SHOW = "show";
+ public static final String BEFORE_HIDE = "beforehide";
+ public static final String BEFORE_SHOW = "beforeshow";
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ AbstractTooltip tooltip = (AbstractTooltip) component;
+
+ Map<String, String> requestMap =
+ context.getExternalContext().getRequestParameterMap();
+
+ String compClientId = component.getClientId(context);
+ String clientId = requestMap.get(compClientId);
+ if (clientId != null && clientId.equals(compClientId)) {
+ context.getPartialViewContext().getRenderIds().add(tooltip.getContentClientId(context));
+
+ //TODO nick - this should be done on encode, not on decode
+ addOnCompleteParam(tooltip.getClientId());
+ }
+ }
+
+ protected static void addOnCompleteParam(String tooltipId) {
+ AjaxContext.getCurrentInstance().appendOncomplete(new StringBuilder()
+ .append("RichFaces.$('").append(tooltipId).append("').onCompleteHandler();").toString());
+ }
+
+ @Override
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ AbstractTooltip tooltip = (AbstractTooltip) component;
+
+ writer.startElement(getMarkupElement(tooltip), component);
+ writer.writeAttribute("id", component.getClientId(context), "clientId");
+ writer.writeAttribute("class", getStyleClass(component), null);
+ String style = getStyle(component);
+ if (style != null && style.trim().length() > 0) {
+ writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, style, null);
+ }
+
+ renderPassThroughAttributes(context, component, getPassThroughAttributes());
+
+ writer.startElement(getMarkupElement(tooltip), component);
+ writer.writeAttribute("id", component.getClientId(context) + ":cntr", null);
+ writer.writeAttribute("class", "rf-tt-cntr", null);
+
+ encodeLoading(writer, context, tooltip);
+ encodeContentBegin(writer, context, tooltip);
+ }
+
+ private void encodeContentBegin(ResponseWriter writer, FacesContext context, AbstractTooltip tooltip) throws IOException {
+ writer.startElement(getMarkupElement(tooltip), tooltip);
+ writer.writeAttribute("id", tooltip.getClientId(context) + "@content", null);
+ writer.writeAttribute("class", "rf-tt-cnt", null);
+ }
+
+ private void encodeLoading(ResponseWriter writer, FacesContext context, AbstractTooltip tooltip) throws IOException {
+ writer.startElement(getMarkupElement(tooltip), tooltip);
+ writer.writeAttribute("id", tooltip.getClientId(context) + ":loading", null);
+ writer.writeAttribute("class", "rf-tt-loading", null);
+ writer.writeText("Loading...", null);
+ writer.endElement(getMarkupElement(tooltip));
+ }
+
+ private String getMarkupElement(AbstractTooltip component) {
+ switch (component.getLayout()) {
+ case block:
+ return HtmlConstants.DIV_ELEM;
+
+ case inline:
+ return HtmlConstants.SPAN_ELEM;
+
+ default:
+ throw new IllegalStateException("Unknown tooltip layout (=" + component.getLayout() + ")");
+ }
+ }
+
+ @Override
+ protected String getStyleClass(UIComponent component) {
+ return concatClasses("rf-tt", attributeAsString(component, "styleClass"));
+ }
+
+ @Override
+ protected JSObject getScriptObject(FacesContext context, UIComponent component) {
+ return new JSObject("RichFaces.ui.Tooltip",
+ component.getClientId(), getScriptObjectOptions(context, component));
+ }
+
+ @Override
+ protected Map<String, Object> getScriptObjectOptions(FacesContext context, UIComponent component) {
+ HtmlTooltip tooltip = (HtmlTooltip) component;
+
+ Map<String, Object> options = new HashMap<String, Object>();
+ options.put("ajax", getAjaxOptions(context, tooltip));
+ options.put("direction", tooltip.getDirection());
+ options.put("attached", tooltip.isAttached());
+ options.put("offset", getOffset(tooltip));
+ options.put("mode", tooltip.getMode());
+ options.put("disabled", tooltip.isDisabled());
+ options.put("hideDelay", tooltip.getHideDelay());
+ options.put("hideEvent", tooltip.getHideEvent());
+ options.put("showDelay", tooltip.getShowDelay());
+ options.put("showEvent", tooltip.getShowEvent());
+ options.put("followMouse", tooltip.isFollowMouse());
+
+ addEventOption(context, tooltip, options, HIDE);
+ addEventOption(context, tooltip, options, SHOW);
+ addEventOption(context, tooltip, options, BEFORE_HIDE);
+ addEventOption(context, tooltip, options, BEFORE_SHOW);
+
+ return options;
+ }
+
+ public Map<String, Object> getOffset(HtmlTooltip tooltip) {
+ Map<String, Object> options = new HashMap<String, Object>();
+ // TODO
+ return options;
+ }
+
+ private void encodeContentEnd(ResponseWriter writer, FacesContext context, AbstractTooltip tooltip) throws IOException {
+ writer.endElement(getMarkupElement(tooltip));
+ }
+
+ @Override
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ encodeContentEnd(writer, context, (AbstractTooltip) component);
+
+ writer.endElement(getMarkupElement((AbstractTooltip) component));
+
+ writeJavaScript(writer, context, component);
+
+ writer.endElement(getMarkupElement((AbstractTooltip) component));
+ }
+
+ public void encodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId) throws IOException {
+ if (AbstractTooltip.CONTENT_META_COMPONENT_ID.equals(metaComponentId)) {
+ AbstractTooltip tooltip = (AbstractTooltip) component;
+ ResponseWriter writer = context.getResponseWriter();
+
+ encodeContentBegin(writer, context, tooltip);
+ for (UIComponent child : tooltip.getChildren()) {
+ child.encodeAll(context);
+ }
+ encodeContentEnd(writer, context, tooltip);
+ }
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return AbstractTooltip.class;
+ }
+
+
+}
+
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-10-28 13:55:25 UTC (rev 19726)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-10-28 13:58:50 UTC (rev 19727)
@@ -11,6 +11,112 @@
</behavior>
<component>
+ <component-type>org.richfaces.Tooltip</component-type>
+ <component-class>org.richfaces.component.html.HtmlTooltip</component-class>
+ <property>
+ <description></description>
+ <property-name>for_</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>value</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>layout</property-name>
+ <property-class>org.richfaces.TooltipLayout</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>attached</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>direction</property-name>
+ <property-class>org.richfaces.TooltipDirection</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>disabled</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>followMouse</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>hideDelay</property-name>
+ <property-class>int</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>hideEvent</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>horizontalOffset</property-name>
+ <property-class>int</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>mode</property-name>
+ <property-class>org.richfaces.TooltipMode</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>showDelay</property-name>
+ <property-class>int</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>showEvent</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>verticalOffset</property-name>
+ <property-class>int</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>bypassUpdates</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>limitToList</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>data</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>status</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>execute</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>render</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+
+ </component>
+
+ <component>
<component-type>org.richfaces.CollapsiblePanel</component-type>
<component-class>org.richfaces.component.html.HtmlCollapsiblePanel</component-class>
<property>
@@ -666,6 +772,12 @@
<render-kit>
<render-kit-id>HTML_BASIC</render-kit-id>
<renderer>
+ <component-family>org.richfaces.Tooltip</component-family>
+ <renderer-type>org.richfaces.Tooltip</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.TooltipRenderer</renderer-class>
+ </renderer>
+
+ <renderer>
<component-family>org.richfaces.CollapsiblePanel</component-family>
<renderer-type>org.richfaces.CollapsiblePanel</renderer-type>
<renderer-class>org.richfaces.renderkit.html.CollapsiblePanelRenderer</renderer-class>
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-10-28 13:55:25 UTC (rev 19726)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-10-28 13:58:50 UTC (rev 19727)
@@ -52,6 +52,201 @@
<tag>
+ <tag-name>tooltip</tag-name>
+ <component>
+ <component-type>org.richfaces.Tooltip</component-type>
+ <renderer-type>org.richfaces.Tooltip</renderer-type>
+
+ </component>
+ <attribute>
+ <description></description>
+ <name>for_</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>value</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>layout</name>
+ <type>org.richfaces.TooltipLayout</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>attached</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>direction</name>
+ <type>org.richfaces.TooltipDirection</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>disabled</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>followMouse</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>hideDelay</name>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>hideEvent</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>horizontalOffset</name>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>mode</name>
+ <type>org.richfaces.TooltipMode</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>showDelay</name>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>showEvent</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>verticalOffset</name>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>id</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>binding</name>
+ <type>javax.faces.component.UIComponent</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>rendered</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>bypassUpdates</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>limitToList</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>data</name>
+ <type>java.lang.Object</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>status</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>execute</name>
+ <type>java.lang.Object</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>render</name>
+ <type>java.lang.Object</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>style</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>styleClass</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>zindex</name>
+ <type>int</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onclick</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>ondblclick</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmousedown</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmousemove</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmouseout</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmouseover</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmouseup</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onhide</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onshow</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onbeforehide</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onbeforeshow</name>
+ <type>java.lang.String</type>
+ </attribute>
+
+ </tag>
+
+ <tag>
<tag-name>collapsiblePanel</tag-name>
<component>
<component-type>org.richfaces.CollapsiblePanel</component-type>
Added: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/Tooltip.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/Tooltip.js (rev 0)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/Tooltip.js 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,284 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.TooltipDirection = {
+ topRight : "topRight",
+ topLeft : "topLeft",
+ bottomRight : "bottomRight",
+ bottomLeft : "bottomLeft",
+ auto : "auto",
+
+ DEFAULT: "bottomRight"
+ };
+ var TooltipDirection = rf.ui.TooltipDirection;
+
+ rf.ui.TooltipMode = {
+ client : "client",
+ ajax : "ajax",
+
+ DEFAULT: "client"
+ };
+ var TooltipMode = rf.ui.TooltipMode;
+
+ var DEFAULT_OPTIONS = {
+ direction : TooltipDirection.DEFAULT,
+ attached : true,
+ offset : [],
+ mode : TooltipMode.DEFAULT,
+ disabled : false,
+ hideDelay : 0,
+ hideEvent : "mouseleave",
+ showDelay : 0,
+ showEvent : "mouseenter",
+ followMouse : true
+ };
+
+ var SHOW_ACTION = {
+
+ /**
+ *
+ * @return {void}
+ * */
+ exec : function (tooltip, event) {
+ var mode = tooltip.mode;
+ if (mode == TooltipMode.ajax) {
+ return this.execAjax(tooltip, event);
+ } else if (mode == TooltipMode.client) {
+ return this.execClient(tooltip, event);
+ } else {
+ rf.log.error("SHOW_ACTION.exec : unknown mode (" + mode + ")");
+ }
+ },
+
+ /**
+ * @protected
+ *
+ * @return {Boolean} false
+ * */
+ execAjax : function (tooltip, event) {
+ tooltip.__loading().show();
+ tooltip.__content().hide();
+ tooltip.__show(event);
+
+ rf.ajax(tooltip.id, null, $.extend({}, tooltip.options["ajax"], {}));
+
+ return true;
+ },
+
+ /**
+ * @protected
+ *
+ * @return {undefined}
+ * - false - if process has been terminated
+ * - true - in other cases
+ * */
+ execClient : function (tooltip, event) {
+ tooltip.__show(event);
+
+ return tooltip.__fireShow();
+ }
+ };
+
+ rf.ui.Tooltip = rf.BaseComponent.extendClass({
+ // class name
+ name:"Tooltip",
+
+ /**
+ * @class Tooltip
+ * @name Tooltip
+ *
+ * @constructor
+ * @param {String} componentId - component id
+ * @param {Hash} options - params
+ * */
+ init : function (componentId, options) {
+ this.options = $.extend({}, DEFAULT_OPTIONS, this.options || {}, options || {});
+ this.attachToDom.call(this, componentId);
+
+ rf.ui.Tooltip.$super.constructor.call(this, componentId);
+
+ this.mode = TooltipMode.ajax;
+ this.options = options;
+
+ this.__addUserEventHandler("hide");
+ this.__addUserEventHandler("show");
+ this.__addUserEventHandler("beforehide");
+ this.__addUserEventHandler("beforeshow");
+
+ this.popup = new RichFaces.ui.Popup(this.id + ":cntr", {attachTo: "div", attachToBody: false, positionType: "TOOLTIP", positionOffset: [200,200]});
+
+ var tooltip = this;
+ function mouseMoveHandler(event) {
+ tooltip.popup.show(event);
+ }
+
+ $("#div").bind(this.options.showEvent, function (event) {
+ tooltip.show(event);
+
+ $("#div").bind("mousemove", mouseMoveHandler);
+ });
+
+ $("#div").bind(this.options.hideEvent, function (event) {
+ tooltip.hide();
+
+ $("#div").unbind("mousemove", mouseMoveHandler);
+ });
+
+ },
+
+ /***************************** Public Methods ****************************************************************/
+ /**
+ * @methodOf
+ * @name PanelMenuItem#hide
+ *
+ * TODO ...
+ *
+ * @return {void} TODO ...
+ */
+ hide: function () {
+ var continueProcess = this.__fireBeforeHide();
+ if (!continueProcess) {
+ return false;
+ }
+
+ this.__hide();
+
+ return this.__fireHide()
+ },
+
+ /**
+ * @private
+ * @return {void} TODO ...
+ */
+ __hide: function () {
+ var tooltip = this;
+ this.__delay(this.options.hideDelay, function () {
+ tooltip.popup.hide();
+ });
+ },
+
+ /**
+ * @methodOf
+ * @name PanelMenuItem#show
+ *
+ * TODO ...
+ *
+ * @return {void} TODO ...
+ */
+ show: function (event) {
+ var continueProcess = this.__fireBeforeShow();
+ if (!continueProcess) {
+ return false;
+ }
+
+ SHOW_ACTION.exec(this, event);
+ },
+
+ onCompleteHandler : function () {
+ this.__loading().hide();
+ this.__content().show();
+
+ return this.__fireShow();
+ },
+
+ /**
+ * @private
+ * @return {void} TODO ...
+ */
+ __show: function (event) {
+ var tooltip = this;
+ this.__delay(this.options.hideDelay, function () {
+ tooltip.popup.show(event);
+ });
+ },
+
+ /***************************** Private Methods ****************************************************************/
+ __delay : function (delay, action) {
+ if (delay > 0) {
+ var hidingTimerHandle = window.setTimeout(function() {
+ action();
+
+ if (hidingTimerHandle) {
+ window.clearTimeout(this.hidingTimerHandle);
+ hidingTimerHandle = undefined;
+ }
+ }, delay);
+ } else {
+ action();
+ }
+ },
+
+ __detectAncestorNode: function(leaf, element) {
+ // Return true if "element" is "leaf" or one of its parents
+ var node = leaf;
+ while (node != null && node != element) {
+ node = node.parentNode;
+ }
+ return (node != null);
+ },
+
+ __loading : function () {
+ return $(document.getElementById(this.id + ":loading"));
+ },
+
+ __content : function () {
+ return $(document.getElementById(this.id + "@content"));
+ },
+
+ __fireHide : function () {
+ return rf.Event.fireById(this.id, "hide", { id: this.id });
+ },
+
+ __fireShow : function () {
+ return rf.Event.fireById(this.id, "show", { id: this.id });
+ },
+
+ __fireBeforeHide : function () {
+ return rf.Event.fireById(this.id, "beforehide", { id: this.id });
+ },
+
+ __fireBeforeShow : function () {
+ return rf.Event.fireById(this.id, "beforeshow", { id: this.id });
+ },
+
+
+
+ /**
+ * @private
+ * */
+ __addUserEventHandler : function (name) {
+ var handler = this.options["on" + name];
+ if (handler) {
+ rf.Event.bindById(this.id, name, handler);
+ }
+ },
+
+ destroy: function () {
+ rf.ui.Tooltip.$super.destroy.call(this);
+ }
+ });
+})(jQuery, RichFaces);
Added: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.ecss
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.ecss (rev 0)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/tooltip.ecss 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+.rf-tt {
+ position: absolute;
+}
+
+.rf-tt-loading {
+
+}
+
+.rf-tt-cnt {
+
+}
+
+.rf-tt-cntr {
+ position: absolute;
+ display: none;
+}
\ No newline at end of file
Added: trunk/ui/output/ui/src/test/java/org/richfaces/component/UITooltipTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/component/UITooltipTest.java (rev 0)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/component/UITooltipTest.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.richfaces.component;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.faces.component.UIComponent;
+import java.util.List;
+
+/**
+ * @author amarkhel
+ * @since 2010-10-24
+ */
+public class UITooltipTest {
+
+ private UITooltip tooltip;
+
+ @Before
+ public void setUp () {
+ tooltip = new UITooltip();
+ }
+
+ @Test
+ public void testSomething() {
+ Assert.assertNotNull(tooltip);
+ }
+}
+
Modified: trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-10-28 13:55:25 UTC (rev 19726)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -51,7 +51,6 @@
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreComments(true);
-
}
protected HtmlUnitEnvironment environment;
@@ -85,7 +84,7 @@
Diff xmlDiff = new Diff(new StringReader(pageCode), new InputStreamReader(expectedPageCode));
xmlDiff.overrideDifferenceListener(new IgnoreScriptsContent());
- Assert.assertTrue("XML was not similar:" + xmlDiff.toString(), xmlDiff.similar());
+ Assert.assertTrue("XML was not similar:" + xmlDiff.toString() + "\n\n" + pageCode, xmlDiff.similar());
}
}
Added: trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/TooltipRendererTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/TooltipRendererTest.java (rev 0)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/TooltipRendererTest.java 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+package org.richfaces.renderkit.html;
+
+import org.junit.Test;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+
+ /**
+ * @author amarkhel
+ * @since 2010-10-24
+ */
+public class TooltipRendererTest extends RendererTestBase {
+
+ @Test
+ public void testDoEncode() throws IOException, SAXException {
+ doTest("tooltip", "f:tooltip");
+ }
+
+}
+
+
+
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xhtml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xhtml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xhtml 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,47 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright ${year}, Red Hat, Inc. and individual contributors
+ by the @authors tag. See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:fn="http://java.sun.com/jsp/jstl/functions"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:pn="http://richfaces.org/output"
+ xmlns:rich="http://richfaces.org/rich">
+
+ <h:head>
+ <title>Richfaces Tooltip Test</title>
+ </h:head>
+
+<h:body>
+ <h:form id="f" style="border:blue solid thin;">
+ <pn:tooltip id="tooltip">
+ <!-- TODO -->
+ </pn:tooltip>
+ </h:form>
+</h:body>
+</html>
+
+
Added: trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xmlunit.xml
===================================================================
--- trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xmlunit.xml (rev 0)
+++ trunk/ui/output/ui/src/test/resources/org/richfaces/renderkit/html/tooltip.xmlunit.xml 2010-10-28 13:58:50 UTC (rev 19727)
@@ -0,0 +1,9 @@
+<span id="f:tooltip" class="rf-tt">
+ <span id="f:tooltip:cntr" class="rf-tt-cntr">
+ <span id="f:tooltip:loading" class="rf-tt-loading">Loading...</span>
+ <span id="f:tooltip@content" class="rf-tt-cnt"></span>
+ </span>
+ <script type="text/javascript">
+ // Text
+ </script>
+</span>
14 years, 2 months
JBoss Rich Faces SVN: r19726 - trunk/ui/common/ui/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-28 09:55:25 -0400 (Thu, 28 Oct 2010)
New Revision: 19726
Modified:
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
Log:
add help method to get resource requestPath
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-10-28 12:34:46 UTC (rev 19725)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-10-28 13:55:25 UTC (rev 19726)
@@ -33,6 +33,8 @@
import java.util.Set;
import java.util.TreeSet;
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.behavior.ClientBehavior;
@@ -685,6 +687,16 @@
return sb.toString();
}
+
+ public static String getResourcePath(FacesContext context, String resourceName) {
+ if (resourceName != null) {
+ ResourceHandler resourceHandler = context.getApplication().getResourceHandler();
+ Resource resource = resourceHandler.createResource(resourceName);
+ return resource.getRequestPath();
+ }
+ return null;
+ }
+
@SuppressWarnings("serial")
public static final class Attributes extends TreeSet<ComponentAttribute> {
@@ -725,6 +737,8 @@
last.setDefaultValue(value);
return this;
}
+
+
}
14 years, 2 months
JBoss Rich Faces SVN: r19725 - in trunk/examples/richfaces-showcase/src/main/webapp/richfaces: inplaceInput and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-10-28 08:34:46 -0400 (Thu, 28 Oct 2010)
New Revision: 19725
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/inplaceInput.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/samples/inplaceInput-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceSelect/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceSelect/inplaceSelect.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceSelect/samples/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceSelect/samples/inplaceSelect-sample.xhtml
Removed:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/inplaceSelect.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/samples/inplaceSelect-sample.xhtml
Log:
reverted back erroneous commit and made corrections(both inplaces). Previously commited select folder rewritten input one because of SVN plugin error.
Copied: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/inplaceInput.xhtml (from rev 19692, trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/inplaceInput.xhtml)
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/inplaceInput.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/inplaceInput.xhtml 2010-10-28 12:34:46 UTC (rev 19725)
@@ -0,0 +1,20 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p>InplaceInput is a simple input component which displays the current value as outputText and switches to inputText based representation after a defined event to allow editing this value.
+You could use simplest examples below. For the first demo, just click on a label to edit the value and click somewhere outside the component to store this value(Or just press ENTER button).</p>
+
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+</ui:composition>
+
+</html>
\ No newline at end of file
Deleted: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/inplaceSelect.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/inplaceSelect.xhtml 2010-10-28 12:08:05 UTC (rev 19724)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/inplaceSelect.xhtml 2010-10-28 12:34:46 UTC (rev 19725)
@@ -1,21 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets">
-
-<ui:composition>
- <p><b>Inplace</b> Select is a simple input component which displays current
- value as outputText and switches to Select based representation after a
- defined event to allow editing this value.</p>
-
- <ui:include src="#{demoNavigator.sampleIncludeURI}" />
- <ui:include src="/templates/includes/source-view.xhtml">
- <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
- <ui:param name="sourceType" value="xhtml" />
- <ui:param name="openLabel" value="View Source" />
- <ui:param name="hideLabel" value="Hide Source" />
- </ui:include>
-</ui:composition>
-
-</html>
\ No newline at end of file
Copied: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/samples/inplaceInput-sample.xhtml (from rev 19692, trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/samples/inplaceInput-sample.xhtml)
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/samples/inplaceInput-sample.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/samples/inplaceInput-sample.xhtml 2010-10-28 12:34:46 UTC (rev 19725)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+ <rich:panel style="width:220px;">
+ <f:facet name="header">
+ <h:outputText value="Person Info"></h:outputText>
+ </f:facet>
+ <h:panelGrid columns="2">
+ <h:outputText value="Name: " />
+ <rich:inplaceInput value="click to enter your name" />
+ <h:outputText value="Email:" />
+ <rich:inplaceInput value="click to enter your email" />
+ </h:panelGrid>
+ </rich:panel>
+</ui:composition>
\ No newline at end of file
Deleted: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/samples/inplaceSelect-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/samples/inplaceSelect-sample.xhtml 2010-10-28 12:08:05 UTC (rev 19724)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceInput/samples/inplaceSelect-sample.xhtml 2010-10-28 12:34:46 UTC (rev 19725)
@@ -1,44 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<ui:composition xmlns="http://www.w3.org/1999/xhtml"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich">
- <h:form>
- <p>Try the simplest example below. Just click on a label to edit
- the value and click somewhere outside the component to store this
- value(Or just press ENTER button).</p>
- <rich:panel style="width:220px;">
- <f:facet name="header">
- <h:outputText value="Simples select"></h:outputText>
- </f:facet>
- <rich:inplaceSelect defaultLabel="Click here to edit"
- openOnEdit="true" saveOnBlur="false">
- <f:selectItem itemValue="0" itemLabel="Option 1" />
- <f:selectItem itemValue="1" itemLabel="Option 2" />
- <f:selectItem itemValue="2" itemLabel="Option 3" />
- <f:selectItem itemValue="3" itemLabel="Option 4" />
- <f:selectItem itemValue="4" itemLabel="Option 5" />
- </rich:inplaceSelect>
- </rich:panel>
- <p>In that sample component customized in next way:
- </p>
- <ul>
- <li><b>f:selectItems</b> tag is used to define a list of items to use.</li>
- <li>Controls "save" and "cancel" are turned on with <b>showControls</b> attribute</li>
- <li><b>editEvent</b> set to dblclick and used to switch to edit state.</li>
- </ul>
- <rich:panel style="width:220px;">
- <f:facet name="header">
- <h:outputText value="Select customization"></h:outputText>
- </f:facet>
- <rich:inplaceSelect editEvent="dblclick" id="inplaceSelect"
- showControls="true" saveOnBlur="true"
- value="#{inplaceSelectBean.value}" defaultLabel="Double click to edit value"
- openOnEdit="true">
- <f:selectItems value="#{inplaceSelectBean.capitalsOptions}" />
- </rich:inplaceSelect>
- </rich:panel>
- </h:form>
-</ui:composition>
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceSelect/inplaceSelect.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceSelect/inplaceSelect.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceSelect/inplaceSelect.xhtml 2010-10-28 12:34:46 UTC (rev 19725)
@@ -0,0 +1,21 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p><b>Inplace</b> Select is a simple input component which displays current
+ value as outputText and switches to Select based representation after a
+ defined event to allow editing this value.</p>
+
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+</ui:composition>
+
+</html>
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceSelect/samples/inplaceSelect-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceSelect/samples/inplaceSelect-sample.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/inplaceSelect/samples/inplaceSelect-sample.xhtml 2010-10-28 12:34:46 UTC (rev 19725)
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+ <h:form>
+ <p>Try the simplest example below. Just click on a label to edit
+ the value and click somewhere outside the component to store this
+ value(Or just press ENTER button).</p>
+ <rich:panel style="width:220px;">
+ <f:facet name="header">
+ <h:outputText value="Simples select"></h:outputText>
+ </f:facet>
+ <rich:inplaceSelect defaultLabel="Click here to edit"
+ openOnEdit="true" saveOnBlur="false">
+ <f:selectItem itemValue="0" itemLabel="Option 1" />
+ <f:selectItem itemValue="1" itemLabel="Option 2" />
+ <f:selectItem itemValue="2" itemLabel="Option 3" />
+ <f:selectItem itemValue="3" itemLabel="Option 4" />
+ <f:selectItem itemValue="4" itemLabel="Option 5" />
+ </rich:inplaceSelect>
+ </rich:panel>
+ <p>In that sample component customized in next way:
+ </p>
+ <ul>
+ <li><b>f:selectItems</b> tag is used to define a list of items to use.</li>
+ <li>Controls "save" and "cancel" are turned on with <b>showControls</b> attribute</li>
+ <li><b>editEvent</b> set to dblclick and used to switch to edit state.</li>
+ </ul>
+ <rich:panel style="width:220px;">
+ <f:facet name="header">
+ <h:outputText value="Select customization"></h:outputText>
+ </f:facet>
+ <rich:inplaceSelect editEvent="dblclick" id="inplaceSelect"
+ showControls="true" saveOnBlur="true"
+ value="#{inplaceSelectBean.value}" defaultLabel="Double click to edit value"
+ openOnEdit="true">
+ <f:selectItems value="#{inplaceSelectBean.capitalsOptions}" />
+ </rich:inplaceSelect>
+ </rich:panel>
+ </h:form>
+</ui:composition>
\ No newline at end of file
14 years, 2 months
JBoss Rich Faces SVN: r19724 - in trunk/ui/input/ui/src: test/resources/org/richfaces/renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-28 08:08:05 -0400 (Thu, 28 Oct 2010)
New Revision: 19724
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.ecss
trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestDefault.xmlunit.xml
trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestEdit.xmlunit.xml
trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestWithControls.xmlunit.xml
Log:
fix test, add styles for fonts
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss 2010-10-28 10:59:38 UTC (rev 19723)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss 2010-10-28 12:08:05 UTC (rev 19724)
@@ -10,8 +10,9 @@
margin : 0px;
width : 100%;
height : 100%;
- font-family:inherit;
- font-size : inherit;
+ color: '#{richSkin.generalTextColor}';
+ font-family: '#{richSkin.generalFamilyFont}';
+ font-size : '#{richSkin.generalSizeFont}';
}
.rf-ii-edit {
@@ -27,6 +28,9 @@
.rf-ii-lbl {
white-space : nowrap;
+ color: '#{richSkin.generalTextColor}';
+ font-family: '#{richSkin.generalFamilyFont}';
+ font-size : '#{richSkin.generalSizeFont}';
}
.rf-ii-d-s {
@@ -62,6 +66,9 @@
margin : 0px;
width : 100%;
height : 100%
+ color: '#{richSkin.generalTextColor}';
+ font-family: '#{richSkin.generalFamilyFont}';
+ font-size : '#{richSkin.generalSizeFont}';
}
.rf-ii-strut {
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss 2010-10-28 10:59:38 UTC (rev 19723)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss 2010-10-28 12:08:05 UTC (rev 19724)
@@ -1,3 +1,9 @@
+.rf-is-fld, .rf-is-opt, .rf-is-lbl {
+ color: '#{richSkin.generalTextColor}';
+ font-family: '#{richSkin.generalFamilyFont}';
+ font-size : '#{richSkin.generalSizeFont}';
+}
+
input.rf-is-fld {
background : '#{richSkin.editBackgroundColor}';
padding : 0px 0px 0px 0px;
@@ -7,8 +13,9 @@
background-image:"url(#{resource['org.richfaces:mark_list.gif']})";
background-position : center right;
background-repeat : no-repeat;
- font-family:inherit;
- font-size : inherit;
+ color: '#{richSkin.generalTextColor}';
+ font-family: '#{richSkin.generalFamilyFont}';
+ font-size : '#{richSkin.generalSizeFont}';
}
.rf-is-none {
@@ -99,10 +106,10 @@
.rf-is-lst-cord {
display : block;
- /*font-size : 0px;*/
position : relative;
- font-family:inherit;
- font-size : inherit;
+ color: '#{richSkin.generalTextColor}';
+ font-family: '#{richSkin.generalFamilyFont}';
+ font-size : '#{richSkin.generalSizeFont}';
}
.rf-is-lst-pos {
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.ecss
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.ecss 2010-10-28 10:59:38 UTC (rev 19723)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.ecss 2010-10-28 12:08:05 UTC (rev 19724)
@@ -1,5 +1,5 @@
-.rf-sel-inp.rf-s-fnt, .rf-sel-opt.rf-sel-fnt{
+.rf-sel-inp, .rf-sel-opt {
color: '#{richSkin.generalTextColor}';
font-size: '#{richSkin.generalSizeFont}';
font-family: '#{richSkin.generalFamilyFont}';
Modified: trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestDefault.xmlunit.xml
===================================================================
--- trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestDefault.xmlunit.xml 2010-10-28 10:59:38 UTC (rev 19723)
+++ trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestDefault.xmlunit.xml 2010-10-28 12:08:05 UTC (rev 19724)
@@ -17,16 +17,17 @@
<span class="rf-is-shdw-r"></span>
<span class="rf-is-shdw-b"></span>
<span class="rf-is-lst-dec">
- <span class="rf-is-lst-scrl" id="form:inplaceSelectDefaultItems"
- style="height: 100px">
- <span id="form:inplaceSelectDefaultItem0" class="rf-is-opt">Label#1
+ <span class="rf-is-lst-scrl" style="height: 100px">
+ <span id="form:inplaceSelectDefaultItems">
+ <span id="form:inplaceSelectDefaultItem0" class="rf-is-opt">Label#1
+ </span>
+ <span id="form:inplaceSelectDefaultItem1" class="rf-is-opt">Label#2
+ </span>
+ <span id="form:inplaceSelectDefaultItem2" class="rf-is-opt">Label#3
+ </span>
+ <span id="form:inplaceSelectDefaultItem3" class="rf-is-opt">Label#4
+ </span>
</span>
- <span id="form:inplaceSelectDefaultItem1" class="rf-is-opt">Label#2
- </span>
- <span id="form:inplaceSelectDefaultItem2" class="rf-is-opt">Label#3
- </span>
- <span id="form:inplaceSelectDefaultItem3" class="rf-is-opt">Label#4
- </span>
</span>
</span>
</span>
Modified: trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestEdit.xmlunit.xml
===================================================================
--- trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestEdit.xmlunit.xml 2010-10-28 10:59:38 UTC (rev 19723)
+++ trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestEdit.xmlunit.xml 2010-10-28 12:08:05 UTC (rev 19724)
@@ -40,12 +40,17 @@
<span class="rf-is-shdw-r"></span>
<span class="rf-is-shdw-b"></span>
<span class="rf-is-lst-dec">
- <span class="rf-is-lst-scrl" id="form:inplaceSelectEditItems"
- style="height: 100px">
- <span id="form:inplaceSelectEditItem0" class="rf-is-opt">Label#1</span>
- <span id="form:inplaceSelectEditItem1" class="rf-is-opt">Label#2</span>
- <span id="form:inplaceSelectEditItem2" class="rf-is-opt">Label#3</span>
- <span id="form:inplaceSelectEditItem3" class="rf-is-opt">Label#4</span>
+ <span class="rf-is-lst-scrl" style="height: 100px">
+ <span id="form:inplaceSelectEditItems">
+ <span id="form:inplaceSelectEditItem0" class="rf-is-opt">Label#1
+ </span>
+ <span id="form:inplaceSelectEditItem1" class="rf-is-opt">Label#2
+ </span>
+ <span id="form:inplaceSelectEditItem2" class="rf-is-opt">Label#3
+ </span>
+ <span id="form:inplaceSelectEditItem3" class="rf-is-opt">Label#4
+ </span>
+ </span>
</span>
</span>
</span>
Modified: trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestWithControls.xmlunit.xml
===================================================================
--- trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestWithControls.xmlunit.xml 2010-10-28 10:59:38 UTC (rev 19723)
+++ trunk/ui/input/ui/src/test/resources/org/richfaces/renderkit/inplaceSelectTestWithControls.xmlunit.xml 2010-10-28 12:08:05 UTC (rev 19724)
@@ -41,16 +41,17 @@
<span class="rf-is-shdw-r"></span>
<span class="rf-is-shdw-b"></span>
<span class="rf-is-lst-dec">
- <span class="rf-is-lst-scrl" id="form:inplaceSelectWithControlsItems"
- style="height: 100px">
- <span id="form:inplaceSelectWithControlsItem0" class="rf-is-opt">Label#1
+ <span class="rf-is-lst-scrl" style="height: 100px">
+ <span id="form:inplaceSelectWithControlsItems">
+ <span id="form:inplaceSelectWithControlsItem0" class="rf-is-opt">Label#1
+ </span>
+ <span id="form:inplaceSelectWithControlsItem1" class="rf-is-opt">Label#2
+ </span>
+ <span id="form:inplaceSelectWithControlsItem2" class="rf-is-opt">Label#3
+ </span>
+ <span id="form:inplaceSelectWithControlsItem3" class="rf-is-opt">Label#4
+ </span>
</span>
- <span id="form:inplaceSelectWithControlsItem1" class="rf-is-opt">Label#2
- </span>
- <span id="form:inplaceSelectWithControlsItem2" class="rf-is-opt">Label#3
- </span>
- <span id="form:inplaceSelectWithControlsItem3" class="rf-is-opt">Label#4
- </span>
</span>
</span>
</span>
@@ -58,6 +59,6 @@
</span>
</span>
<script type="text/javascript">
- // ignored
+ //ignore
</script>
</span>
\ No newline at end of file
14 years, 2 months
JBoss Rich Faces SVN: r19723 - trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-28 06:59:38 -0400 (Thu, 28 Oct 2010)
New Revision: 19723
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
Log:
remove debug info
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-28 10:51:49 UTC (rev 19722)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-28 10:59:38 UTC (rev 19723)
@@ -158,10 +158,7 @@
__scrollToSelectedItem : function() {
if(this.scrollContainer) {
var offset = 0;
- if(this.index > 5) {
- var test = 5;
- }
-
+
this.items.slice(0, this.index).each(function() {
offset += this.offsetHeight;
});
14 years, 2 months
JBoss Rich Faces SVN: r19722 - in trunk/ui/input/ui/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-28 06:51:49 -0400 (Thu, 28 Oct 2010)
New Revision: 19722
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
trunk/ui/input/ui/src/main/templates/select.template.xml
Log:
add scroll support for the selects
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-10-28 08:16:52 UTC (rev 19721)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-10-28 10:51:49 UTC (rev 19722)
@@ -4,8 +4,10 @@
rf.ui.InplaceSelect = function(id, options) {
var mergedOptions = $.extend({}, defaultOptions, options);
- $super.constructor.call(this, id, mergedOptions)
- mergedOptions['attachTo'] = id;
+ $super.constructor.call(this, id, mergedOptions)
+
+ mergedOptions['attachTo'] = id;
+ mergedOptions['scrollContainer'] = $(document.getElementById(id + "Items")).parent()[0];
this.popupList = new rf.ui.PopupList(id+"List", this, mergedOptions);
this.items = mergedOptions.items;
this.selValueInput = $(document.getElementById(id+"selValue"));
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-28 08:16:52 UTC (rev 19721)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-28 10:51:49 UTC (rev 19722)
@@ -7,6 +7,7 @@
$super.constructor.call(this, id, mergedOptions);
this.selectListener = listener;
this.selectItemCss = mergedOptions.selectItemCss;
+ this.scrollContainer = $(mergedOptions.scrollContainer);
this.itemCss = mergedOptions.itemCss;
this.listCss = mergedOptions.listCss;
this.index = -1;
@@ -44,6 +45,7 @@
} else {
item.addClass(this.selectItemCss);
}
+ this.__scrollToSelectedItem(this);
},
unselectItem: function(item) {
@@ -151,8 +153,30 @@
__setItems: function(items) {
this.items = items;
+ },
+
+ __scrollToSelectedItem : function() {
+ if(this.scrollContainer) {
+ var offset = 0;
+ if(this.index > 5) {
+ var test = 5;
+ }
+
+ this.items.slice(0, this.index).each(function() {
+ offset += this.offsetHeight;
+ });
+
+ var parentContainer = this.scrollContainer;
+ if(offset < parentContainer.scrollTop()) {
+ parentContainer.scrollTop(offset);
+ } else {
+ offset+=this.items.get(this.index).offsetHeight;
+ if(offset - parentContainer.scrollTop() > parentContainer.get(0).clientHeight) {
+ parentContainer.scrollTop(offset - parentContainer.innerHeight());
+ }
+ }
+ }
}
-
}
})());
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-10-28 08:16:52 UTC (rev 19721)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-10-28 10:51:49 UTC (rev 19722)
@@ -115,7 +115,8 @@
this.id = id;
var mergedOptions = $.extend({}, defaultOptions, options);
mergedOptions['attachTo'] = id;
-
+ mergedOptions['scrollContainer'] = $(document.getElementById(id + "Items")).parent()[0];
+
this.defaultLabel = mergedOptions.defaultLabel;
var inputLabel = this.getValue() ;
this.initialValue = (inputLabel != this.defaultLabel) ? inputLabel : "";
Modified: trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-10-28 08:16:52 UTC (rev 19721)
+++ trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-10-28 10:51:49 UTC (rev 19722)
@@ -87,8 +87,10 @@
<span class="rf-is-shdw-r"></span>
<span class="rf-is-shdw-b"></span>
<span class="rf-is-lst-dec">
- <span class="rf-is-lst-scrl" id="#{clientId}Items" style="height: #{component.attributes['listHeight']}">
- <cdk:call expression="encodeItems(facesContext, component, clientSelectItems);"/>
+ <span class="rf-is-lst-scrl" style="height: #{component.attributes['listHeight']}">
+ <span id="#{clientId}Items">
+ <cdk:call expression="encodeItems(facesContext, component, clientSelectItems);"/>
+ </span>
</span>
</span>
</span>
Modified: trunk/ui/input/ui/src/main/templates/select.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/select.template.xml 2010-10-28 08:16:52 UTC (rev 19721)
+++ trunk/ui/input/ui/src/main/templates/select.template.xml 2010-10-28 10:51:49 UTC (rev 19722)
@@ -54,8 +54,10 @@
<div class="rf-sel-shdw-b"></div>
<div class="rf-sel-lst-dcrtn">
- <div class="rf-sel-lst-scrl" id="#{clientId}Items" >
- <cdk:call expression="encodeItems(facesContext, component, clientSelectItems);"/>
+ <div class="rf-sel-lst-scrl">
+ <div id="#{clientId}Items" >
+ <cdk:call expression="encodeItems(facesContext, component, clientSelectItems);"/>
+ </div>
</div>
</div>
</div>
14 years, 2 months
JBoss Rich Faces SVN: r19721 - trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-10-28 04:16:52 -0400 (Thu, 28 Oct 2010)
New Revision: 19721
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
Log:
add 'mouseover', 'click' handlers which was removed from popup base class
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-28 00:20:19 UTC (rev 19720)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-28 08:16:52 UTC (rev 19721)
@@ -5,11 +5,14 @@
rf.ui.PopupList = function(id, listener, options) {
var mergedOptions = $.extend({}, defaultOptions, options);
$super.constructor.call(this, id, mergedOptions);
- this.selectListener = listener;
+ this.selectListener = listener;
this.selectItemCss = mergedOptions.selectItemCss;
this.itemCss = mergedOptions.itemCss;
this.listCss = mergedOptions.listCss;
this.index = -1;
+ this.popup.bind("mouseover", $.proxy(this.__onMouseOver, this));
+ this.popup.bind("click", $.proxy(this.__onClick, this));
+
this.__updateItemsList();
};
14 years, 2 months
JBoss Rich Faces SVN: r19720 - in branches/RF-8742/ui/validator/impl/src: main/java/org/richfaces/validator and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-10-27 20:20:19 -0400 (Wed, 27 Oct 2010)
New Revision: 19720
Added:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/BaseFacesObjectDescriptor.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesServiceBase.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesValidatorDescriptor.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/FacesValidatorServiceTest.java
Modified:
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterDescriptorImpl.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterServiceImpl.java
Log:
RESOLVED - issue RF-9519: FacesValidatorService tests and implementation
https://jira.jboss.org/browse/RF-9519
Modified: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java 2010-10-27 23:57:24 UTC (rev 19719)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java 2010-10-28 00:20:19 UTC (rev 19720)
@@ -28,6 +28,8 @@
import org.richfaces.validator.BeanValidator;
import org.richfaces.validator.ConverterServiceImpl;
import org.richfaces.validator.FacesConverterService;
+import org.richfaces.validator.FacesValidatorService;
+import org.richfaces.validator.FacesValidatorServiceImpl;
import org.richfaces.validator.NullValidator;
import org.richfaces.validator.ObjectValidator;
@@ -47,8 +49,9 @@
* @see org.richfaces.application.Module#configure(org.richfaces.application.ServicesFactory)
*/
public void configure(ServicesFactory factory) {
- factory.setInstance(ObjectValidator.class, createInstance());
+ factory.setInstance(ObjectValidator.class, createObjectValidator());
factory.setInstance(FacesConverterService.class, new ConverterServiceImpl());
+ factory.setInstance(FacesValidatorService.class, new FacesValidatorServiceImpl());
}
/**
@@ -56,7 +59,7 @@
*
* @return
*/
- static ObjectValidator createInstance() {
+ static ObjectValidator createObjectValidator() {
ObjectValidator validator = null;
try {
validator = new BeanValidator();
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/BaseFacesObjectDescriptor.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/BaseFacesObjectDescriptor.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/BaseFacesObjectDescriptor.java 2010-10-28 00:20:19 UTC (rev 19720)
@@ -0,0 +1,42 @@
+package org.richfaces.validator;
+
+import java.util.Map;
+
+import javax.faces.application.FacesMessage;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+public class BaseFacesObjectDescriptor<T> {
+
+ private final Class<? extends T> converterClass;
+ private Map<String, Object> parameters = Maps.newHashMap();
+ private final FacesMessage message;
+
+
+ public BaseFacesObjectDescriptor(Class<? extends T> converterClass, FacesMessage message) {
+ this.converterClass = converterClass;
+ this.message = message;
+ }
+
+ public Class<?> getImplementationClass() {
+ return converterClass;
+ }
+
+ public Map<String, ? extends Object> getAdditionalParameters() {
+ return parameters;
+ }
+
+ public FacesMessage getMessage() {
+ return message;
+ }
+
+ protected void addParameter(String name, Object value) {
+ parameters.put(name, value);
+ }
+
+ protected void makeImmutable() {
+ parameters = ImmutableMap.copyOf(parameters);
+ }
+
+}
\ No newline at end of file
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/BaseFacesObjectDescriptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterDescriptorImpl.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterDescriptorImpl.java 2010-10-27 23:57:24 UTC (rev 19719)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterDescriptorImpl.java 2010-10-28 00:20:19 UTC (rev 19720)
@@ -3,59 +3,20 @@
*/
package org.richfaces.validator;
-import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.convert.Converter;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
/**
* @author asmirnov
*
*/
-public class ConverterDescriptorImpl implements ConverterDescriptor {
+public class ConverterDescriptorImpl extends BaseFacesObjectDescriptor<Converter> implements ConverterDescriptor {
- private final Class<? extends Converter> converterClass;
-
- private Map<String, Object> parameters = Maps.newHashMap();
-
- private final FacesMessage message;
-
ConverterDescriptorImpl(Class<? extends Converter> converterClass,FacesMessage message) {
- this.converterClass = converterClass;
- this.message = message;
-
+ super(converterClass,message);
}
- /* (non-Javadoc)
- * @see org.richfaces.validator.FacesObjectDescriptor#getImplementationClass()
- */
- public Class<?> getImplementationClass() {
- return converterClass;
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.validator.FacesObjectDescriptor#getAdditionalParameters()
- */
- public Map<String, ? extends Object> getAdditionalParameters() {
- return parameters;
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.validator.FacesObjectDescriptor#getMessage()
- */
- public FacesMessage getMessage() {
- return message;
- }
-
- void addParameter(String name, Object value){
- parameters.put(name, value);
- }
- void makeImmutable(){
- parameters = ImmutableMap.copyOf(parameters);
- }
-
}
Modified: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterServiceImpl.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterServiceImpl.java 2010-10-27 23:57:24 UTC (rev 19719)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterServiceImpl.java 2010-10-28 00:20:19 UTC (rev 19720)
@@ -3,11 +3,6 @@
*/
package org.richfaces.validator;
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIInput;
@@ -27,18 +22,15 @@
import javax.faces.convert.NumberConverter;
import javax.faces.convert.ShortConverter;
-import com.google.common.collect.ImmutableSet;
/**
* @author asmirnov
*
*/
-public class ConverterServiceImpl implements FacesConverterService {
+public class ConverterServiceImpl extends FacesServiceBase<Converter> implements FacesConverterService {
private static final String DEFAULT_CONVERTER_MESSAGE_ID = UIInput.CONVERSION_MESSAGE_ID;
- private static final ImmutableSet<String> HIDDEN_PROPERTIES = ImmutableSet.of("class", "transient");
-
/*
* (non-Javadoc)
*
@@ -47,53 +39,15 @@
*/
public ConverterDescriptor getConverterDescription(FacesContext context, Converter converter) {
// determine converter message.
- FacesMessage message = getConverterMessage(context, converter);
+ FacesMessage message = getMessage(context, converter);
ConverterDescriptorImpl descriptor = new ConverterDescriptorImpl(converter.getClass(), message);
- fillConverterParameters(descriptor, converter);
+ fillParameters(descriptor, converter);
descriptor.makeImmutable();
return descriptor;
}
- private void fillConverterParameters(ConverterDescriptorImpl descriptor, Converter converter) {
- // get bean attributes for converter, put them into parameters.
- try {
- BeanInfo beanInfo = Introspector.getBeanInfo(converter.getClass());
- PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
- for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
- String name = propertyDescriptor.getName();
- if (!HIDDEN_PROPERTIES.contains(name)) {
- try {
- Object value = propertyDescriptor.getReadMethod().invoke(converter);
- if (null != value) {
- descriptor.addParameter(name, value);
- }
- } catch (IllegalArgumentException e) {
- // Ignore
- } catch (IllegalAccessException e) {
- // Ignore
- } catch (InvocationTargetException e) {
- // Ignore
- }
- }
- }
- } catch (IntrospectionException e) {
- // Ignore.
- }
- }
-
- /**
- * Creates message for converter, using current locale.
- *
- * @param context
- * @param converter
- * @return
- */
- private FacesMessage getConverterMessage(FacesContext context, Converter converter) {
- String messageId = getMessageId(converter);
- return MessageFactory.createMessage(context, messageId);
- }
-
- private String getMessageId(Converter converter) {
+ @Override
+ protected String getMessageId(Converter converter) {
String messageId;
if (converter instanceof BigDecimalConverter) {
messageId = BigDecimalConverter.DECIMAL_ID;
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesServiceBase.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesServiceBase.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesServiceBase.java 2010-10-28 00:20:19 UTC (rev 19720)
@@ -0,0 +1,60 @@
+package org.richfaces.validator;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+
+import com.google.common.collect.ImmutableSet;
+
+public abstract class FacesServiceBase<T> {
+
+ private static final ImmutableSet<String> HIDDEN_PROPERTIES = ImmutableSet.of("class", "transient");
+
+ protected abstract String getMessageId(T component);
+
+
+ protected void fillParameters(BaseFacesObjectDescriptor<T> descriptor, T component) {
+ // get bean attributes for converter, put them into parameters.
+ try {
+ BeanInfo beanInfo = Introspector.getBeanInfo(component.getClass());
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
+ String name = propertyDescriptor.getName();
+ if (!HIDDEN_PROPERTIES.contains(name)) {
+ try {
+ Object value = propertyDescriptor.getReadMethod().invoke(component);
+ if (null != value) {
+ descriptor.addParameter(name, value);
+ }
+ } catch (IllegalArgumentException e) {
+ // Ignore
+ } catch (IllegalAccessException e) {
+ // Ignore
+ } catch (InvocationTargetException e) {
+ // Ignore
+ }
+ }
+ }
+ } catch (IntrospectionException e) {
+ // Ignore.
+ }
+ }
+
+ /**
+ * Creates message for converter, using current locale.
+ *
+ * @param context
+ * @param component
+ * @return
+ */
+ protected FacesMessage getMessage(FacesContext context, T component) {
+ String messageId = getMessageId(component);
+ return MessageFactory.createMessage(context, messageId);
+ }
+
+}
\ No newline at end of file
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesServiceBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesValidatorDescriptor.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesValidatorDescriptor.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesValidatorDescriptor.java 2010-10-28 00:20:19 UTC (rev 19720)
@@ -0,0 +1,12 @@
+package org.richfaces.validator;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.validator.Validator;
+
+public class FacesValidatorDescriptor extends BaseFacesObjectDescriptor<Validator> implements ValidatorDescriptor {
+
+ public FacesValidatorDescriptor(Class<? extends Validator> validatorClass, FacesMessage message) {
+ super(validatorClass, message);
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesValidatorDescriptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java 2010-10-28 00:20:19 UTC (rev 19720)
@@ -0,0 +1,55 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.DoubleRangeValidator;
+import javax.faces.validator.LengthValidator;
+import javax.faces.validator.LongRangeValidator;
+import javax.faces.validator.RegexValidator;
+import javax.faces.validator.RequiredValidator;
+import javax.faces.validator.Validator;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class FacesValidatorServiceImpl extends FacesServiceBase<Validator> implements FacesValidatorService {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.validator.FacesValidatorService#getValidatorDescription(javax.faces.context.FacesContext,
+ * javax.faces.validator.Validator)
+ */
+ public ValidatorDescriptor getValidatorDescription(FacesContext context, Validator validator) {
+ FacesMessage message = getMessage(context, validator);
+ FacesValidatorDescriptor descriptor = new FacesValidatorDescriptor(validator.getClass(), message);
+ fillParameters(descriptor, validator);
+ descriptor.makeImmutable();
+ return descriptor;
+ }
+
+ @Override
+ protected String getMessageId(Validator component) {
+ String messageId;
+ if (component instanceof DoubleRangeValidator) {
+ messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
+ } else if (component instanceof LengthValidator) {
+ messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
+ } else if (component instanceof LongRangeValidator) {
+ messageId = LongRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
+ } else if (component instanceof RegexValidator) {
+ messageId = RegexValidator.NOT_MATCHED_MESSAGE_ID;
+ } else if (component instanceof RequiredValidator) {
+ messageId = UIInput.REQUIRED_MESSAGE_ID;
+ } else {
+ messageId = UIInput.UPDATE_MESSAGE_ID;
+ }
+ return messageId;
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/FacesValidatorServiceTest.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/FacesValidatorServiceTest.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/FacesValidatorServiceTest.java 2010-10-28 00:20:19 UTC (rev 19720)
@@ -0,0 +1,88 @@
+package org.richfaces.validator;
+
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.HashMap;
+import java.util.Locale;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIViewRoot;
+import javax.faces.validator.LengthValidator;
+import javax.faces.validator.RequiredValidator;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+import org.jboss.test.faces.mock.Environment;
+import org.jboss.test.faces.mock.Environment.Feature;
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockController;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+(a)RunWith(MockTestRunner.class)
+public class FacesValidatorServiceTest {
+
+ @Mock()
+ @Environment({ Feature.APPLICATION })
+ protected MockFacesEnvironment environment;
+ protected FacesValidatorService serviceImpl;
+ @Mock
+ protected UIViewRoot viewRoot;
+ @Mock
+ protected UIInput input;
+ protected MockController controller;
+ protected Validator validator;
+
+
+ @Before
+ public void setUp() {
+ // create service impl.
+ serviceImpl = new FacesValidatorServiceImpl();
+ expect(environment.getFacesContext().getViewRoot()).andStubReturn(viewRoot);
+ expect(viewRoot.getLocale()).andStubReturn(Locale.ENGLISH);
+ expect(environment.getApplication().getMessageBundle()).andStubReturn("com.sun.faces.resources.Messages");
+ HashMap<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put("label", "foo");
+ expect(input.getAttributes()).andStubReturn(attributes);
+ expect(input.getRequiredMessage()).andStubReturn(null);
+ }
+
+ @After
+ public void tearDown() {
+ controller.verify();
+ serviceImpl = null;
+ }
+
+ @Test
+ public void getConverterClass() throws Exception {
+ validator = new LengthValidator();
+ controller.replay();
+ ValidatorDescriptor validatorDescription = serviceImpl.getValidatorDescription(environment.getFacesContext(), validator);
+ assertEquals(validator.getClass(), validatorDescription.getImplementationClass());
+ }
+
+ @Test
+ public void getValidatorMessage() throws Exception {
+ validator = new RequiredValidator();
+ FacesMessage facesMessage = null;
+ controller.replay();
+ try{
+ validator.validate(environment.getFacesContext(), input, null);
+ } catch(ValidatorException e){
+ facesMessage = e.getFacesMessage();
+ }
+ assertNotNull(facesMessage);
+ ValidatorDescriptor validatorDescription = serviceImpl.getValidatorDescription(environment.getFacesContext(), validator);
+ String summary = validatorDescription.getMessage().getSummary();
+ summary = summary.replace("{0}", "foo");
+ assertEquals(facesMessage.getSummary(), summary);
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/FacesValidatorServiceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
14 years, 2 months
JBoss Rich Faces SVN: r19719 - management/design-4x/tree.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-10-27 19:57:24 -0400 (Wed, 27 Oct 2010)
New Revision: 19719
Modified:
management/design-4x/tree/tree.html
Log:
https://jira.jboss.org/browse/RF-9315 - classes renamed
Modified: management/design-4x/tree/tree.html
===================================================================
--- management/design-4x/tree/tree.html 2010-10-27 23:34:28 UTC (rev 19718)
+++ management/design-4x/tree/tree.html 2010-10-27 23:57:24 UTC (rev 19719)
@@ -6,26 +6,29 @@
<style>
.tree_size {width : 170px;}
-.tree_item {background : url(images/last.gif) no-repeat center left; cursor : default; font-size : 11px /*generalSizeFont*/; font-family : verdana /*generalFamilyFont*/; color : #000000 /*generalTextColor*/; padding : 1px 0px 1px 0px; overflow : hidden; width : 100%; white-space : nowrap;}
-.tree_item_name {padding : 0px 4px 0px 2px; vertical-align : middle; cursor : pointer; display : inline-block;}
+.tree_item {background : url(images/last.gif) no-repeat center left; cursor : default; font-size : 11px /*generalSizeFont*/;
+font-family : verdana /*generalFamilyFont*/; color : #000000 /*generalTextColor*/;
+padding : 1px 0px 1px 0px; overflow : hidden; width : 100%;
+white-space : nowrap;}
+.tree_item_label {padding : 0px 4px 0px 2px; vertical-align : middle; cursor : pointer; display : inline-block;}
.tree_selarea {display : inline-block;}
.tree_selected {background : #C7D7EC /*additionalBackgroundColor*/;}
-.tree_level {background : url(images/line.gif) repeat-y;}
-.tree_level_last {background : none;}
-.tree_level .tree_level {margin-left : 16px;}
+.tree_node {background : url(images/line.gif) repeat-y;}
+.tree_node_last {background : none;}
+.tree_node .tree_node {margin-left : 16px;}
.tree_icon {vertical-align : middle; margin : 0px; cursor : pointer; width : 16px; height : 16px; display : inline-block;}
-.tree_status_plus {background : url(images/plus.gif) no-repeat center;}
-.tree_status_minus {background : url(images/minus.gif) no-repeat center;}
+.tree_icon_collapsed {background : url(images/plus.gif) no-repeat center;}
+.tree_icon_expanded {background : url(images/minus.gif) no-repeat center;}
.tree_status_blank {background : url(images/spacer.gif) no-repeat center;}
-.tree_node {background : url(images/folder.gif) no-repeat center;}
-.tree_child {background : url(images/file.gif) no-repeat center;}
+.tree_icon_node {background : url(images/folder.gif) no-repeat center;}
+.tree_icon_leaf {background : url(images/file.gif) no-repeat center;}
-.tree_level.tree_collapse .tree_level{display : none;}
+.tree_node.tree_collapse .tree_node{display : none;}
</style>
@@ -36,63 +39,63 @@
<div class="tree_size">
- <div class="tree_level tree_level_last">
+ <div class="tree_node tree_node_last">
<div class="tree_item">
- <div class="tree_icon tree_status_minus"></div><div class="tree_selarea"><div class="tree_icon tree_node"></div><span class="tree_item_name">Node name 1</span></div>
+ <div class="tree_icon tree_icon_expanded"></div><div class="tree_selarea"><div class="tree_icon tree_icon_node"></div><span class="tree_item_label">Node name 1</span></div>
</div>
- <div class="tree_level">
+ <div class="tree_node">
<div class="tree_item">
- <div class="tree_icon tree_status_blank"></div><div class="tree_selarea"><div class="tree_icon tree_node"></div><span class="tree_item_name">Node name 1.1</span></div>
+ <div class="tree_icon tree_status_blank"></div><div class="tree_selarea"><div class="tree_icon tree_icon_node"></div><span class="tree_item_label">Node name 1.1</span></div>
</div>
</div>
- <div class="tree_level">
+ <div class="tree_node">
<div class="tree_item">
- <div class="tree_icon tree_status_minus"></div><div class="tree_selarea"><div class="tree_icon tree_node"></div><span class="tree_item_name">Node name 1.2</span></div>
+ <div class="tree_icon tree_icon_expanded"></div><div class="tree_selarea"><div class="tree_icon tree_icon_node"></div><span class="tree_item_label">Node name 1.2</span></div>
</div>
- <div class="tree_level">
+ <div class="tree_node">
<div class="tree_item">
- <div class="tree_icon tree_status_blank"></div><div class="tree_selarea tree_selected"><div class="tree_icon tree_node"></div><span class="tree_item_name">Very long node name 1.2.1</span></div>
+ <div class="tree_icon tree_status_blank"></div><div class="tree_selarea tree_selected"><div class="tree_icon tree_icon_node"></div><span class="tree_item_label">Very long node name 1.2.1</span></div>
</div>
</div>
- <div class="tree_level tree_collapse">
+ <div class="tree_node tree_collapse">
<div class="tree_item">
- <div class="tree_icon tree_status_plus"></div><div class="tree_selarea"><div class="tree_icon tree_node"></div><span class="tree_item_name">Node name 1.2.2</span></div>
+ <div class="tree_icon tree_icon_collapsed"></div><div class="tree_selarea"><div class="tree_icon tree_icon_node"></div><span class="tree_item_label">Node name 1.2.2</span></div>
</div>
- <div class="tree_level">
+ <div class="tree_node">
<div class="tree_item">
- <div class="tree_icon tree_status_minus"></div><div class="tree_selarea"><div class="tree_icon tree_node"></div><span class="tree_item_name">Node name 1.2.2.1</span></div>
+ <div class="tree_icon tree_icon_expanded"></div><div class="tree_selarea"><div class="tree_icon tree_icon_node"></div><span class="tree_item_label">Node name 1.2.2.1</span></div>
</div>
</div>
- <div class="tree_level tree_level_last">
+ <div class="tree_node tree_node_last">
<div class="tree_item">
- <div class="tree_icon tree_status_minus"></div><div class="tree_selarea"><div class="tree_icon tree_node"></div><span class="tree_item_name">Node name 1.2.2.2</span></div>
+ <div class="tree_icon tree_icon_expanded"></div><div class="tree_selarea"><div class="tree_icon tree_icon_node"></div><span class="tree_item_label">Node name 1.2.2.2</span></div>
</div>
- <div class="tree_level tree_level_last">
+ <div class="tree_node tree_node_last">
<div class="tree_item">
- <div class="tree_icon tree_status_minus"></div><div class="tree_selarea"><div class="tree_icon tree_node"></div><span class="tree_item_name">Node name 1.2.2.2.1</span></div>
+ <div class="tree_icon tree_icon_expanded"></div><div class="tree_selarea"><div class="tree_icon tree_icon_node"></div><span class="tree_item_label">Node name 1.2.2.2.1</span></div>
</div>
- <div class="tree_level">
+ <div class="tree_node">
<div class="tree_item">
- <div class="tree_icon tree_status_blank"></div><div class="tree_selarea"><div class="tree_icon tree_child"></div><span class="tree_item_name">Node name 1.2.2.2.1.1</span></div>
+ <div class="tree_icon tree_status_blank"></div><div class="tree_selarea"><div class="tree_icon tree_icon_leaf"></div><span class="tree_item_label">Node name 1.2.2.2.1.1</span></div>
</div>
</div>
- <div class="tree_level tree_level_last">
+ <div class="tree_node tree_node_last">
<div class="tree_item">
- <div class="tree_icon tree_status_blank"></div><div class="tree_selarea"><div class="tree_icon tree_child"></div><span class="tree_item_name">Node name 1.2.2.2.1.2</span></div>
+ <div class="tree_icon tree_status_blank"></div><div class="tree_selarea"><div class="tree_icon tree_icon_leaf"></div><span class="tree_item_label">Node name 1.2.2.2.1.2</span></div>
</div>
</div>
</div>
</div>
</div>
- <div class="tree_level tree_level_last">
+ <div class="tree_node tree_node_last">
<div class="tree_item">
- <div class="tree_icon tree_status_blank"></div><div class="tree_selarea"><div class="tree_icon tree_child"></div><span class="tree_item_name">Node name 1.2.3</span></div>
+ <div class="tree_icon tree_status_blank"></div><div class="tree_selarea"><div class="tree_icon tree_icon_leaf"></div><span class="tree_item_label">Node name 1.2.3</span></div>
</div>
</div>
</div>
- <div class="tree_level tree_level_last">
+ <div class="tree_node tree_node_last">
<div class="tree_item">
- <div class="tree_icon tree_status_blank"></div><div class="tree_selarea"><div class="tree_icon tree_child"></div><span class="tree_item_name">Node name 1.3</span></div>
+ <div class="tree_icon tree_status_blank"></div><div class="tree_selarea"><div class="tree_icon tree_icon_leaf"></div><span class="tree_item_label">Node name 1.3</span></div>
</div>
</div>
</div>
14 years, 2 months
JBoss Rich Faces SVN: r19718 - in branches/RF-8742/ui/validator: impl/src/main/java/org/richfaces/application and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-10-27 19:34:28 -0400 (Wed, 27 Oct 2010)
New Revision: 19718
Added:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ValidatorDescriptor.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterDescriptorImpl.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterServiceImpl.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/MessageFactory.java
Modified:
branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/FacesValidatorService.java
branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java
branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/FacesConverterServiceTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java
Log:
RESOLVED - issue RF-9520: ConverterService unit tests and implementation
https://jira.jboss.org/browse/RF-9520
Modified: branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/FacesValidatorService.java
===================================================================
--- branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/FacesValidatorService.java 2010-10-27 23:29:43 UTC (rev 19717)
+++ branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/FacesValidatorService.java 2010-10-27 23:34:28 UTC (rev 19718)
@@ -6,5 +6,5 @@
public interface FacesValidatorService {
- FacesObjectDescriptor getValidatorDescription(FacesContext context,Validator validator);
+ ValidatorDescriptor getValidatorDescription(FacesContext context,Validator validator);
}
Added: branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ValidatorDescriptor.java
===================================================================
--- branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ValidatorDescriptor.java (rev 0)
+++ branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ValidatorDescriptor.java 2010-10-27 23:34:28 UTC (rev 19718)
@@ -0,0 +1,12 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+/**
+ * @author asmirnov
+ *
+ */
+public interface ValidatorDescriptor extends FacesObjectDescriptor {
+
+}
Property changes on: branches/RF-8742/ui/validator/api/src/main/java/org/richfaces/validator/ValidatorDescriptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java 2010-10-27 23:29:43 UTC (rev 19717)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/application/ValidatorModule.java 2010-10-27 23:34:28 UTC (rev 19718)
@@ -26,6 +26,8 @@
import javax.validation.ValidationException;
import org.richfaces.validator.BeanValidator;
+import org.richfaces.validator.ConverterServiceImpl;
+import org.richfaces.validator.FacesConverterService;
import org.richfaces.validator.NullValidator;
import org.richfaces.validator.ObjectValidator;
@@ -46,7 +48,7 @@
*/
public void configure(ServicesFactory factory) {
factory.setInstance(ObjectValidator.class, createInstance());
-
+ factory.setInstance(FacesConverterService.class, new ConverterServiceImpl());
}
/**
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterDescriptorImpl.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterDescriptorImpl.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterDescriptorImpl.java 2010-10-27 23:34:28 UTC (rev 19718)
@@ -0,0 +1,61 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+import java.util.Map;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.convert.Converter;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ConverterDescriptorImpl implements ConverterDescriptor {
+
+
+ private final Class<? extends Converter> converterClass;
+
+ private Map<String, Object> parameters = Maps.newHashMap();
+
+ private final FacesMessage message;
+
+ ConverterDescriptorImpl(Class<? extends Converter> converterClass,FacesMessage message) {
+ this.converterClass = converterClass;
+ this.message = message;
+
+ }
+ /* (non-Javadoc)
+ * @see org.richfaces.validator.FacesObjectDescriptor#getImplementationClass()
+ */
+ public Class<?> getImplementationClass() {
+ return converterClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.validator.FacesObjectDescriptor#getAdditionalParameters()
+ */
+ public Map<String, ? extends Object> getAdditionalParameters() {
+ return parameters;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.validator.FacesObjectDescriptor#getMessage()
+ */
+ public FacesMessage getMessage() {
+ return message;
+ }
+
+ void addParameter(String name, Object value){
+ parameters.put(name, value);
+ }
+
+ void makeImmutable(){
+ parameters = ImmutableMap.copyOf(parameters);
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterDescriptorImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterServiceImpl.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterServiceImpl.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterServiceImpl.java 2010-10-27 23:34:28 UTC (rev 19718)
@@ -0,0 +1,132 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.BigDecimalConverter;
+import javax.faces.convert.BigIntegerConverter;
+import javax.faces.convert.BooleanConverter;
+import javax.faces.convert.ByteConverter;
+import javax.faces.convert.CharacterConverter;
+import javax.faces.convert.Converter;
+import javax.faces.convert.DateTimeConverter;
+import javax.faces.convert.DoubleConverter;
+import javax.faces.convert.EnumConverter;
+import javax.faces.convert.FloatConverter;
+import javax.faces.convert.IntegerConverter;
+import javax.faces.convert.LongConverter;
+import javax.faces.convert.NumberConverter;
+import javax.faces.convert.ShortConverter;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ConverterServiceImpl implements FacesConverterService {
+
+ private static final String DEFAULT_CONVERTER_MESSAGE_ID = UIInput.CONVERSION_MESSAGE_ID;
+
+ private static final ImmutableSet<String> HIDDEN_PROPERTIES = ImmutableSet.of("class", "transient");
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.validator.FacesConverterService#getConverterDescription(javax.faces.context.FacesContext,
+ * javax.faces.convert.Converter)
+ */
+ public ConverterDescriptor getConverterDescription(FacesContext context, Converter converter) {
+ // determine converter message.
+ FacesMessage message = getConverterMessage(context, converter);
+ ConverterDescriptorImpl descriptor = new ConverterDescriptorImpl(converter.getClass(), message);
+ fillConverterParameters(descriptor, converter);
+ descriptor.makeImmutable();
+ return descriptor;
+ }
+
+ private void fillConverterParameters(ConverterDescriptorImpl descriptor, Converter converter) {
+ // get bean attributes for converter, put them into parameters.
+ try {
+ BeanInfo beanInfo = Introspector.getBeanInfo(converter.getClass());
+ PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
+ String name = propertyDescriptor.getName();
+ if (!HIDDEN_PROPERTIES.contains(name)) {
+ try {
+ Object value = propertyDescriptor.getReadMethod().invoke(converter);
+ if (null != value) {
+ descriptor.addParameter(name, value);
+ }
+ } catch (IllegalArgumentException e) {
+ // Ignore
+ } catch (IllegalAccessException e) {
+ // Ignore
+ } catch (InvocationTargetException e) {
+ // Ignore
+ }
+ }
+ }
+ } catch (IntrospectionException e) {
+ // Ignore.
+ }
+ }
+
+ /**
+ * Creates message for converter, using current locale.
+ *
+ * @param context
+ * @param converter
+ * @return
+ */
+ private FacesMessage getConverterMessage(FacesContext context, Converter converter) {
+ String messageId = getMessageId(converter);
+ return MessageFactory.createMessage(context, messageId);
+ }
+
+ private String getMessageId(Converter converter) {
+ String messageId;
+ if (converter instanceof BigDecimalConverter) {
+ messageId = BigDecimalConverter.DECIMAL_ID;
+ } else if (converter instanceof BigIntegerConverter) {
+ messageId = BigIntegerConverter.BIGINTEGER_ID;
+ } else if (converter instanceof BooleanConverter) {
+ messageId = BooleanConverter.BOOLEAN_ID;
+ } else if (converter instanceof ByteConverter) {
+ messageId = ByteConverter.BYTE_ID;
+ } else if (converter instanceof CharacterConverter) {
+ messageId = CharacterConverter.CHARACTER_ID;
+ } else if (converter instanceof DateTimeConverter) {
+ // TODO - distinguish Date, Time, and DateTime.
+ messageId = DateTimeConverter.DATETIME_ID;
+ } else if (converter instanceof DoubleConverter) {
+ messageId = DoubleConverter.DOUBLE_ID;
+ } else if (converter instanceof EnumConverter) {
+ messageId = EnumConverter.ENUM_ID;
+ } else if (converter instanceof FloatConverter) {
+ messageId = FloatConverter.FLOAT_ID;
+ } else if (converter instanceof IntegerConverter) {
+ messageId = IntegerConverter.INTEGER_ID;
+ } else if (converter instanceof LongConverter) {
+ messageId = LongConverter.LONG_ID;
+ } else if (converter instanceof NumberConverter) {
+ // TODO - detect case ( currency, percent etc ).
+ messageId = NumberConverter.NUMBER_ID;
+ } else if (converter instanceof ShortConverter) {
+ messageId = ShortConverter.SHORT_ID;
+ } else {
+ messageId = DEFAULT_CONVERTER_MESSAGE_ID;
+ }
+ return messageId;
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/ConverterServiceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/MessageFactory.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/MessageFactory.java (rev 0)
+++ branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/MessageFactory.java 2010-10-27 23:34:28 UTC (rev 19718)
@@ -0,0 +1,75 @@
+/**
+ *
+ */
+package org.richfaces.validator;
+
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author asmirnov
+ *
+ */
+public final class MessageFactory {
+
+ private MessageFactory(){}
+
+ public static FacesMessage createMessage(FacesContext context, String messageId) {
+ Locale locale = getCurrentLocale(context);
+ String messageBundle = context.getApplication().getMessageBundle();
+ FacesMessage message;
+ try {
+ if (null != messageBundle) {
+ try {
+ message = getMessageFromBundle(locale, messageBundle, messageId);
+ } catch (MissingResourceException e) {
+ message = getMessageFromBundle(locale, FacesMessage.FACES_MESSAGES, messageId);
+ }
+ } else {
+ message = getMessageFromBundle(locale, FacesMessage.FACES_MESSAGES, messageId);
+ }
+ } catch (MissingResourceException e) {
+ // No bundles at all, fall back message.
+ return new FacesMessage("conversion error");
+ }
+ return message;
+ }
+
+ private static FacesMessage getMessageFromBundle(Locale locale, String messageBundle, String messageId)
+ throws MissingResourceException {
+ ResourceBundle bundle = ResourceBundle.getBundle(messageBundle, locale, getCurrentLoader(messageId));
+ String summary = bundle.getString(messageId);
+ String detail;
+ try {
+ detail = bundle.getString(messageId + "_detail");
+ } catch (MissingResourceException e) {
+ return new FacesMessage(summary);
+ }
+ return new FacesMessage(summary, detail);
+ }
+
+ private static Locale getCurrentLocale(FacesContext context) {
+ UIViewRoot viewRoot = context.getViewRoot();
+ Locale locale;
+ if (null == viewRoot) {
+ locale = Locale.getDefault();
+ } else {
+ locale = viewRoot.getLocale();
+ }
+ return locale;
+ }
+
+ private static ClassLoader getCurrentLoader(Object fallbackClass) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null) {
+ loader = fallbackClass.getClass().getClassLoader();
+ }
+ return loader;
+ }
+
+}
Property changes on: branches/RF-8742/ui/validator/impl/src/main/java/org/richfaces/validator/MessageFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/FacesConverterServiceTest.java
===================================================================
--- branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/FacesConverterServiceTest.java 2010-10-27 23:29:43 UTC (rev 19717)
+++ branches/RF-8742/ui/validator/impl/src/test/java/org/richfaces/validator/FacesConverterServiceTest.java 2010-10-27 23:34:28 UTC (rev 19718)
@@ -1,37 +1,109 @@
package org.richfaces.validator;
-import static org.junit.Assert.*;
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
-import javax.faces.context.FacesContext;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIViewRoot;
+import javax.faces.convert.BooleanConverter;
import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.convert.DateTimeConverter;
+import javax.faces.convert.IntegerConverter;
+import javax.faces.render.ClientBehaviorRenderer;
+import org.jboss.test.faces.mock.Environment;
+import org.jboss.test.faces.mock.Environment.Feature;
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockController;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.jboss.test.faces.mock.MockTestRunner;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
-
+(a)RunWith(MockTestRunner.class)
public class FacesConverterServiceTest {
- FacesConverterService serviceImpl;
-
- Converter converter;
+ @Mock()
+ @Environment({ Feature.APPLICATION })
+ protected MockFacesEnvironment environment;
+ protected FacesConverterService serviceImpl;
+ @Mock
+ protected UIViewRoot viewRoot;
+ @Mock
+ protected UIInput input;
+ @Mock
+ protected ClientBehaviorRenderer behaviorRenderer;
+ protected MockController controller;
+ protected Converter converter;
- private FacesContext context;
@Before
public void setUp() {
// create service impl.
+ serviceImpl = new ConverterServiceImpl();
+ expect(environment.getFacesContext().getViewRoot()).andStubReturn(viewRoot);
+ expect(viewRoot.getLocale()).andStubReturn(Locale.ENGLISH);
+ expect(environment.getApplication().getMessageBundle()).andStubReturn("com.sun.faces.resources.Messages");
+ HashMap<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put("label", "foo");
+ expect(input.getAttributes()).andStubReturn(attributes);
}
@After
public void tearDown() {
+ controller.verify();
serviceImpl = null;
}
@Test
- public void getConverterDescription() throws Exception {
- ConverterDescriptor converterDescription = serviceImpl.getConverterDescription(context, converter);
+ public void getConverterClass() throws Exception {
+ converter = new BooleanConverter();
+ controller.replay();
+ ConverterDescriptor converterDescription = serviceImpl.getConverterDescription(environment.getFacesContext(), converter);
assertEquals(converter.getClass(), converterDescription.getImplementationClass());
}
+ @Test
+ public void getConverterMessage() throws Exception {
+ converter = new IntegerConverter();
+ FacesMessage facesMessage = null;
+ controller.replay();
+ try{
+ converter.getAsObject(environment.getFacesContext(), input, "abc");
+ } catch(ConverterException e){
+ facesMessage = e.getFacesMessage();
+ }
+ assertNotNull(facesMessage);
+ ConverterDescriptor converterDescription = serviceImpl.getConverterDescription(environment.getFacesContext(), converter);
+ String summary = converterDescription.getMessage().getSummary();
+ summary = summary.replace("{2}", "foo");
+ summary = summary.replace("'{0}'", "abc");
+ assertEquals(facesMessage.getSummary(), summary);
+ }
+
+ @Test
+ public void getConverterParameters() throws Exception {
+ DateTimeConverter converter = new DateTimeConverter();
+
+ converter.setDateStyle("short");
+ converter.setPattern("MM/DD/YYYY");
+ converter.setTimeStyle("full");
+ converter.setType("both");
+ converter.setTimeZone(TimeZone.getTimeZone("EST"));
+ controller.replay();
+ ConverterDescriptor converterDescription = serviceImpl.getConverterDescription(environment.getFacesContext(), converter);
+ Map<String, ? extends Object> additionalParameters = converterDescription.getAdditionalParameters();
+ assertEquals("short", additionalParameters.get("dateStyle"));
+ assertEquals("MM/DD/YYYY", additionalParameters.get("pattern"));
+ }
}
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java 2010-10-27 23:29:43 UTC (rev 19717)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorGetValidatorTest.java 2010-10-27 23:34:28 UTC (rev 19718)
@@ -23,6 +23,7 @@
import org.richfaces.validator.BeanValidatorService;
import org.richfaces.validator.FacesValidatorService;
import org.richfaces.validator.FacesObjectDescriptor;
+import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -104,7 +105,7 @@
private void setupComponentValidator(Validator... validators) {
expect(input.getValidators()).andStubReturn(validators);
for (Validator validator : validators) {
- FacesObjectDescriptor validatorDescriptor = environment.createMock(FacesObjectDescriptor.class);
+ ValidatorDescriptor validatorDescriptor = environment.createMock(ValidatorDescriptor.class);
expect((Class) validatorDescriptor.getImplementationClass()).andStubReturn(validator.getClass());
expect(validatorDescriptor.getMessage()).andStubReturn(VALIDATION_ERROR);
expect(facesValidatorService.getValidatorDescription(environment.getFacesContext(), validator))
14 years, 2 months