Author: abelevich
Date: 2007-10-05 11:22:17 -0400 (Fri, 05 Oct 2007)
New Revision: 3284
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
Log:
RF-1070
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
===================================================================
---
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2007-10-05
13:56:15 UTC (rev 3283)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2007-10-05
15:22:17 UTC (rev 3284)
@@ -22,6 +22,7 @@
package org.richfaces.renderkit.html;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -31,13 +32,14 @@
import java.util.Set;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.faces.event.ActionEvent;
-import org.ajax4jsf.event.AjaxEvent;
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.javascript.JSFunction;
import org.richfaces.component.UIPanelMenu;
import org.richfaces.component.UIPanelMenuGroup;
import org.richfaces.component.UIPanelMenuItem;
@@ -52,6 +54,41 @@
return UIComponent.class;
}
+ // find and encode UIParameter's components
+ public List encodeParams(FacesContext context, UIPanelMenuItem component) throws
IOException {
+
+ UIPanelMenuItem menuItem = component;
+ List params = new ArrayList();
+ StringBuffer buff = new StringBuffer();
+
+ List children = menuItem.getChildren();
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
+ UIComponent child = (UIComponent) iterator.next();
+
+ if(child instanceof UIParameter){
+
+ UIParameter param = (UIParameter)child;
+ String name = param.getName();
+
+ if (null == name) {
+ throw new IllegalArgumentException(Messages.getMessage(
+ Messages.UNNAMED_PARAMETER_ERROR, component.getClientId(context)));
+ }
+
+ Object value = param.getValue();
+ buff.append("params[");
+ buff.append(ScriptUtils.toScript(name));
+ buff.append("] = ");
+ buff.append(ScriptUtils.toScript(value));
+ buff.append(";");
+ params.add(buff.toString());
+ }
+ }
+
+ return params;
+ }
+
+
public void insertScript(FacesContext context, UIComponent component)
throws IOException {
@@ -122,8 +159,11 @@
if (null == target)
targetString = "";
else
- targetString = target.toString();
+ targetString = target.toString();
+
+
+
if (childRendered && parentRendered){
if ( !isParentDisabled(child) ){
String childName;
@@ -139,8 +179,19 @@
itemNames.add(childName);
}
+
+ if(child instanceof UIPanelMenuItem){
+ List paramsList = encodeParams(context, (UIPanelMenuItem)child);
+ if(!paramsList.isEmpty()){
+ buffer.append("var params = new Object();");
+ for (Iterator iterator = paramsList.iterator(); iterator.hasNext();) {
+ buffer.append(iterator.next());
+ }
+ }
+ }
+
buffer
- .append("new PanelMenuItem({myId:'")
+ .append("new PanelMenuItem(params,{myId:'")
.append((String) child.getClientId(context))
.append("',parentId:'")
.append((String) child.getParent().getClientId(context))
Modified:
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
===================================================================
---
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-10-05
13:56:15 UTC (rev 3283)
+++
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-10-05
15:22:17 UTC (rev 3284)
@@ -27,14 +27,17 @@
PanelMenuItem = Class.create();
PanelMenuItem.prototype = {
- initialize: function(ids, options, hoveredStyles, hoveredClasses, level,
haveDynamicIcon, action, opened, ajaxFunction, onItemHover, iconAlign, iconExpanded,
iconCollapsed, iconSpacer){
+ initialize: function(params,ids, options, hoveredStyles, hoveredClasses, level,
haveDynamicIcon, action, opened, ajaxFunction, onItemHover, iconAlign, iconExpanded,
iconCollapsed, iconSpacer){
if (!ids.parentId){return};
this.type = options.type;
this.onopen = options.onopen;
+ this.itemId = ids.myId;
this.onclose = options.onclose;
this.event = options.event;
this.disabled = options.disabled;
this.name = options.name;
+ this.params = params;
+ this.myId = ids.myId;
this.mode = options.mode;
if (!this.mode)
@@ -214,7 +217,9 @@
if ("server" == this.mode) {
if (this.target)
form.target = this.target;
- form.submit();
+
+ Richfaces.jsFormSubmit(this.myId, form.name, this.target,this.params);
+ //form.submit();
}
else if ("ajax" == this.mode) {
var event = e;
Modified: trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
===================================================================
--- trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-10-05
13:56:15 UTC (rev 3283)
+++ trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-10-05
15:22:17 UTC (rev 3284)
@@ -17,7 +17,9 @@
<h:scripts>
new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
- /org/richfaces/renderkit/html/scripts/utils.js,
+ /org/richfaces/renderkit/html/scripts/utils.js,
+ /org/ajax4jsf/javascript/scripts/form.js,
+ /org/richfaces/renderkit/html/scripts/form.js
/org/richfaces/renderkit/html/scripts/panelMenu.js,
</h:scripts>