Author: konstantin.mishin
Date: 2009-07-28 06:01:01 -0400 (Tue, 28 Jul 2009)
New Revision: 15023
Modified:
branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java
branches/community/3.3.X/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
Log:
RF-7595
Modified:
branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java
===================================================================
---
branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java 2009-07-28
09:57:25 UTC (rev 15022)
+++
branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java 2009-07-28
10:01:01 UTC (rev 15023)
@@ -22,17 +22,19 @@
package org.richfaces.renderkit.html;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.UIContextMenu;
-import org.richfaces.component.UIMenuGroup;
-import org.richfaces.renderkit.ScriptOptions;
/**
* @author Maksim Kaszynski
@@ -40,71 +42,23 @@
*/
public class ContextMenuRendererDelegate extends AbstractMenuRenderer {
- /* (non-Javadoc)
- * @see
org.richfaces.renderkit.html.AbstractMenuRenderer#getLayerScript(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
- */
- protected String getLayerScript(FacesContext context, UIComponent component) {
- StringBuffer buffer = new StringBuffer();
- JSFunction function = new JSFunction("new RichFaces.Menu.Layer");
- function.addParameter(component.getClientId(context)+"_menu");
- function.addParameter(component.getAttributes().get("showDelay"));
-
- if (component instanceof UIContextMenu) {
- function.addParameter(component.getAttributes().get("hideDelay"));
- } else {
- function.addParameter(new Integer(300));
- }
-
- function.appendScript(buffer);
-
- if (component instanceof UIMenuGroup) {
- buffer.append(".");
- function = new JSFunction("asSubMenu");
-
function.addParameter(component.getParent().getClientId(context)+"_menu");
- function.addParameter(component.getClientId(context));
- String evt = (String) component.getAttributes().get("event");
- if(evt == null || evt.trim().length() == 0){
- evt = "onmouseover";
- }
- function.addParameter(evt);
- ScriptOptions subMenuOptions = new ScriptOptions(component);
- subMenuOptions.addEventHandler("onopen");
- subMenuOptions.addEventHandler("onclose");
- subMenuOptions.addOption("direction");
- subMenuOptions.addOption("dummy", "dummy");
- function.addParameter(subMenuOptions);
- function.appendScript(buffer);
-
- } else {
- buffer.append(".");
- function = new JSFunction("asContextMenu");
-/* function.addParameter(component.getParent().getClientId(context));
- String evt = (String) component.getAttributes().get("event");
- if(evt == null || evt.trim().length() == 0){
- evt = "oncontextmenu";
- }
- function.addParameter(evt);
- function.addParameter("onmouseout");
-*/ ScriptOptions menuOptions = new ScriptOptions(component);
-
- menuOptions.addOption("direction");
- menuOptions.addOption("jointPoint");
- menuOptions.addOption("verticalOffset");
-
-
- menuOptions.addOption("horizontalOffset");
- menuOptions.addEventHandler("oncollapse");
- menuOptions.addEventHandler("onexpand");
- menuOptions.addEventHandler("onitemselect");
- menuOptions.addEventHandler("ongroupactivate");
-
- menuOptions.addOption("dummy", "dummy");
- function.addParameter(menuOptions);
- function.appendScript(buffer);
-
+ protected void appendMenuScript(FacesContext context, UIComponent component,
StringBuffer buffer) {
+ Map<String, Object> options = new HashMap<String, Object>();
+ RendererUtils utils = getUtils();
+ buffer.append(".");
+ JSFunction function = new JSFunction("asContextMenu");
+ utils.addToScriptHash(options, "direction",
component.getAttributes().get("direction"), "auto");
+ utils.addToScriptHash(options, "jointPoint",
component.getAttributes().get("jointPoint"), "auto");
+ utils.addToScriptHash(options, "verticalOffset",
component.getAttributes().get("verticalOffset"), "0");
+ utils.addToScriptHash(options, "horizontalOffset",
component.getAttributes().get("horizontalOffset"), "0");
+ utils.addToScriptHash(options, "oncollapse",
component.getAttributes().get("oncollapse"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "onexpand",
component.getAttributes().get("onexpand"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "onitemselect",
component.getAttributes().get("onitemselect"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "ongroupactivate",
component.getAttributes().get("ongroupactivate"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
+ if (!options.isEmpty()) {
+ function.addParameter(options);
}
-
- return buffer.toString();
+ function.appendScript(buffer);
}
/* (non-Javadoc)
Modified:
branches/community/3.3.X/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
---
branches/community/3.3.X/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2009-07-28
09:57:25 UTC (rev 15022)
+++
branches/community/3.3.X/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2009-07-28
10:01:01 UTC (rev 15023)
@@ -34,7 +34,6 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
import org.richfaces.component.UIDropDownMenu;
-import org.richfaces.component.UIMenuGroup;
public class DropDownMenuRendererBase extends AbstractMenuRenderer {
@@ -44,59 +43,26 @@
}
@Override
- protected String getLayerScript(FacesContext context, UIComponent component) {
- StringBuffer buffer = new StringBuffer();
+ protected void appendMenuScript(FacesContext context, UIComponent component,
StringBuffer buffer) {
Map<String, Object> options = new HashMap<String, Object>();
RendererUtils utils = getUtils();
- JSFunction function = new JSFunction("new RichFaces.Menu.Layer");
- function.addParameter(component.getClientId(context)+"_menu");
- utils.addToScriptHash(options, "delay",
component.getAttributes().get("showDelay"), "300");
- utils.addToScriptHash(options, "hideDelay",
component.getAttributes().get("hideDelay"), "300");
- utils.addToScriptHash(options, "selectedClass",
component.getAttributes().get("selectedLabelClass"));
-
- if (!options.isEmpty()) {
- function.addParameter(options);
- }
-
+ buffer.append(".");
+ JSFunction function = new JSFunction("asDropDown");
+ function.addParameter(component.getClientId(context));
+ utils.addToScriptHash(options, "onEvt",
component.getAttributes().get("event"), "onmouseover");
+ utils.addToScriptHash(options, "direction",
component.getAttributes().get("direction"), "auto");
+ utils.addToScriptHash(options, "jointPoint",
component.getAttributes().get("jointPoint"), "auto");
+ utils.addToScriptHash(options, "verticalOffset",
component.getAttributes().get("verticalOffset"), "0");
+ utils.addToScriptHash(options, "horizontalOffset",
component.getAttributes().get("horizontalOffset"), "0");
+ utils.addToScriptHash(options, "oncollapse",
component.getAttributes().get("oncollapse"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "onexpand",
component.getAttributes().get("onexpand"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "onitemselect",
component.getAttributes().get("onitemselect"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "ongroupactivate",
component.getAttributes().get("ongroupactivate"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "disabled",
component.getAttributes().get("disabled"));
+ if (!options.isEmpty()) {
+ function.addParameter(options);
+ }
function.appendScript(buffer);
-
- options = new HashMap<String, Object>();
-
- if (component instanceof UIMenuGroup) {
- buffer.append(".");
- function = new JSFunction("asSubMenu");
-
function.addParameter(component.getParent().getClientId(context)+"_menu");
- function.addParameter(component.getClientId(context));
- utils.addToScriptHash(options, "evtName",
component.getAttributes().get("event"), "onmouseover");
- utils.addToScriptHash(options, "direction",
component.getAttributes().get("direction"), "auto");
- utils.addToScriptHash(options, "onopen",
component.getAttributes().get("onopen"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
- utils.addToScriptHash(options, "onclose",
component.getAttributes().get("onclose"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
- if (!options.isEmpty()) {
- function.addParameter(options);
- }
- function.appendScript(buffer);
- } else {
- buffer.append(".");
- function = new JSFunction("asDropDown");
- function.addParameter(component.getClientId(context));
- utils.addToScriptHash(options, "onEvt",
component.getAttributes().get("event"), "onmouseover");
- utils.addToScriptHash(options, "direction",
component.getAttributes().get("direction"), "auto");
- utils.addToScriptHash(options, "jointPoint",
component.getAttributes().get("jointPoint"), "auto");
- utils.addToScriptHash(options, "verticalOffset",
component.getAttributes().get("verticalOffset"), "0");
- utils.addToScriptHash(options, "horizontalOffset",
component.getAttributes().get("horizontalOffset"), "0");
- utils.addToScriptHash(options, "oncollapse",
component.getAttributes().get("oncollapse"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
- utils.addToScriptHash(options, "onexpand",
component.getAttributes().get("onexpand"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
- utils.addToScriptHash(options, "onitemselect",
component.getAttributes().get("onitemselect"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
- utils.addToScriptHash(options, "ongroupactivate",
component.getAttributes().get("ongroupactivate"), null,
ScriptHashVariableWrapper.EVENT_HANDLER);
- utils.addToScriptHash(options, "disabled",
component.getAttributes().get("disabled"));
- if (!options.isEmpty()) {
- function.addParameter(options);
- }
- function.appendScript(buffer);
-
- }
-
- return buffer.toString();
}
public void encodeChildren(FacesContext context, UIComponent component)