[richfaces-svn-commits] JBoss Rich Faces SVN: r302 - in trunk/richfaces/menu-components/src/main/java/org/richfaces: renderkit/html and 1 other directory.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Fri Apr 6 09:12:20 EDT 2007
Author: F.antonov
Date: 2007-04-06 09:12:20 -0400 (Fri, 06 Apr 2007)
New Revision: 302
Added:
trunk/richfaces/menu-components/src/main/java/org/richfaces/component/MenuComponent.java
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
Log:
MenuItem component development.
Added: trunk/richfaces/menu-components/src/main/java/org/richfaces/component/MenuComponent.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/component/MenuComponent.java (rev 0)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/component/MenuComponent.java 2007-04-06 13:12:20 UTC (rev 302)
@@ -0,0 +1,44 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+
+/**
+ * Interface which main menu must implements in order to menu components could works correctly.
+ * @author F. Antonov
+ *
+ */
+public interface MenuComponent {
+
+ /**
+ * Possible values for submit mode property.
+ */
+ public static final String MODE_AJAX = "ajax";
+ public static final String MODE_SERVER = "server";
+ public static final String MODE_NONE = "none";
+
+ /**
+ * Getter for submit mode property.
+ */
+ public String getMode();
+
+}
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java 2007-04-06 11:56:56 UTC (rev 301)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java 2007-04-06 13:12:20 UTC (rev 302)
@@ -36,9 +36,6 @@
public static final String COMPONENT_TYPE = "org.richfaces.DropDownMenu";
- public static final String MODE_AJAX = "ajax";
- public static final String MODE_SERVER = "server";
- public static final String MODE_NONE = "none";
public abstract String getMode();
public abstract void setMode(String mode);
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2007-04-06 11:56:56 UTC (rev 301)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2007-04-06 13:12:20 UTC (rev 302)
@@ -33,7 +33,7 @@
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.ComponentVariables;
import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
-import org.ajax4jsf.framework.renderer.RendererUtils;
+import org.richfaces.component.MenuComponent;
import org.richfaces.component.UIMenuItem;
import org.richfaces.component.util.ViewUtil;
import org.richfaces.renderkit.CompositeRenderer;
@@ -43,7 +43,6 @@
public class MenuItemRendererBase extends CompositeRenderer {
-// private static RendererUtils rendererUtils = new RendererUtils();
protected Class getComponentClass() {
return UIMenuItem.class;
@@ -70,7 +69,7 @@
// taken from forId attribute
String mode = menuItem.getMode();
- if (!UIMenuItem.MODE_NONE.equalsIgnoreCase(mode)) {
+ if (!MenuComponent.MODE_NONE.equalsIgnoreCase(mode)) {
ActionEvent actionEvent = new ActionEvent(menuItem);
if (menuItem.isImmediate()) {
@@ -95,60 +94,18 @@
variables.setVariable("icon", resource);
if (menuItem.isDisabled()) {
- resource = "dr-menu-item dr-menu-item-disabled rich-menu-item rich-menu-item-disabled "
- + getStringAttributeOrEmptyString(menuItem, "styleClass");
- variables.setVariable("class", resource);
-
- resource = "dr-menu-icon dr-menu-icon-disabled rich-menu-item-icon rich-menu-item-icon-disabled "
- + getStringAttributeOrEmptyString(menuItem, "iconClass");
- variables.setVariable("iconClass", resource);
-
- resource = "dr-menu-label dr-menu-label-disabled rich-menu-item-label rich-menu-item-label-disabled";
- variables.setVariable("labelClass", resource);
-
- variables.setVariable("onclick", "Event.stop(event || window.event);");
-
+ variables.setVariable("iconDisabledClasses", "dr-menu-icon-disabled rich-menu-item-icon-disabled");
} else {
- StringBuffer scriptValue = new StringBuffer();
- scriptValue.append("this.className='dr-menu-item dr-menu-item-enabled rich-menu-item rich-menu-item-enabled ")
- .append(getStringAttributeOrEmptyString(menuItem, "styleClass") + "'; ");
- processInlineStyles(context, menuItem, scriptValue, false);
- scriptValue.append("document.getElementById('" + menuItem.getClientId(context) + ":icon').className='dr-menu-icon rich-menu-item-icon ")
- .append(getStringAttributeOrEmptyString(menuItem, "iconClass") + "'; ");
- scriptValue.append("document.getElementById('" + menuItem.getClientId(context) + ":anchor').className='dr-menu-label rich-menu-item-label'; ")
- .append(getStringAttributeOrEmptyString(menuItem, "onmouseout"));
- variables.setVariable("onmouseout", scriptValue);
+ variables.setVariable("onmouseoutInlineStyles", processInlineStyles(context, menuItem, false));
+ variables.setVariable("onmouseoverInlineStyles", processInlineStyles(context, menuItem, true));
- scriptValue = new StringBuffer();
- scriptValue.append("this.className='dr-menu-item dr-menu-item-hover rich-menu-item rich-menu-item-hover ")
- .append(getStringAttributeOrEmptyString(menuItem, "styleClass") + " ")
- .append(getStringAttributeOrEmptyString(menuItem, "selectClass") + "'; ");
- processInlineStyles(context, menuItem, scriptValue, true);
- scriptValue.append("document.getElementById('" + menuItem.getClientId(context) + ":icon').className='dr-menu-icon dr-menu-icon-selected rich-menu-item-icon rich-menu-item-icon-selected ")
- .append(getStringAttributeOrEmptyString(menuItem, "iconClass") + "'; ");
- scriptValue.append("document.getElementById('" + menuItem.getClientId(context) + ":anchor').className='dr-menu-label dr-menu-label-selected rich-menu-item-label rich-menu-item-label-selected'; ")
- .append(getStringAttributeOrEmptyString(menuItem, "onmouseout"));
- variables.setVariable("onmouseover", scriptValue);
-
- resource = "dr-menu-item dr-menu-item-enabled rich-menu-item rich-menu-item-enabled "
- + getStringAttributeOrEmptyString(menuItem, "styleClass");
- variables.setVariable("class", resource);
-
- resource = "dr-menu-icon rich-menu-item-icon "
- + getStringAttributeOrEmptyString(menuItem, "iconClass");
- variables.setVariable("iconClass", resource);
-
- resource = "dr-menu-label rich-menu-item-label";
- variables.setVariable("labelClass", resource);
-
- scriptValue = new StringBuffer();
- scriptValue.append(getStringAttributeOrEmptyString(menuItem, "onselect"));
+ StringBuffer scriptValue = new StringBuffer();
String mode = resolveSubmitMode(menuItem);
- if (mode.equalsIgnoreCase(UIMenuItem.MODE_AJAX)) {
+ if (mode.equalsIgnoreCase(MenuComponent.MODE_AJAX)) {
scriptValue.append(AjaxRendererUtils.buildOnClick(menuItem, context).toString());
//scriptValue.append("; Exadel.Menu.Layers.shutdown();return false;");
- } else if (mode.equalsIgnoreCase(UIMenuItem.MODE_SERVER)) {
+ } else if (mode.equalsIgnoreCase(MenuComponent.MODE_SERVER)) {
CommandScriptBuilder builder = new CommandScriptBuilder(menuItem);
builder.setCheckActionAndListener(true);
Object target = menuItem.getAttributes().get("target");
@@ -162,14 +119,13 @@
builder.addParameter(id + ":hidden", id);
scriptValue.append(builder.toString());
} else {
- scriptValue.append("; " + getStringAttributeOrEmptyString(menuItem, "onclick"));
+ scriptValue.append(getStringAttributeOrEmptyString(menuItem, "onclick"));
}
if (resource.length() > 0) {
variables.setVariable("onclick", scriptValue.toString());
}
}
- variables.setVariable("value", getStringAttributeOrEmptyString(menuItem, "value"));
}
protected String getStringAttributeOrEmptyString(UIComponent component, String attributeName) {
@@ -199,23 +155,24 @@
}
UIComponent parent = menuItem.getParent();
while (null != parent) {
- submitMode = (String) parent.getAttributes().get("mode");
- if (null != submitMode) {
- return submitMode;
+ if (parent instanceof MenuComponent) {
+ return ((MenuComponent) parent).getMode();
}
parent = parent.getParent();
}
- return UIMenuItem.MODE_SERVER;
+
+ return MenuComponent.MODE_SERVER;
}
- private void processInlineStyles(FacesContext context, UIMenuItem menuItem, StringBuffer buffer, boolean isOnmouseover) {
+ private String processInlineStyles(FacesContext context, UIMenuItem menuItem, boolean isOnmouseover) {
+ StringBuffer buffer = new StringBuffer();
Object style = menuItem.getAttributes().get("style");
Object selectStyle = menuItem.getAttributes().get("selectStyle");
if (null == selectStyle) {
- return;
+ return "";
}
- buffer.append("document.getElementById('" + menuItem.getClientId(context) + "').style.cssText='");
+ buffer.append("$('" + menuItem.getClientId(context) + "').style.cssText='");
if (null != style) {
buffer.append(style.toString() + "; ");
}
@@ -224,6 +181,7 @@
} else {
buffer.append("';");
}
+ return buffer.toString();
}
}
More information about the richfaces-svn-commits
mailing list