Author: artdaw
Date: 2011-01-18 08:01:51 -0500 (Tue, 18 Jan 2011)
New Revision: 21054
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu-base.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuitem.js
trunk/ui/output/ui/src/main/templates/dropdownmenu.template.xml
trunk/ui/output/ui/src/main/templates/menuitem.template.xml
Log:
RF-10200: bug with action, actionListener attributes is fixed. Also positioning of
DropDownMenu is fixed.
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2011-01-18
12:20:02 UTC (rev 21053)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2011-01-18
13:01:51 UTC (rev 21054)
@@ -96,13 +96,13 @@
if (jointPoint == null) {
jointPoint = org.richfaces.component.Positioning.DEFAULT;
}
- RenderKitUtils.addToScriptHash(map, "jointPoint", jointPoint,
org.richfaces.component.Positioning.DEFAULT);
+ RenderKitUtils.addToScriptHash(map, "jointPoint",
jointPoint.getValue(), org.richfaces.component.Positioning.DEFAULT.getValue());
Positioning direction = group.getDirection();
if (direction == null) {
direction = org.richfaces.component.Positioning.DEFAULT;
}
- RenderKitUtils.addToScriptHash(map, "direction", direction,
org.richfaces.component.Positioning.DEFAULT);
+ RenderKitUtils.addToScriptHash(map, "direction",
direction.getValue(), org.richfaces.component.Positioning.DEFAULT.getValue());
results.add(map);
}
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
===================================================================
---
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2011-01-18
12:20:02 UTC (rev 21053)
+++
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2011-01-18
13:01:51 UTC (rev 21054)
@@ -92,30 +92,23 @@
return "";
}
-
+
protected String getOnClickFunction(FacesContext facesContext, UIComponent component)
{
AbstractMenuItem menuItem = (AbstractMenuItem) component;
Mode subminMode = resolveSubmitMode(menuItem);
- if (menuItem.isDisabled()) {
- return "";
- } else if (subminMode == null || Mode.server.equals(subminMode)) {
- return getServerSubmitFunction(menuItem);
- } else if (Mode.ajax.equals(subminMode)) {
+ if (Mode.ajax.equals(subminMode)) {
return getOnClick(facesContext, menuItem);
- } else if (Mode.client.equals(subminMode)) {
+ } else {
return "";
}
-
- return "";
}
protected Mode resolveSubmitMode(AbstractMenuItem menuItem) {
- Mode submitMode = menuItem.getMode();
- if (null != submitMode) {
- return submitMode;
+ if (menuItem.getMode() != null) {
+ return menuItem.getMode();
}
AbstractDropDownMenu parent = getDDMenu(menuItem);
- if (parent != null) {
+ if (parent != null && parent.getMode() != null) {
return parent.getMode();
}
return Mode.server;
@@ -182,5 +175,9 @@
return false;
}
return true;
- }
+ }
+
+ public String getSubmitMode(UIComponent component){
+ return this.resolveSubmitMode((AbstractMenuItem) component).name();
+ }
}
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu-base.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu-base.js 2011-01-18
12:20:02 UTC (rev 21053)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu-base.js 2011-01-18
13:01:51 UTC (rev 21054)
@@ -70,7 +70,7 @@
navEventHandlers["keydown" + this.namespace] = this.__keydownHandler;
rf.Event.bind(this.popupElement, navEventHandlers, this);
- }
+ };
rf.BaseComponent.extend(rf.ui.MenuBase);
@@ -111,45 +111,41 @@
rf.ui.MenuManager.setActiveSubMenu(rf.$(this.element));
}
this.popupElement.focus();
-
},
- __hidePopup : function() {
- /*
- * for (var i in this.groupList) { this.groupList[i].hide(); }
- */
- if (this.__isShown()) {
- this.invokeEvent("hide", rf.getDomElement(this.id), null);
- this.__closeChildGroups();
- this.popup.hide();
- this.displayed = false;
- this.__deselectCurrentItem();
- this.currentSelectedItemIndex = -1;
- jqueryParentMenu=this.__getParentMenu();
- parentMenu = rf.$(this.__getParentMenu());
- if (this.id != parentMenu.id)
- {
- parentMenu.popupElement.focus();
- rf.ui.MenuManager.setActiveSubMenu(parentMenu);
- }
- }
+ __hidePopup : function() {
+ if (this.__isShown()) {
+ this.invokeEvent("hide", rf.getDomElement(this.id), null);
+ this.__closeChildGroups();
+ this.popup.hide();
+ this.displayed = false;
+ this.__deselectCurrentItem();
+ this.currentSelectedItemIndex = -1;
+ jqueryParentMenu = this.__getParentMenu();
+ parentMenu = rf.$(this.__getParentMenu());
+ if (this.id != parentMenu.id) {
+ parentMenu.popupElement.focus();
+ rf.ui.MenuManager.setActiveSubMenu(parentMenu);
+ }
+ }
+ },
- },
-
- __closeChildGroups : function() {
+ __closeChildGroups : function() {
var i = 0;
- for (i in this.items) {
- menuItem = this.items.eq(i);
- if (this.__isGroup(menuItem)) {
- rf.$(menuItem).hide();
- }
- }
+ var menuItem;
+ for (i in this.items) {
+ menuItem = this.items.eq(i);
+ if (this.__isGroup(menuItem)) {
+ rf.$(menuItem).hide();
+ }
+ }
},
__getParentMenuFromItem : function(item) {
- if (item)
- menu = item.parents('div.rf-ddm-itm')
- .has('div.rf-ddm-lst-bg').eq(1);
+ var menu;
+ if (item)
+ menu = item.parents('div.rf-ddm-itm')
+ .has('div.rf-ddm-lst-bg').eq(1);
if (menu && menu.length > 0)
return menu;
else {
@@ -162,8 +158,8 @@
},
__getParentMenu : function() {
- menu = $(this.element).parents('div.rf-ddm-itm')
- .has('div.rf-ddm-lst-bg').eq(0);
+ var menu = $(this.element).parents('div.rf-ddm-itm')
+ .has('div.rf-ddm-lst-bg').eq(0);
if (menu && menu.length > 0)
return menu;
else {
@@ -174,10 +170,7 @@
__isGroup : function(item) {
var group = item.find('div.' + this.options.listCss);
- if (group.length > 0) {
- return true;
- }
- return false;
+ return group.length > 0;
},
__isDisabled : function(item) {
@@ -218,14 +211,14 @@
}, this), this.options.showDelay);
},
- __leaveHandler : function(e) {
+ __leaveHandler : function() {
window.clearTimeout(this.showTimeoutId);
this.hideTimeoutId = window.setTimeout($.proxy(function() {
this.hide();
}, this), this.options.hideDelay);
},
- __overHandler : function(e) {
+ __overHandler : function() {
window.clearTimeout(this.hideTimeoutId);
},
@@ -239,4 +232,4 @@
};
})());
-})(jQuery, RichFaces)
\ No newline at end of file
+})(jQuery, RichFaces);
\ No newline at end of file
Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js 2011-01-18
12:20:02 UTC (rev 21053)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js 2011-01-18
13:01:51 UTC (rev 21054)
@@ -19,7 +19,7 @@
disabledItemCss : "rf-ddm-itm-dis",
listCss : "rf-ddm-lst",
listContainerCss : "rf-ddm-lst-bg"
- }
+ };
// constructor definition
rf.ui.Menu = function(componentId, options) {
@@ -53,45 +53,32 @@
var groupId = groupOptions[i].id;
var positionOffset = [
groupOptions[i].horizontalOffset,
- groupOptions[i].verticalOffset]
+ groupOptions[i].verticalOffset];
var onshow = groupOptions[i].onshow;
var onhide = groupOptions[i].onhide;
- var eventType = "mouseover";
+ //var eventType = "mouseover";
if (null != groupId) {
// var popup = new RichFaces.ui.Popup(groupId +
// '_list', options);
- var group = new RichFaces.ui.MenuGroup(groupId,
- {
- rootMenuId : this.id,
- onshow : onshow,
- onhide : onhide
- });
- this.groupList[groupId] = group;
+ this.groupList[groupId] = new
RichFaces.ui.MenuGroup(groupId,
+ {
+ rootMenuId : this.id,
+ onshow : onshow,
+ onhide : onhide,
+ positionOffset: positionOffset
+ });
}
}
},
- submitForm : function(item) {
- var form = this.__getParentForm(item);
- if (this.options.mode == "server") {
- rf.submitForm(form, {
- selectedMenuItem : item.id
- });
- }
- if (this.options.mode == "ajax") {
- rf.ajax(item.id);
- }
- },
-
show : function() {
if (this.menuManager.openedMenu != this.id) {
this.menuManager.shutdownMenu();
this.menuManager.addMenuId(this.id);
this.__showPopup();
}
- this.popupElement.focus();
},
hide : function() {
@@ -99,10 +86,6 @@
this.menuManager.deletedMenuId();
},
- __getParentForm : function(item) {
- return item.parents("form")[0];
- },
-
destroy : function() {
// clean up code here
this.detach(this.id);
@@ -142,4 +125,4 @@
}
}
-})(jQuery, RichFaces)
\ No newline at end of file
+})(jQuery, RichFaces);
\ No newline at end of file
Modified:
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuitem.js
===================================================================
---
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuitem.js 2011-01-18
12:20:02 UTC (rev 21053)
+++
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/menuitem.js 2011-01-18
13:01:51 UTC (rev 21054)
@@ -1,69 +1,82 @@
(function($, rf) {
- rf.ui = rf.ui || {};
-
- var defaultOptions = {
- selectItemCss : "rf-ddm-itm-sel",
- unselectItemCss : "rf-ddm-itm-unsel",
-
- }
-
- // constructor definition
-
- rf.ui.MenuItem = function(componentId, options) {
- this.options = options;
- $super.constructor.call(this, componentId);
- this.attachToDom(componentId);
- this.element = $(rf.getDomElement(componentId));
- rf.Event.bindById(this.id,'click', this.__clickHandler, this);
- rf.Event.bindById(this.id,'mouseenter',this.select, this);
- rf.Event.bindById(this.id,'mouseleave',this.unselect, this);
- this.selected = false;
- }
-
- rf.BaseComponent.extend(rf.ui.MenuItem);
-
- // define super class link
- var $super = rf.ui.MenuItem.$super;
-
- $.extend(rf.ui.MenuItem.prototype, (function() {
-
- return {
- name : "MenuItem",
- select : function() {
- this.element.removeClass('rf-ddm-itm-unsel');
- this.element.addClass('rf-ddm-itm-sel');
- this.selected = true;
- },
- unselect : function() {
- this.element.removeClass('rf-ddm-itm-sel');
- this.element.addClass('rf-ddm-itm-unsel');
- this.selected = false;
- },
- activate : function() {
- this.invokeEvent('click',rf.getDomElement(this.id));
- },
-
- isSelected : function() {
- return this.selected;
- },
-
- __clickHandler : function (e) {
- parentMenu = this.__getParentMenu();
- if (parentMenu){
- this.__getParentMenu().processItem(this.element);
- }
- if (this.options.submitFunction){
- this.options.submitFunction.call(this,e);
- }
- },
-
- __getParentMenu : function () {
- menu = this.element.parents('div.rf-ddm-lbl');
- if (menu && menu.length > 0) return rf.$(menu);
- else return null;
-
- },
- };
-})());
-
-})(jQuery, RichFaces)
\ No newline at end of file
+ rf.ui = rf.ui || {};
+
+ // constructor definition
+
+ rf.ui.MenuItem = function(componentId, options) {
+ this.options = options;
+ $super.constructor.call(this, componentId);
+ this.attachToDom(componentId);
+ this.element = $(rf.getDomElement(componentId));
+ rf.Event.bindById(this.id, 'click', this.__clickHandler, this);
+ rf.Event.bindById(this.id, 'mouseenter', this.select, this);
+ rf.Event.bindById(this.id, 'mouseleave', this.unselect, this);
+ this.selected = false;
+ };
+
+ rf.BaseComponent.extend(rf.ui.MenuItem);
+
+ // define super class link
+ var $super = rf.ui.MenuItem.$super;
+
+ $.extend(rf.ui.MenuItem.prototype, (function() {
+
+ return {
+ name : "MenuItem",
+ select : function() {
+ this.element.removeClass('rf-ddm-itm-unsel');
+ this.element.addClass('rf-ddm-itm-sel');
+ this.selected = true;
+ },
+ unselect : function() {
+ this.element.removeClass('rf-ddm-itm-sel');
+ this.element.addClass('rf-ddm-itm-unsel');
+ this.selected = false;
+ },
+ activate : function() {
+ this.invokeEvent('click', rf.getDomElement(this.id));
+ },
+
+ isSelected : function() {
+ return this.selected;
+ },
+
+ __clickHandler : function (e) {
+ var parentMenu = this.__getParentMenu();
+ if (parentMenu) {
+ this.__getParentMenu().processItem(this.element);
+ }
+
+ this.__submitForm(rf.getDomElement(this.id), e);
+ },
+
+ /**
+ *
+ * @param item DOM element
+ */
+ __submitForm : function(item, e) {
+ var form = this.__getParentForm(item);
+ var itemId = {};
+ itemId[item.id] = item.id;
+ if (this.options.mode == "server") {
+ rf.submitForm(form, itemId);
+ }
+ if (this.options.mode == "ajax" &&
this.options.submitFunction) {
+ this.options.submitFunction.call(this, e);
+ }
+ },
+
+ __getParentForm : function(item) {
+ return $($(item).parents("form").get(0));
+ },
+
+ __getParentMenu : function () {
+ var menu = this.element.parents('div.rf-ddm-lbl');
+ if (menu && menu.length > 0) return rf.$(menu);
+ else return null;
+
+ }
+ };
+ })());
+
+})(jQuery, RichFaces);
\ No newline at end of file
Modified: trunk/ui/output/ui/src/main/templates/dropdownmenu.template.xml
===================================================================
--- trunk/ui/output/ui/src/main/templates/dropdownmenu.template.xml 2011-01-18 12:20:02
UTC (rev 21053)
+++ trunk/ui/output/ui/src/main/templates/dropdownmenu.template.xml 2011-01-18 13:01:51
UTC (rev 21054)
@@ -50,8 +50,8 @@
<script type="text/javascript">
<cdk:scriptObject name="options">
- <cdk:scriptOption name="direction"
value="#{getDirection(component)}"/>
- <cdk:scriptOption name="jointPoint"
value="#{getJointPoint(component)}"/>
+ <cdk:scriptOption name="direction"
value="#{getDirection(component).getValue()}"/>
+ <cdk:scriptOption name="jointPoint"
value="#{getJointPoint(component).getValue()}"/>
<cdk:scriptOption name="showEvent"
value="#{getShowEvent(component)}"/>
<cdk:scriptOption name="mode"
value="#{getMode(component)}"/>
<cdk:scriptOption attributes="hideDelay showEvent showDelay
horizontalOffset verticalOffset" />
Modified: trunk/ui/output/ui/src/main/templates/menuitem.template.xml
===================================================================
--- trunk/ui/output/ui/src/main/templates/menuitem.template.xml 2011-01-18 12:20:02 UTC
(rev 21053)
+++ trunk/ui/output/ui/src/main/templates/menuitem.template.xml 2011-01-18 13:01:51 UTC
(rev 21054)
@@ -80,7 +80,8 @@
<c:when test="#{not isDisabled}">
<script type="text/javascript">
<cdk:scriptObject name="options">
- <cdk:scriptOption name="submitFunction"
value="#{getOnClickFunction(facesContext, component)}"
wrapper="eventHandler"/>
+ <cdk:scriptOption name="mode"
value="#{getSubmitMode(component)}" />
+ <cdk:scriptOption name="submitFunction"
value="#{getOnClickFunction(facesContext, component)}"
wrapper="eventHandler"/>
</cdk:scriptObject>
new RichFaces.ui.MenuItem(#{toScriptArgs(clientId, options)});