Author: sergeyhalipov
Date: 2007-05-22 10:08:14 -0400 (Tue, 22 May 2007)
New Revision: 830
Modified:
trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuItem.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
Log:
Panel menu: target, width, mode, expandMode attributes added;
Modified: trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml
===================================================================
--- trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml 2007-05-22 12:16:34
UTC (rev 829)
+++ trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml 2007-05-22 14:08:14
UTC (rev 830)
@@ -295,7 +295,7 @@
Set the submission mode for all panel menu groups after expand/collapse
except ones where this attribute redefined. (ajax, server, none(Default))
</description>
- <defaultvalue><![CDATA["none"]]></defaultvalue>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
<name>iconExpanded</name>
@@ -439,7 +439,7 @@
<description>
Set the submission mode (ajax,server(Default),none)
</description>
- <defaultvalue><![CDATA["server"]]></defaultvalue>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
<name>icon</name>
@@ -518,5 +518,10 @@
&ui_command_attributes;
&html_style_attributes;
&html_events;
+ <property>
+ <name>target</name>
+ <classname>java.lang.String</classname>
+ <description>Target frame for action to execute.</description>
+ </property>
</component>
</components>
\ No newline at end of file
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java 2007-05-22
12:16:34 UTC (rev 829)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java 2007-05-22
14:08:14 UTC (rev 830)
@@ -21,9 +21,11 @@
package org.richfaces.component.panelmenu;
+import javax.faces.component.UICommand;
+
import org.richfaces.component.UISwitchablePanel;
-public abstract class UIPanelMenuGroup extends UISwitchablePanel {
+public abstract class UIPanelMenuGroup extends UICommand {
public static final String COMPONENT_TYPE = "org.richfaces.panelMenuGroup";
@@ -47,12 +49,8 @@
public abstract void setDisabled(boolean disabled);
public abstract Object getValue();
public abstract void setValue(Object value);
- public abstract String getAction();
- public abstract void setAction(String action);
public abstract String getTarget();
public abstract void setTarget(String target);
- /*public abstract boolean isImmediate();
- public abstract void setImmediate(boolean immediate);*/
public abstract String getHoverClass();
public abstract void setHoverClass(String hoverClass);
public abstract String getHoverStyle();
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuItem.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuItem.java 2007-05-22
12:16:34 UTC (rev 829)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuItem.java 2007-05-22
14:08:14 UTC (rev 830)
@@ -53,5 +53,6 @@
public abstract void setIconClass(String iconClass);
public abstract String getIconStyle();
public abstract void setIconStyle(String iconStyle);
-
+ public abstract String getTarget();
+ public abstract void setTarget(String target);
}
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-22
12:16:34 UTC (rev 829)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-22
14:08:14 UTC (rev 830)
@@ -29,7 +29,9 @@
import javax.faces.context.ResponseWriter;
import javax.faces.event.ActionEvent;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.ajax4jsf.framework.util.style.CSSFormat;
+import org.richfaces.component.UISwitchablePanel;
import org.richfaces.component.panelmenu.UIPanelMenu;
import org.richfaces.component.panelmenu.UIPanelMenuGroup;
@@ -41,20 +43,25 @@
protected void doDecode(FacesContext context, UIComponent component) {
String clientId = component.getClientId(context);
Map requestMap =context.getExternalContext().getRequestParameterMap();
+ UIPanelMenuGroup group = ((UIPanelMenuGroup)component);
if(requestMap.containsKey("panelMenuState"+clientId)){
Object property = requestMap.get("panelMenuState"+clientId);
if (property.equals("opened")) {
- ((UIPanelMenuGroup)component).setExpanded(true);
+ group.setExpanded(true);
} else if (property.equals("closed")) {
((UIPanelMenuGroup)component).setExpanded(false);
}
}
if(isSubmitted(context, component)){
- ActionEvent actionEvent = new ActionEvent(component);
- component.queueEvent(actionEvent);
+ if (UISwitchablePanel.SERVER_METHOD.equals(getItemMode(group))) {
+ ActionEvent actionEvent = new ActionEvent(component);
+ component.queueEvent(actionEvent);
+ } else if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(group))) {
+ new AjaxEvent(component).queue();
+ }
}
}
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-05-22
12:16:34 UTC (rev 829)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-05-22
14:08:14 UTC (rev 830)
@@ -33,7 +33,9 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.resource.InternetResourceBuilder;
+import org.ajax4jsf.framework.util.javascript.JSFunction;
import org.richfaces.component.panelmenu.UIPanelMenu;
import org.richfaces.component.panelmenu.UIPanelMenuGroup;
import org.richfaces.component.panelmenu.UIPanelMenuItem;
@@ -72,6 +74,7 @@
.append(");\n");
String iconPosition = ((UIPanelMenu)component).getIconItemPosition();
String iconPositionTopLevel = ((UIPanelMenu)component).getIconItemTopPosition();
+
for (Iterator iter = flatList.iterator(); iter.hasNext();) {
UIComponent child = (UIComponent) iter.next();
if ((child instanceof UIPanelMenuItem)||(child instanceof UIPanelMenuGroup)) {
@@ -107,6 +110,13 @@
String [] hoveredStyles = hoveredStyle.split(";");
String [] hoveredClasses = hoveredClass.split(" ");
+ String mode = getItemMode(child);
+ Object target = child.getAttributes().get("target");
+ String targetString;
+ if (null == target)
+ targetString = "";
+ else
+ targetString = target.toString();
if (childRendered && parentRendered){
if (childDisabled==null || !childDisabled.equals("true")){
@@ -118,6 +128,8 @@
.append("'},{type:" + (child instanceof UIPanelMenuItem ?
"\"item\"":"\"node\""))
.append(",onopen:"+(onopen.equals("") ?
"\"\"" : "\"" + onopen +
"\"")+",onclose:"+(onclose.equals("") ?
"\"\"" : "\"" + onclose + "\""))
.append(",event:\"" + event + "\"")
+ .append(",mode:\"" + mode + "\"")
+ .append(",target:\"" + targetString + "\"")
.append("},{");
@@ -157,7 +169,9 @@
addImages(buffer,context,child,component.getClientId(context).toString());
- buffer.append("\n");
+ addAjaxFunction(context,child,buffer);
+
+ buffer.append(");\n");
}
} else {
continue;
@@ -335,26 +349,38 @@
String iconExpandedScript = ("".equals(iconNodeOpened)) ? "null"
: "\"" + iconExpandedSource + "\"";
buffer.append("," + iconExpandedScript + "," +
iconCollapsedScript);
}
- buffer.append(",\"" + PANEL_MENU_SPACER_ICON + "\");");
+ buffer.append(",\"" + PANEL_MENU_SPACER_ICON + "\"");
} else {
if (!"".equals(iconItem)){
if (!iconItem.equals("custom")){
if(component.getAttributes().get("icon").equals("")){
- buffer.append(","+'"'+sourceIconItem+'"').append(","+'"'+sourceIconItem+'"'+");");
+ buffer.append(","+'"'+sourceIconItem+'"').append(","+'"'+sourceIconItem+'"'+"
");
} else {
- buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+");");
+ buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+"
");
}
} else {
if(component.getAttributes().get("icon").equals("")){
- buffer.append(","+'"'+PANEL_MENU_SPACER_ICON+'"').append(","+'"'+PANEL_MENU_SPACER_ICON+'"'+");");
+ buffer.append(","+'"'+PANEL_MENU_SPACER_ICON+'"').append(","+'"'+PANEL_MENU_SPACER_ICON+'"'+"
");
} else {
- buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+");");
+ buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+"
");
}
}
} else {
- buffer.append(");");
+ buffer.append(" ");
}
}
}
+ protected void addAjaxFunction(FacesContext context, UIComponent child, StringBuffer
buffer) {
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(child,
+ context);
+ Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
+ child);
+ function.addParameter(eventOptions);
+
+ buffer.append(",\"");
+ function.appendScript(buffer);
+ buffer.append("\"");
+ }
+
}
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-22
12:16:34 UTC (rev 829)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-22
14:08:14 UTC (rev 830)
@@ -36,6 +36,7 @@
import org.ajax4jsf.framework.util.style.CSSFormat;
import org.richfaces.component.panelmenu.UIPanelMenu;
import org.richfaces.component.panelmenu.UIPanelMenuGroup;
+import org.richfaces.component.panelmenu.UIPanelMenuItem;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrow;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrowDown;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrowUp;
@@ -206,4 +207,28 @@
return submitted;
}
+ protected String getItemMode(UIComponent component) {
+ String parentExpandMode = findMenu(component).getExpandMode();
+ String parentMode = findMenu(component).getMode();
+ if (null == parentMode && "".equals(parentMode))
+ parentMode = "server";
+ if (null == parentExpandMode && "".equals(parentExpandMode))
+ parentExpandMode = "none";
+ String mode = "none";
+ if (component instanceof UIPanelMenuGroup) {
+ UIPanelMenuGroup group = (UIPanelMenuGroup) component;
+ if (null != group.getMode() && ! "".equals(group.getMode()))
+ mode = group.getMode();
+ else
+ mode = parentExpandMode;
+ } else if (component instanceof UIPanelMenuItem) {
+ UIPanelMenuItem item = (UIPanelMenuItem) component;
+ if (null != item.getMode() && ! "".equals(item.getMode()))
+ mode = item.getMode();
+ else
+ mode = parentMode;
+ }
+ return mode;
+ }
+
}
Modified:
trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
===================================================================
---
trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-05-22
12:16:34 UTC (rev 829)
+++
trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-05-22
14:08:14 UTC (rev 830)
@@ -17,12 +17,21 @@
PanelMenuStorage[myId] = this;}};
PanelMenuItem = Class.create();
PanelMenuItem.prototype = {
- initialize: function(ids, options, hoveredStyles, hoveredClasses, level,
haveDynamicIcon, action, opened, iconAlign, iconExpanded, iconCollapsed, iconSpacer){
+ initialize: function(ids, options, hoveredStyles, hoveredClasses, level,
haveDynamicIcon, action, opened, iconAlign, iconExpanded, iconCollapsed, iconSpacer,
+ ajaxFunction){
if (!ids.parentId){return};
this.type = options.type;
this.onopen = options.onopen;
this.onclose = options.onclose;
this.event = options.event;
+
+ this.mode = options.mode;
+ if (!this.mode)
+ this.mode = ("node" == this.type) ? "none" : "server";
+
+ this.ajaxSubmit = ajaxFunction;
+ this.target = options.target;
+
this.hoveredStyles = hoveredStyles;
this.hoveredClasses = hoveredClasses;
this.tdhider = $("tdhide"+ids.myId);
@@ -139,6 +148,7 @@
}
this.expanded = true;
},
+
show: function(){
if (this.type!="node")
this.inputState.value="opened";
@@ -150,7 +160,10 @@
preTrigger:function(e){
this.inputAction.setAttribute('value', this.obj.id);
},
+
trigger:function(e){
+ if ("none" == this.mode)
+ return;
if (this.action !="panelMenuItemAction"){
this.preTrigger(e);
var form = Event.findElement(e, "form");
@@ -161,7 +174,15 @@
form.action = action;
document.body.appendChild(form);
}
- form.submit();
+ if ("server" == this.mode) {
+ if (this.target)
+ form.target = this.target;
+ form.submit();
+ }
+ else if ("ajax" == this.mode) {
+ var event = e;
+ eval(this.ajaxSubmit);
+ }
}
},
Modified: trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx
===================================================================
---
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-05-22
12:16:34 UTC (rev 829)
+++
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenu.jspx 2007-05-22
14:08:14 UTC (rev 830)
@@ -25,7 +25,7 @@
<f:call name="utils.encodeBeginFormIfNessesary"/>
<table cellpadding="0" cellspacing="0"
style="#{component.style};" class="#{component.styleClass}"
- id="#{clientId}" >
+ id="#{clientId}" width="#{component.width}" >
<tbody>
<vcp:body>