Author: nbelaevski
Date: 2009-03-23 15:43:48 -0400 (Mon, 23 Mar 2009)
New Revision: 13127
Removed:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBaseChildrenHolder.java
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
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/htmlPanelMenuGroup.jspx
trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
trunk/ui/panelmenu/src/test/java/org/richfaces/component/PanelMenuComponentTest.java
Log:
Changes for
https://jira.jboss.org/jira/browse/RF-6119 reverted.
https://jira.jboss.org/jira/browse/RF-6583
Modified: trunk/ui/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java
===================================================================
---
trunk/ui/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java 2009-03-23
18:50:40 UTC (rev 13126)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/component/UIPanelMenuGroup.java 2009-03-23
19:43:48 UTC (rev 13127)
@@ -22,7 +22,6 @@
package org.richfaces.component;
import javax.faces.component.ActionSource2;
-import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.BooleanConverter;
import javax.faces.el.MethodBinding;
@@ -39,15 +38,6 @@
public static final String COMPONENT_TYPE = "org.richfaces.panelMenuGroup";
- public static final String EXPAND_MODE_AJAX = "ajax";
- public static final String EXPAND_MODE_SERVER = "server";
- public static final String EXPAND_MODE_NONE = "none";
-
- /*
- * It is same as "none" if you don't set expand mode
- * */
- public static final String EXPAND_MODE_EMPTY = "";
-
public abstract String getStyleClass();
public abstract void setStyleClass(String styleClass);
@@ -79,7 +69,6 @@
public abstract String getIconStyle();
public abstract void setIconStyle(String iconStyle);
public abstract String getOncollapse();
-
public abstract void setOncollapse(String ongroupcollapse);
public abstract String getOnexpand();
public abstract void setOnexpand(String ongroupexpand);
@@ -88,16 +77,8 @@
public abstract void setName(String string);
public abstract String getName();
- public boolean isParentDisabled() {
- UIComponent parent = this.getParent();
- if(!(parent instanceof UIPanelMenuGroup)){
- return false;
- }
-
- return this.isDisabled() || ((UIPanelMenuGroup) parent).isParentDisabled();
- }
-
- public boolean isExpanded(){
+ public boolean isExpanded(){
+
Object value = getValue();
if(value == null){
return false;
@@ -161,8 +142,8 @@
}
// Invoke the default ActionListener
- ActionListener listener =
- context.getApplication().getActionListener();
+ ActionListener listener =
+ context.getApplication().getActionListener();
if (listener != null) {
listener.processAction((ActionEvent) event);
}
@@ -170,11 +151,6 @@
super.broadcast(event);
}
}
+
- public boolean isNoneExpandMode() {
- String trimedMode = this.getExpandMode().trim().toLowerCase();
- return EXPAND_MODE_NONE.equals(trimedMode)
- || EXPAND_MODE_EMPTY.equals(trimedMode);
- }
-
}
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
---
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2009-03-23
18:50:40 UTC (rev 13126)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2009-03-23
19:43:48 UTC (rev 13127)
@@ -63,7 +63,7 @@
String src = getIconByType("custom",false,context,component);
int w = 16; //width(context);
- for (int i=0; i<level; i++){
+ for (int i=0;i<level;i++){
writer.startElement("img", component);
writer.writeAttribute("src", src, null);
writer.writeAttribute("alt", " ", null);
@@ -171,50 +171,46 @@
public void insertLabel(FacesContext context, UIComponent component) throws IOException
{
Object value = component.getAttributes().get("label");
- if (value!=null) {
+ if (value!=null){
context.getResponseWriter().writeText(value, null);
}
}
protected boolean isChildrenExpanded(UIComponent component){
- if (component.getChildren() == null) {
- return false;
- }
-
- Iterator<UIComponent> itr = component.getChildren().iterator();
- while (itr.hasNext()) {
- UIComponent child = itr.next();
- if (child instanceof UIPanelMenuGroup) {
- if (((UIPanelMenuGroup) child).isExpanded()) {
- return true;
- } else {
- return isChildrenExpanded(child);
- }
- }
- }
+ if (component.getChildren() != null){
+ Iterator itr = component.getChildren().iterator();
+ while(itr.hasNext()){
+ UIComponent child = (UIComponent)itr.next();
+ if(child instanceof UIPanelMenuGroup){
+ if( ((UIPanelMenuGroup)child).isExpanded() ){
+ return true;
+ } else {
+ return isChildrenExpanded(child);
+ }
+ }
+ }
+ }
return false;
}
protected boolean isParentDisabled(UIComponent component){
+ boolean returnValue = false;
UIComponent parent = component.getParent();
- if(!(parent instanceof UIPanelMenuGroup)){
- return false;
+ if(parent instanceof UIPanelMenuGroup){
+ UIPanelMenuGroup parentGroup = (UIPanelMenuGroup)parent;
+ if(parentGroup.isDisabled()){
+ returnValue = true;
+ } else {
+ returnValue = isParentDisabled(parentGroup);
+ }
}
-
- UIPanelMenuGroup parentGroup = (UIPanelMenuGroup) parent;
- return parentGroup.isDisabled() || isParentDisabled(parentGroup);
+ return returnValue;
}
- protected boolean isParentExpended(UIComponent component){
- UIComponent parent = component.getParent();
- return parent instanceof UIPanelMenuGroup
- && ((UIPanelMenuGroup)parent).isExpanded();
- }
-
protected boolean isSubmitted(FacesContext context, UIComponent component){
boolean submitted = false;
String clientId = component.getClientId(context);
- Map<String, String> requestParameterMap =
context.getExternalContext().getRequestParameterMap();
+ Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
Object value = requestParameterMap.get("panelMenuAction"+clientId);
if (clientId!=null&&value!=null){
@@ -226,31 +222,25 @@
}
protected String getItemMode(UIComponent component) {
+ String parentExpandMode = findMenu(component).getExpandMode();
String parentMode = findMenu(component).getMode();
- if (null == parentMode || "".equals(parentMode)) {
+ if (null == parentMode || "".equals(parentMode))
parentMode = "server";
- }
-
- String parentExpandMode = findMenu(component).getExpandMode();
- if (null == parentExpandMode || "".equals(parentExpandMode)) {
+ if (null == parentExpandMode || "".equals(parentExpandMode))
parentExpandMode = "none";
- }
-
String mode = "none";
if (component instanceof UIPanelMenuGroup) {
UIPanelMenuGroup group = (UIPanelMenuGroup) component;
- if (null != group.getExpandMode() && !
"".equals(group.getExpandMode())) {
+ if (null != group.getExpandMode() && !
"".equals(group.getExpandMode()))
mode = group.getExpandMode();
- } else {
- mode = parentExpandMode;
- }
+ else
+ mode = parentExpandMode;
} else if (component instanceof UIPanelMenuItem) {
UIPanelMenuItem item = (UIPanelMenuItem) component;
- if (null != item.getMode() && ! "".equals(item.getMode())) {
+ if (null != item.getMode() && ! "".equals(item.getMode()))
mode = item.getMode();
- } else {
+ else
mode = parentMode;
- }
}
return mode;
}
@@ -265,8 +255,11 @@
while( !(parent instanceof UIPanelMenu) && !(parent instanceof
UIPanelMenuGroup)) {
parent = parent.getParent();
}
-
- return parent instanceof UIPanelMenu;
+ if(parent instanceof UIPanelMenu){
+ return true;
+ } else {
+ return false;
+ }
}
/**
@@ -295,25 +288,5 @@
}
}
-
- public void registerComponent(FacesContext context, UIComponent component) {
- if (component instanceof UIPanelMenuGroup || component instanceof UIPanelMenuItem) {
- int level = 0;
- UIComponent c = component;
- while ((c = c.getParent()) != null) {
- if (c instanceof UIPanelMenuGroup) {
- level++;
- } else if (c instanceof UIPanelMenu) {
- UIPanelMenu parentMenu = (UIPanelMenu) c;
-
- PanelMenuRendererBaseChildrenHolder childrenHolder =
PanelMenuRendererBaseChildrenHolder.getChildrenHolder(parentMenu);
- if (childrenHolder != null) {
- childrenHolder.registerChild(component, level);
- }
- break;
- }
- }
- }
- }
}
Deleted:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBaseChildrenHolder.java
===================================================================
---
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBaseChildrenHolder.java 2009-03-23
18:50:40 UTC (rev 13126)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBaseChildrenHolder.java 2009-03-23
19:43:48 UTC (rev 13127)
@@ -1,90 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-
-import org.richfaces.component.UIPanelMenu;
-
-public final class PanelMenuRendererBaseChildrenHolder {
-
- private static final String CHILDREN_HOLDER_ATTRIBUTE =
"_panelMenuRendererBaseChildrenHolder";
-
- public static final class Item {
- private UIComponent component;
- private int level;
-
- private Item(UIComponent component, int level) {
- super();
- this.component = component;
- this.level = level;
- }
-
- public UIComponent getComponent() {
- return component;
- }
-
- public int getLevel() {
- return level;
- }
- }
-
- private List<PanelMenuRendererBaseChildrenHolder.Item> children = new
ArrayList<PanelMenuRendererBaseChildrenHolder.Item>();
-
- private Object initialAttributeValue;
-
- private UIComponent component;
-
- public PanelMenuRendererBaseChildrenHolder(UIComponent component) {
- super();
-
- this.component = component;
- this.initialAttributeValue = component.getAttributes().put(CHILDREN_HOLDER_ATTRIBUTE,
this);
- }
-
- public void unregister() {
- Map<String, Object> attributes = component.getAttributes();
-
- if (this.initialAttributeValue != null) {
- attributes.put(CHILDREN_HOLDER_ATTRIBUTE, initialAttributeValue);
- } else {
- attributes.remove(CHILDREN_HOLDER_ATTRIBUTE);
- }
- }
-
- public static PanelMenuRendererBaseChildrenHolder getChildrenHolder(UIPanelMenu
panelMenu) {
- return (PanelMenuRendererBaseChildrenHolder)
- panelMenu.getAttributes().get(CHILDREN_HOLDER_ATTRIBUTE);
- }
-
- void registerChild(UIComponent child, int level) {
- this.children.add(new Item(child, level));
- }
-
- public List<PanelMenuRendererBaseChildrenHolder.Item> getChildren() {
- return children;
- }
-}
\ No newline at end of file
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java
===================================================================
---
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2009-03-23
18:50:40 UTC (rev 13126)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuGroupRenderer.java 2009-03-23
19:43:48 UTC (rev 13127)
@@ -37,28 +37,27 @@
public class PanelMenuGroupRenderer extends PanelMenuRendererBase {
- protected Class<? extends UIComponent> getComponentClass() {
+ protected Class getComponentClass() {
return UIPanelMenuGroup.class;
}
protected void doDecode(FacesContext context, UIComponent component) {
String clientId = component.getClientId(context);
- Map<String, String> requestMap =
- context.getExternalContext().getRequestParameterMap();
- UIPanelMenuGroup group = (UIPanelMenuGroup)component;
+ Map requestMap =context.getExternalContext().getRequestParameterMap();
+ UIPanelMenuGroup group = ((UIPanelMenuGroup)component);
- if (requestMap.containsKey("panelMenuState"+clientId)) {
+ if(requestMap.containsKey("panelMenuState"+clientId)){
Object property = requestMap.get("panelMenuState"+clientId);
if (property.equals("opened")) {
group.setSubmittedValue("true");
} else if (property.equals("closed")) {
group.setSubmittedValue("false");
}
+
}
-
if(isSubmitted(context, component)){
new ActionEvent(component).queue();
- if (UIPanelMenuGroup.EXPAND_MODE_AJAX.equals(getItemMode(component))) {
+ if ("ajax".equals(getItemMode(component))) {
new AjaxEvent(component).queue();
}
}
@@ -163,9 +162,8 @@
}
}
- if ("".equals(icon)) {
+ if ("".equals(icon))
icon = "custom";
- }
String source = getIconByType(icon, isTopLevel, context, component);
boolean drawHidden = false;
if (source != null && source.trim().length() == 0) {
@@ -207,7 +205,7 @@
return styleBuffer.toString();
}
- public void insertLabel (FacesContext context, UIComponent component) throws IOException
{
+ public void insertLabel(FacesContext context, UIComponent component) throws IOException
{
Object label = component.getAttributes().get("label");
if (label!=null){
context.getResponseWriter().writeText(label, null);
@@ -219,7 +217,7 @@
throws ConverterException {
UIPanelMenuGroup group = (UIPanelMenuGroup)component;
- if (group.getConverter() != null) {
+ if(group.getConverter() != null){
return group.getConverter().getAsObject(context, component, (String)submittedValue);
} else {
return submittedValue;
@@ -227,7 +225,7 @@
}
- public boolean isOpened (FacesContext context, UIComponent component) throws IOException
{
+ public boolean isOpened(FacesContext context, UIComponent component)throws IOException
{
boolean value = false;
if(component instanceof UIPanelMenuGroup){
@@ -242,9 +240,11 @@
} else {
//check expanded attributes in children groups, if exists
boolean isChildrenExpanded = isChildrenExpanded(component);
- value = isChildrenExpanded && disabled;
+ value = isChildrenExpanded && disabled; // ? "opened" :
"closed";
}
+
}
+
return value;
}
@@ -305,11 +305,10 @@
public String getTableClass(FacesContext context, UIComponent component) {
String result;
- if (isTopLevel(component)) {
+ if (isTopLevel(component))
result = "dr-pmenu-top-group rich-pmenu-top-group ";
- } else {
+ else
result = "dr-pmenu-group";
- }
return result;
}
@@ -319,16 +318,4 @@
return group.getName().equals(parentMenu.getSelectedName());
}
- @Override
- public void renderChildren(FacesContext facesContext, UIComponent component)
- throws IOException {
-
- if (((UIPanelMenuGroup) component).isNoneExpandMode()
- || isOpened(facesContext, component)) {
- super.renderChildren(facesContext, component);
- }
- }
-
-
-
}
Modified:
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java
===================================================================
---
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2009-03-23
18:50:40 UTC (rev 13126)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuItemRenderer.java 2009-03-23
19:43:48 UTC (rev 13127)
@@ -34,7 +34,7 @@
import org.richfaces.renderkit.PanelMenuRendererBase;
public class PanelMenuItemRenderer extends PanelMenuRendererBase {
- protected Class<? extends UIComponent> getComponentClass() {
+ protected Class getComponentClass() {
return UIPanelMenuItem.class;
}
@@ -42,7 +42,8 @@
}
protected void doDecode(FacesContext context, UIComponent component) {
- if (isSubmitted(context, component)) {
+ if(isSubmitted(context, component)) {
+ UIPanelMenuItem item = (UIPanelMenuItem)component;
new ActionEvent(component).queue();
if ("ajax".equals(getItemMode(component))) {
new AjaxEvent(component).queue();
@@ -87,9 +88,9 @@
throws IOException{
UIPanelMenu panelMenu = findMenu(component);
- ResponseWriter writer = context.getResponseWriter();
- boolean isTopLevel = isTopLevel(component);
- String iconType = null;
+ ResponseWriter writer = context.getResponseWriter();
+ boolean isTopLevel = isTopLevel(component);
+ String iconType = null;
UIPanelMenuItem item = (UIPanelMenuItem)component;
String defaultItemIcon = null;
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 2009-03-23
18:50:40 UTC (rev 13126)
+++
trunk/ui/panelmenu/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2009-03-23
19:43:48 UTC (rev 13127)
@@ -23,8 +23,10 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -37,35 +39,31 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.ComponentVariables;
-import org.ajax4jsf.renderkit.ComponentsVariableResolver;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIPanelMenu;
import org.richfaces.component.UIPanelMenuGroup;
import org.richfaces.component.UIPanelMenuItem;
-import org.richfaces.renderkit.PanelMenuRendererBaseChildrenHolder;
import org.richfaces.renderkit.PanelMenuRendererBase;
public class PanelMenuRenderer extends PanelMenuRendererBase {
- private static final String CHILDREN_HOLDER = "childrenHolder";
-
- private static final String FIRST_EXPANDED_ENCODED = "firstExpandedEncoded";
-
/* (non-Javadoc)
* @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
*/
- protected Class<? extends UIComponent> getComponentClass() {
+
+ protected Class getComponentClass() {
return UIComponent.class;
}
// find and encode UIParameter's components
- public List<String> encodeParams(FacesContext context, UIPanelMenuItem
menuItem) throws IOException {
+ public List encodeParams(FacesContext context, UIPanelMenuItem component) throws
IOException {
- List<String> params = new ArrayList<String>();
+ UIPanelMenuItem menuItem = component;
+ List params = new ArrayList();
+ StringBuffer buff = new StringBuffer();
- List<UIComponent> children = menuItem.getChildren();
- for (Iterator<UIComponent> iterator = children.iterator();
iterator.hasNext();) {
+ List children = menuItem.getChildren();
+ for (Iterator iterator = children.iterator(); iterator.hasNext();) {
UIComponent child = (UIComponent) iterator.next();
if(child instanceof UIParameter){
@@ -75,11 +73,14 @@
if (name != null) {
Object value = param.getValue();
- StringBuffer buff = new StringBuffer();
- buff.append("params[").append(ScriptUtils.toScript(name)).append("] =
")
- .append(ScriptUtils.toScript(value)).append(";");
+ buff.append("params[");
+ buff.append(ScriptUtils.toScript(name));
+ buff.append("] = ");
+ buff.append(ScriptUtils.toScript(value));
+ buff.append(";");
params.add(buff.toString());
}
+
}
}
@@ -87,109 +88,188 @@
}
@Override
- protected void preEncodeBegin(FacesContext context, UIComponent component)
- throws IOException {
-
+ protected void preEncodeBegin(FacesContext context, UIComponent component) throws
IOException {
super.preEncodeBegin(context, component);
-
+
// In case of encoding the UIPanelMenu in "expandSingle=true" mode
// the value of "firstExpandedEncoded" attribute should be reset to
- // initial "false" state
- if (component instanceof UIPanelMenu) {
- UIPanelMenu panelMenu = (UIPanelMenu) component;
- if (panelMenu.isExpandSingle()) {
- panelMenu.getAttributes().put(FIRST_EXPANDED_ENCODED, false);
- }
- }
+ // initial "false" state
+ if (component instanceof UIPanelMenu) {
+ UIPanelMenu panelMenu = (UIPanelMenu) component;
+ if (panelMenu.isExpandSingle()) {
+ panelMenu.getAttributes().put("firstExpandedEncoded", false);
+ }
+ }
}
public void insertScript(FacesContext context, UIComponent component)
throws IOException {
- StringBuffer buffer = new StringBuffer();
- Set<String> itemNames = new HashSet<String>();
+ StringBuffer buffer = new StringBuffer();
+ StringBuffer panelMenu = new StringBuffer();
+ List flatList = new LinkedList();
+ Map levels = new HashMap();
- UIPanelMenu panelMenu = (UIPanelMenu)component;
+ Set itemNames = new HashSet();
- ComponentVariables variables = ComponentsVariableResolver.getVariables(this,
component);
- List<PanelMenuRendererBaseChildrenHolder.Item> childrenItems =
(List<PanelMenuRendererBaseChildrenHolder.Item>)
variables.getVariable(CHILDREN_HOLDER);
- if (childrenItems != null) {
- for (PanelMenuRendererBaseChildrenHolder.Item childItem : childrenItems) {
- UIComponent child = childItem.getComponent();
-
- boolean parentRendered = child.getParent().isRendered();
- if (!parentRendered) {
- child.getAttributes().put("rendered",Boolean.FALSE);
- }
-
- boolean childRendered = child.isRendered();
- if (!childRendered || !parentRendered || isParentDisabled(child)/* ||
!isParentExpended(child)*/) {
- continue;
- }
-
- boolean childDisabled = panelMenu.isDisabled()
- || child instanceof UIPanelMenuGroup ? ((UIPanelMenuGroup)child).isDisabled() :
((UIPanelMenuItem)child).isDisabled();
-
-
- String childName;
- if(child instanceof UIPanelMenuGroup){
- childName = ((UIPanelMenuGroup)child).getName();
- } else {
- childName = ((UIPanelMenuItem)child).getName();
+ UIPanelMenu parentMenu = (UIPanelMenu)component;
+
+ boolean expandSingle = parentMenu.isExpandSingle();
+
+ String selectedChild = parentMenu.getSelectedName();
+
+ flatten(component.getChildren(), flatList, levels, 0);
+
+ panelMenu.append("var ids = new PanelMenu('")
+ .append(component.getClientId(context).toString())
+ .append("',")
+ .append(new Boolean(expandSingle).toString())
+ .append(",").append("'").append(selectedChild).append("'")
+ .append(").getIds();\n");
+
+ for (Iterator iter = flatList.iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if ((child instanceof UIPanelMenuItem)||(child instanceof UIPanelMenuGroup)) {
+ boolean childDisabled;
+ if (!((UIPanelMenu)component).isDisabled())
+ childDisabled = child instanceof UIPanelMenuGroup ?
((UIPanelMenuGroup)child).isDisabled() : ((UIPanelMenuItem)child).isDisabled();
+ else
+ childDisabled = true;
+ boolean childRendered = child instanceof UIPanelMenuGroup ?
((UIPanelMenuGroup)child).isRendered() : ((UIPanelMenuItem)child).isRendered();
+ boolean parentRendered = true;
+ if (! (child.getParent() instanceof UIPanelMenu))
+ parentRendered = child.getParent() instanceof UIPanelMenuGroup ?
((UIPanelMenuGroup)child.getParent()).isRendered() :
((UIPanelMenuItem)child.getParent()).isRendered();
+ if (!parentRendered){
+ child.getAttributes().put("rendered",Boolean.FALSE);
}
- if(itemNames.contains(childName)){
- throw new RuntimeException("Attibute \"name\" with value
\"" + childName + "\" is already used in PanelMenu. It must be unique
for every group/item.");
- } else {
- itemNames.add(childName);
- }
+ //UIPanelMenu parentMenu = findMenu(child);
- buffer.append("var params = new Object();");
-
- if (child instanceof UIPanelMenuItem) {
- for (String param : encodeParams(context, (UIPanelMenuItem)child)) {
- buffer.append(param);
- }
- }
+ String event = parentMenu.getEvent();
+ if ("".equals(event))
+ event = "click";
+ else if (event.startsWith("on"))
+ event = event.substring(2);
- buffer.append("new PanelMenuItem(ids, params,")
-
.append("{myId:'").append(child.getClientId(context)).append("',")
-
.append("parentId:'").append(child.getParent().getClientId(context)).append("'},")
- .append("{type:").append(child instanceof UIPanelMenuItem ?
"\"item\"":"\"node\"").append(",")
- .append("onopen:").append(getOnOpen(panelMenu,
child)).append(",")
- .append("onclose:").append(getNoClose(panelMenu,
child)).append(",")
-
.append("event:\"").append(getEvent(panelMenu)).append("\",")
-
.append("mode:\"").append(getItemMode(child)).append("\",")
- .append("disabled:").append(childDisabled).append(",")
-
.append("target:\"").append(getTarget(child)).append("\",")
- .append("name:\"").append(childName).append("\"")
- .append("},{").append(getHoveredStyle(panelMenu,
child)).append("},")
- .append(getHoverClass(panelMenu, child))
- .append(childItem.getLevel())
- .append(switchOnImagesIfNeeded(context,child));
+ String onopen = (child instanceof UIPanelMenuGroup) &&
!((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
+ parentMenu.getOngroupexpand() + ";" +
((UIPanelMenuGroup)child).getOnexpand() : "";
+ String onclose = (child instanceof UIPanelMenuGroup) &&
!((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child) ?
+ parentMenu.getOngroupcollapse() + ";" +
((UIPanelMenuGroup)child).getOncollapse() : "";
+ String hoveredStyle = (child instanceof UIPanelMenuGroup ?
+ parentMenu.getHoveredGroupStyle() : parentMenu.getHoveredItemStyle())
+ + ";" + (child instanceof UIPanelMenuGroup ?
+ ((UIPanelMenuGroup)child).getHoverStyle() :
((UIPanelMenuItem)child).getHoverStyle());
+ String hoveredClass = (child instanceof UIPanelMenuGroup ?
+ parentMenu.getHoveredGroupClass() : parentMenu.getHoveredItemClass())
+ + " " + (child instanceof UIPanelMenuGroup ?
+ ((UIPanelMenuGroup)child).getHoverClass() :
((UIPanelMenuItem)child).getHoverClass());
+ String [] hoveredStyles = hoveredStyle.split(";");
+ String [] hoveredClasses = hoveredClass.split(" ");
- addActionIfNeeded(context,child,buffer);
+ String mode = getItemMode(child);
+ Object target = child.getAttributes().get("target");
+ String targetString;
+ if (null == target)
+ targetString = "";
+ else
+ targetString = target.toString();
- setExpandedIfNeeded(context,child,buffer);
- addAjaxFunction(context,child,buffer);
- addOnItemHover(panelMenu.getOnitemhover(), child, buffer);
- String iconPos;
- boolean isTopLevel = isTopLevel(child);
- if(child instanceof UIPanelMenuGroup){
- iconPos = isTopLevel ? panelMenu.getIconGroupTopPosition() :
panelMenu.getIconGroupPosition();
+ if (childRendered && parentRendered){
+ if ( !isParentDisabled(child) ){
+ String childName;
+ if(child instanceof UIPanelMenuGroup){
+ childName = ((UIPanelMenuGroup)child).getName();
+ } else {
+ childName = ((UIPanelMenuItem)child).getName();
+ }
+
+ if(itemNames.contains(childName)){
+ throw new RuntimeException("Attibute \"name\" with value
\"" + childName + "\" is already used in PanelMenu. It must be unique
for every group/item.");
+ } else {
+ itemNames.add(childName);
+ }
+
+ buffer.append("var params = new Object();");
+
+ if(child instanceof UIPanelMenuItem){
+ List paramsList = encodeParams(context, (UIPanelMenuItem)child);
+ if(!paramsList.isEmpty()){
+ for (Iterator iterator = paramsList.iterator(); iterator.hasNext();) {
+ buffer.append((String)iterator.next());
+ }
+ }
+ }
+
+ buffer
+ .append("new PanelMenuItem(ids, params,{myId:'")
+ .append((String) child.getClientId(context))
+ .append("',parentId:'")
+ .append((String) child.getParent().getClientId(context))
+ .append("'},{type:" + (child instanceof UIPanelMenuItem ?
"\"item\"":"\"node\""))
+ .append(",onopen:"+("".equals(onopen) ?
"\"\"" : "\"" + onopen +
"\"")+",onclose:"+("".equals(onclose) ?
"\"\"" : "\"" + onclose + "\""))
+ .append(",event:\"" + event + "\"")
+ .append(",mode:\"" + mode + "\"")
+ .append(",target:\"" + targetString + "\"")
+ .append(",disabled:" + new Boolean(childDisabled).toString())
+ .append(",target:\"" + targetString + "\"")
+ .append(",name:\"" + childName + "\"")
+ .append("},{");
+
+ for (int i = 0; i < hoveredStyles.length; i++)
+ if (!"".equals(hoveredStyles[i])) {
+ String [] temp = hoveredStyles[i].split(":");
+ String cssName = temp[0].trim();
+ String cssValue = temp[1].trim();
+ buffer.append("\"" + cssName + "\": \"" +
cssValue + "\"");
+ if (i != hoveredStyles.length - 1)
+ buffer.append(",");
+ }
+
+ buffer.append("},");
+ if (hoveredClasses.length > 0) {
+ buffer.append("new Array(");
+ for (int i = 0; i < hoveredClasses.length; i++)
+ if (!"".equals(hoveredClasses[i])) {;
+ buffer.append("\"" + hoveredClasses[i] + "\"");
+ if (i != hoveredClasses.length - 1)
+ buffer.append(",");
+ }
+ buffer.append("),");
+ } else
+ buffer.append("new Array(),");
+
+ buffer.append(levels.get(child.getClientId(context)));
+ switchOnImagesIfNeeded(context,child,buffer);
+
+ addActionIfNeeded(context,child,buffer);
+
+ setExpandedIfNeeded(context,child,buffer);
+
+ addAjaxFunction(context,child,buffer);
+
+ addOnItemHover(parentMenu.getOnitemhover(), child, buffer);
+
+ String iconPos = "left";
+ boolean isTopLevel = isTopLevel(child);
+ if(child instanceof UIPanelMenuGroup){
+ iconPos = isTopLevel ? parentMenu.getIconGroupTopPosition() :
parentMenu.getIconGroupPosition();
+ } else {
+ iconPos = isTopLevel ? parentMenu.getIconItemTopPosition() :
parentMenu.getIconItemPosition();
+ }
+
+ buffer.append(","+'"'+iconPos+'"');
+
+ addImages(buffer,context,child,component.getClientId(context).toString());
+
+ buffer.append(");\n");
+ }
} else {
- iconPos = isTopLevel ? panelMenu.getIconItemTopPosition() :
panelMenu.getIconItemPosition();
+ continue;
}
-
- buffer.append(",\""+iconPos+'"');
-
- addImages(buffer, context, child, component.getClientId(context).toString());
-
- buffer.append(");\n");
}
}
@@ -197,118 +277,48 @@
writer.startElement(HTML.SCRIPT_ELEM, component);
writer.writeAttribute(HTML.id_ATTRIBUTE, "script" +
component.getClientId(context), null);
writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
- writer.writeText(getPanelMenuScript(context, panelMenu), null);
+ writer.writeText(panelMenu, null);
writer.writeText(buffer, null);
writer.endElement(HTML.SCRIPT_ELEM);
}
-
- private String getNoClose(UIPanelMenu panelMenu, UIComponent child) {
- String onclose = (child instanceof UIPanelMenuGroup) &&
!((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child)
- ? panelMenu.getOngroupcollapse() + ";" +
((UIPanelMenuGroup)child).getOncollapse() : "";
- return "".equals(onclose) ? "\"\"" :
"\"" + onclose + "\"";
- }
-
- private String getOnOpen(UIPanelMenu panelMenu, UIComponent child) {
- String onopen = (child instanceof UIPanelMenuGroup) &&
!((UIPanelMenuGroup)child).isDisabled() && !isParentDisabled(child)
- ? panelMenu.getOngroupexpand() + ";" +
((UIPanelMenuGroup)child).getOnexpand() : "";
- return "".equals(onopen) ? "\"\"" :
"\"" + onopen + "\"";
- }
-
- private String getTarget(UIComponent child) {
- Object target = child.getAttributes().get("target");
- return null == target ? "" : target.toString();
- }
-
- private String getHoverClass(UIPanelMenu panelMenu, UIComponent child) {
- String hoveredClass = (child instanceof UIPanelMenuGroup ?
- panelMenu.getHoveredGroupClass() : panelMenu.getHoveredItemClass())
- + " " + (child instanceof UIPanelMenuGroup ?
- ((UIPanelMenuGroup)child).getHoverClass() :
((UIPanelMenuItem)child).getHoverClass());
- String [] hoveredClasses = hoveredClass.trim().split(" ");
-
- StringBuffer buffer = new StringBuffer();
-
- buffer.append("new Array(");
- for (int i = 0; i < hoveredClasses.length; i++) {
- if (!"".equals(hoveredClasses[i])) {
-
buffer.append("\"").append(hoveredClasses[i]).append("\"");
-
- if (i != hoveredClasses.length - 1){
- buffer.append(",");
- }
- }
- }
- buffer.append("),");
-
- return buffer.toString();
- }
-
- private String getHoveredStyle(UIPanelMenu panelMenu, UIComponent child) {
- String hoveredStyle = (child instanceof UIPanelMenuGroup
- ? panelMenu.getHoveredGroupStyle() : panelMenu.getHoveredItemStyle()) +
";" +
- (child instanceof UIPanelMenuGroup ?
((UIPanelMenuGroup)child).getHoverStyle() : ((UIPanelMenuItem)child).getHoverStyle());
- String [] hoveredStyles = hoveredStyle.split(";");
-
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < hoveredStyles.length; i++) {
- if (!"".equals(hoveredStyles[i])) {
- String [] temp = hoveredStyles[i].split(":");
- String cssName = temp[0].trim();
- String cssValue = temp[1].trim();
- buffer.append("\"" + cssName + "\":
\"" + cssValue + "\"");
- if (i != hoveredStyles.length - 1) {
- buffer.append(",");
- }
- }
- }
-
- return buffer.toString();
- }
-
- private String getEvent(UIPanelMenu panelMenu) {
- String event = panelMenu.getEvent();
- if ("".equals(event)) {
- event = "click";
- } else if (event.startsWith("on")) {
- event = event.substring(2);
- }
- return event;
- }
-
- private StringBuffer getPanelMenuScript(FacesContext context, UIPanelMenu parentMenu)
{
- StringBuffer panelMenu = new StringBuffer();
- panelMenu.append("var ids = new PanelMenu('")
- .append(parentMenu.getClientId(context).toString())
- .append("',")
- .append(parentMenu.isExpandSingle())
- .append(",").append("'").append(parentMenu.getSelectedName()).append("'")
- .append(").getIds();\n");
- return panelMenu;
- }
- private String switchOnImagesIfNeeded(FacesContext context, UIComponent child)throws
IOException {
- boolean isToplevel = isTopLevel(child);
- String customIconOpened = "";
- String customIconClosed = "";
+ public void flatten(List children, List flatList, Map levels,int initialLevel) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (children != null) {
+ for (Iterator iter = children.iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if (child instanceof UIPanelMenu){
+ continue;
+ }
+ flatList.add(child);
+ levels.put(child.getClientId(context), new Integer(initialLevel));
+ flatten(child.getChildren(), flatList, levels, initialLevel + 1);
+ }
+ }
+ }
+
+ private void switchOnImagesIfNeeded(FacesContext context, UIComponent child,
StringBuffer buffer)throws IOException {
+ boolean isToplevel = isTopLevel(child);
+ String customIconOpened = "";
+ String customIconClosed = "";
UIPanelMenu panelMenu = findMenu(child);
if(panelMenu == null){
- return "";
+ return;
}
- String iconOpened = isToplevel ? panelMenu.getIconExpandedTopGroup() :
panelMenu.getIconExpandedGroup();
- String iconClosed = isToplevel ? panelMenu.getIconCollapsedTopGroup() :
panelMenu.getIconCollapsedGroup();
+ String iconOpened = isToplevel ? panelMenu.getIconExpandedTopGroup() :
panelMenu.getIconExpandedGroup();
+ String iconClosed = isToplevel ? panelMenu.getIconCollapsedTopGroup() :
panelMenu.getIconCollapsedGroup();
try {
customIconOpened = (String)child.getAttributes().get("iconOpened");
customIconClosed = (String)child.getAttributes().get("iconClosed");
} catch (Exception e) {}
- StringBuffer buffer = new StringBuffer();
if (child instanceof UIPanelMenuItem){
buffer.append(",false");
} else {
- if (iconClosed.equals("custom") &&
iconOpened.equals("custom")){
- if (customIconClosed.equals("") &&
customIconOpened.equals("")){
+ if
(iconClosed.equals("custom")&&iconOpened.equals("custom")){
+ if
(customIconClosed.equals("")&&customIconOpened.equals("")){
buffer.append(",false");
} else {
buffer.append(",true");
@@ -317,7 +327,6 @@
buffer.append(",true");
}
}
- return buffer.toString();
}
private void addActionIfNeeded(FacesContext context,UIComponent child,StringBuffer
buffer){
@@ -329,8 +338,7 @@
buffer.append(",true");
}
} else {
- if (((UIPanelMenuGroup) child).getAction() != null &&
- !((UIPanelMenuGroup)child).getAction().equals("")){
+ if
(((UIPanelMenuGroup)child).getAction()!=null&&!((UIPanelMenuGroup)child).getAction().equals("")){
buffer.append(",'panelMenuNodeAction'");
} else {
buffer.append(",false");
@@ -413,11 +421,11 @@
}
if(customItemIcon != null && !customItemIcon.equals("")){
- buffer.append(",\""+customIconSource).append("\",\""+customIconSource+"\"
");
+ buffer.append(","+'"'+customIconSource+'"').append(","+'"'+customIconSource+'"'+"
");
} else if (defaultItemIcon != null && !defaultItemIcon.equals("")){
- buffer.append(",\""+defaultItemIconSrc).append("\",\""+defaultItemIconSrc+"\"
");
+ buffer.append(","+'"'+defaultItemIconSrc+'"').append(","+'"'+defaultItemIconSrc+'"'+"
");
} else {
- buffer.append(",\""+PANEL_MENU_SPACER_ICON).append("\",\""+PANEL_MENU_SPACER_ICON+"\"
");
+ buffer.append(","+'"'+PANEL_MENU_SPACER_ICON+'"').append(","+'"'+PANEL_MENU_SPACER_ICON+'"'+"
");
}
buffer.append(",\"\" ");
@@ -457,35 +465,43 @@
defaultIconNodeOpened = panelMenu.getIconExpandedGroup();
}
+ String defaultIconNodeClosedSrc = getIconByType(defaultIconNodeClosed,
isTopLevel,context, component);
String defaultIconNodeOpenedSrc = getIconByType(defaultIconNodeOpened,
isTopLevel,context, component);
- String iconExpanded = group.isDisabled() ? group.getIconDisabled() :
group.getIconExpanded();
- String iconExpandedSource = getIconByType(iconExpanded,isTopLevel,context,component);
+
+ String iconExpanded = "";
+ String iconCollapsed = "";
+ String iconExpandedSource = "";
+ String iconCollapsedSource = "";
+
+ iconExpanded = group.isDisabled() ? group.getIconDisabled() :
group.getIconExpanded();
+ iconCollapsed = group.isDisabled() ? group.getIconDisabled() :
group.getIconCollapsed();
+ iconExpandedSource = getIconByType(iconExpanded,isTopLevel,context,component);
+ iconCollapsedSource = getIconByType(iconCollapsed,isTopLevel,context,component);
+
if(iconExpanded != null && !iconExpanded.equals("")){
- buffer.append(",\"" + iconExpandedSource + '"');
+ buffer.append(","+'"'+ iconExpandedSource +
'"');
} else if(defaultIconNodeOpened != null &&
!defaultIconNodeOpened.equals("")){
- buffer.append(",\"" + defaultIconNodeOpenedSrc + '"');
+ buffer.append(","+'"'+defaultIconNodeOpenedSrc +
'"');
} else {
- buffer.append(",\"" + PANEL_MENU_SPACER_ICON + '"');
+ buffer.append(","+'"'+PANEL_MENU_SPACER_ICON +
'"');
}
-
- String defaultIconNodeClosedSrc = getIconByType(defaultIconNodeClosed,
isTopLevel,context, component);
- String iconCollapsed = group.isDisabled() ? group.getIconDisabled() :
group.getIconCollapsed();
- String iconCollapsedSource =
getIconByType(iconCollapsed,isTopLevel,context,component);
+
if(iconCollapsed != null && !iconCollapsed.equals("")){
- buffer.append(",\"" + iconCollapsedSource + '"');
+ buffer.append(","+'"'+iconCollapsedSource+'"');
} else if(defaultIconNodeClosed != null &&
!defaultIconNodeClosed.equals("")){
- buffer.append(",\"" + defaultIconNodeClosedSrc + '"');
+ buffer.append(","+'"'+defaultIconNodeClosedSrc+'"');
} else {
- buffer.append(",\"" + PANEL_MENU_SPACER_ICON + '"');
+ buffer.append(","+'"'+PANEL_MENU_SPACER_ICON +
'"');
}
}
buffer.append(",\"" + PANEL_MENU_SPACER_ICON + "\"");
}
protected void addAjaxFunction(FacesContext context, UIComponent child, StringBuffer
buffer) {
- JSFunction function = AjaxRendererUtils.buildAjaxFunction(child, context);
- Map<String, Object> eventOptions =
- AjaxRendererUtils.buildEventOptions(context, child);
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction(child,
+ context);
+ Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
+ child);
function.addParameter(eventOptions);
buffer.append(",\"");
@@ -493,55 +509,45 @@
buffer.append("\"");
}
- protected void addOnItemHover(String menuOnItemHover, UIComponent child,
- StringBuffer buffer) {
+ protected void addOnItemHover(String menuOnItemHover, UIComponent child, StringBuffer
buffer) {
buffer.append(",\"");
- if (child instanceof UIPanelMenuItem) {
- if (menuOnItemHover != null &&
!menuOnItemHover.equals(""))
- buffer.append(menuOnItemHover);
- }
- buffer.append("\"");
- }
-
+ if(child instanceof UIPanelMenuItem){
+ if(menuOnItemHover != null && !menuOnItemHover.equals(""))
buffer.append(menuOnItemHover);
+ }
+ buffer.append("\"");
+ }
+
public void renderChildren(FacesContext facesContext, UIComponent component)throws
IOException {
- if(!(component instanceof UIPanelMenu)) {
- return;
- }
-
- UIPanelMenu panelMenu = (UIPanelMenu)component;
- PanelMenuRendererBaseChildrenHolder childrenHolder = new
PanelMenuRendererBaseChildrenHolder(panelMenu);
-
- try {
- for (Iterator<UIComponent> it = component.getChildren().iterator();
it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
- if (child instanceof UIPanelMenuGroup) {
- UIPanelMenuGroup group = (UIPanelMenuGroup)child;
- if (panelMenu.isExpandSingle()) {
- if (!(Boolean)panelMenu.getAttributes().get(FIRST_EXPANDED_ENCODED)) {
- if (group.isExpanded()) {
- panelMenu.getAttributes().put(FIRST_EXPANDED_ENCODED, true);
+ if(component instanceof UIPanelMenu){
+ UIPanelMenu panelMenu = (UIPanelMenu)component;
+ if(panelMenu.getChildCount() > 0){
+ for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
+ UIComponent child = (UIComponent) it.next();
+ if(child instanceof UIPanelMenuGroup) {
+ UIPanelMenuGroup group = (UIPanelMenuGroup)child;
+
+ if(panelMenu.isExpandSingle()) {
+ if(!(Boolean)panelMenu.getAttributes().get("firstExpandedEncoded")) {
+ if(group.isExpanded()) {
+ panelMenu.getAttributes().put("firstExpandedEncoded", true);
+ }
+ }else {
+ group.setExpanded(false);
+ if((Boolean)group.getValue()){
+ group.setValue(null);
+ }
}
- } else {
- group.setExpanded(false);
- if ((Boolean)group.getValue()) {
- group.setValue(null);
- }
- }
- }
+ }
+ }
+ renderChild(facesContext, child);
}
- renderChild(facesContext, child);
}
- } finally {
- childrenHolder.unregister();
- }
-
- ComponentVariables variables = ComponentsVariableResolver.getVariables(this,
component);
- variables.setVariable(CHILDREN_HOLDER, childrenHolder.getChildren());
+ }
}
public void doDecode(FacesContext context, UIComponent component) {
- Map<String, String> requestMap =
context.getExternalContext().getRequestParameterMap();
+ Map requestMap = context.getExternalContext().getRequestParameterMap();
String menuClientId = component.getClientId(context);
UIPanelMenu menu = ((UIPanelMenu)component);
Object selectedItemName = requestMap.get(menuClientId + "selectedItemName");
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 2009-03-23
18:50:40 UTC (rev 13126)
+++
trunk/ui/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2009-03-23
19:43:48 UTC (rev 13127)
@@ -82,9 +82,8 @@
this.myId = ids.myId;
this.mode = options.mode;
- if (!this.mode) {
+ if (!this.mode)
this.mode = ("node" == this.type) ? "none" : "server";
- }
this.ajaxSubmit = ajaxFunction;
this.onItemHover = onItemHover;
@@ -93,7 +92,6 @@
this.hoveredStyles = hoveredStyles;
this.hoveredClasses = hoveredClasses;
this.tdhider = Element.extend(idsMap[ids.myId]);
-
if (!this.tdhider) {
this.tdhider = $(ids.myId);
}
@@ -117,7 +115,6 @@
}
parent = parent.parentObj;
}
-
// parent - root menu object
this.rootMenu = parent;
@@ -161,14 +158,13 @@
this._attachBehaviors();
this.inputs = this._getDirectChildrenByTag(this.content,"INPUT");
- for (var i=0;i<this.inputs.length;i++){
- if (this.inputs[i].name.indexOf("panelMenuState")!=-1){
- this.inputState = this.inputs[i];
- } else if (this.inputs[i].name.indexOf("panelMenuAction")!=-1){
- this.inputAction = this.inputs[i];
- }
- }
-
+ for (var i=0;i<this.inputs.length;i++){
+ if (this.inputs[i].name.indexOf("panelMenuState")!=-1){
+ this.inputState = this.inputs[i];
+ } else if (this.inputs[i].name.indexOf("panelMenuAction")!=-1){
+ this.inputAction = this.inputs[i];
+ }
+ }
if (opened){
this.parentObj.lastExpanded = this;
this.expand();
Modified: trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx
===================================================================
--- trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx 2009-03-23
18:50:40 UTC (rev 13126)
+++ trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx 2009-03-23
19:43:48 UTC (rev 13127)
@@ -13,8 +13,6 @@
<f:clientid var="clientId"/>
- <f:call name="registerComponent" />
-
<div id="#{clientId}" style="#{this:getHideStyle(context,
component)}"
class="#{this:getDivClass(context, component)}" >
<jsp:scriptlet>
Modified: trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
===================================================================
--- trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2009-03-23
18:50:40 UTC (rev 13126)
+++ trunk/ui/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2009-03-23
19:43:48 UTC (rev 13127)
@@ -13,8 +13,6 @@
<f:clientid var="clientId"/>
- <f:call name="registerComponent" />
-
<div id="#{clientId}" style="#{this:getHideStyle(context,
component)}" >
<table cellspacing="0" cellpadding="0" border="0"
id="tablehide#{clientId}"
Modified:
trunk/ui/panelmenu/src/test/java/org/richfaces/component/PanelMenuComponentTest.java
===================================================================
---
trunk/ui/panelmenu/src/test/java/org/richfaces/component/PanelMenuComponentTest.java 2009-03-23
18:50:40 UTC (rev 13126)
+++
trunk/ui/panelmenu/src/test/java/org/richfaces/component/PanelMenuComponentTest.java 2009-03-23
19:43:48 UTC (rev 13127)
@@ -35,7 +35,6 @@
import org.ajax4jsf.resource.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.sun.faces.application.ActionListenerImpl;
@@ -44,7 +43,7 @@
* Unit test for simple Component.
*/
public class PanelMenuComponentTest extends AbstractAjax4JsfTestCase {
- private static Set<String> javaScripts = new HashSet<String>();
+ private static Set javaScripts = new HashSet();
private static final boolean IS_PAGE_AVAILABILITY_CHECK = true;
private String[] imageResources = new String[]{
@@ -85,36 +84,7 @@
private UIPanelMenuGroup group3;
private UIPanelMenuItem item1;
private UIPanelMenuItem item2;
- private UIPanelMenuItem item3;
-
- /*
- <viewRoot>
- <from id="form">
- <panelMenu id="panelMenu" >
- <panelMenuGroup id="group1" disabled="true"
expandMode="none" >
- <panelMenuItem id="item1" ></panelMenuItem>
- </panelMenuGroup>
- <panelMenuGroup id="group2" value="true">
- <panelMenuGroup id="subgroup" > <!-- in this case
content don't rendered -->
- <panelMenuItem id="item3" />
- </panelMenuGroup>
-
- <panelMenuItem id="item2"
disabled="true"/>
- <panelMenuItem id="triangleItem"
icon="triangle" />
- <panelMenuItem id="spacerItem" icon="spacer"
/>
- <panelMenuItem id="triangleDownItem"
icon="triangleDown" />
- <panelMenuItem id="triangleUpItem"
icon="triangleUp" />
- <panelMenuItem id="chevronItem" icon="chevron"
/>
- <panelMenuItem id="chevronUpItem"
icon="chevronUp" />
- <panelMenuItem id="chevronDownItem"
icon="chevronDown" />
- <panelMenuItem id="discItem" icon="disc"
/>
- <panelMenuItem id="gridItem" icon="grid"
/>
- </panelMenuGroup>
- </panelMenu>
- </form>
- </viewRoot>
- */
public void setUp() throws Exception {
super.setUp();
@@ -132,13 +102,11 @@
group1 =
(UIPanelMenuGroup)application.createComponent("org.richfaces.panelMenuGroup");
group1.setId("group1");
- group1.setExpandMode("none");
group1.setDisabled(true);
panelMenu.getChildren().add(group1);
group2 =
(UIPanelMenuGroup)application.createComponent("org.richfaces.panelMenuGroup");
group2.setId("group2");
- group2.setValue(true);
panelMenu.getChildren().add(group2);
item1 =
(UIPanelMenuItem)application.createComponent("org.richfaces.panelMenuItem");
@@ -148,11 +116,6 @@
group3 =
(UIPanelMenuGroup)application.createComponent("org.richfaces.panelMenuGroup");
group3.setId("subgroup");
group2.getChildren().add(group3);
-
- item3 =
(UIPanelMenuItem)application.createComponent("org.richfaces.panelMenuItem");
- item3.setId("item3");
- group3.getChildren().add(item3);
-
item2 =
(UIPanelMenuItem)application.createComponent("org.richfaces.panelMenuItem");
item2.setId("item2");
@@ -174,7 +137,7 @@
item.setId("triangleDownItem");
item.setIcon("triangleDown");
group2.getChildren().add(item);
-
+
item =
(UIPanelMenuItem)application.createComponent("org.richfaces.panelMenuItem");
item.setId("triangleUpItem");
item.setIcon("triangleUp");
@@ -225,6 +188,7 @@
public void testRender() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
+ //System.out.println(page.asXml());
HtmlElement div = page.getHtmlElementById(panelMenu.getClientId(facesContext));
assertNotNull(div);
@@ -267,12 +231,6 @@
assertNotNull(rightIcon);
assertEquals("img", rightIcon.getNodeName());
- try {
- page.getHtmlElementById(item3.getClientId(facesContext));
- } catch (ElementNotFoundException e) {
- // it is right this element must be absent
- }
-
HtmlElement firstItemHide = page.getHtmlElementById("tablehide" +
item1.getClientId(facesContext));
assertNotNull(firstItemHide);
assertEquals("table", firstItemHide.getNodeName());