Author: konstantin.mishin
Date: 2009-07-29 06:18:35 -0400 (Wed, 29 Jul 2009)
New Revision: 15040
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-29
09:55:20 UTC (rev 15039)
+++
branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java 2009-07-29
10:18:35 UTC (rev 15040)
@@ -22,17 +22,13 @@
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;
@@ -42,23 +38,9 @@
*/
public class ContextMenuRendererDelegate extends AbstractMenuRenderer {
- 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);
- }
- function.appendScript(buffer);
+ @Override
+ protected JSFunction getMenuScriptFunction(FacesContext context, UIComponent component)
{
+ return new JSFunction("asContextMenu");
}
/* (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-29
09:55:20 UTC (rev 15039)
+++
branches/community/3.3.X/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2009-07-29
10:18:35 UTC (rev 15040)
@@ -22,7 +22,6 @@
package org.richfaces.renderkit.html;
import java.io.IOException;
-import java.util.HashMap;
import java.util.Map;
import javax.faces.component.UIComponent;
@@ -32,7 +31,6 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
import org.richfaces.component.UIDropDownMenu;
@@ -43,28 +41,21 @@
}
@Override
- protected void appendMenuScript(FacesContext context, UIComponent component,
StringBuffer buffer) {
- Map<String, Object> options = new HashMap<String, Object>();
- RendererUtils utils = getUtils();
- buffer.append(".");
+ protected JSFunction getMenuScriptFunction(FacesContext context, UIComponent component)
{
JSFunction function = new JSFunction("asDropDown");
function.addParameter(component.getClientId(context));
+ return function;
+ }
+
+ @Override
+ protected Map<String, Object> getMenuOptions(UIComponent component) {
+ Map<String, Object> options = super.getMenuOptions(component);
+ RendererUtils utils = getUtils();
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 options;
}
-
+
public void encodeChildren(FacesContext context, UIComponent component)
throws IOException {
if (!((org.richfaces.component.UIDropDownMenu)component).isDisabled())