001: /*
002: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
003: *
004: * "The contents of this file are subject to the Mozilla Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License at
007: * http://www.mozilla.org/MPL/
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
011: * License for the specific language governing rights and limitations under
012: * the License.
013: *
014: * The Original Code is ICEfaces 1.5 open source software code, released
015: * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
016: * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
017: * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
018: *
019: * Contributor(s): _____________________.
020: *
021: * Alternatively, the contents of this file may be used under the terms of
022: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
023: * License), in which case the provisions of the LGPL License are
024: * applicable instead of those above. If you wish to allow use of your
025: * version of this file only under the terms of the LGPL License and not to
026: * allow others to use your version of this file under the MPL, indicate
027: * your decision by deleting the provisions above and replace them with
028: * the notice and other provisions required by the LGPL License. If you do
029: * not delete the provisions above, a recipient may use your version of
030: * this file under either the MPL or the LGPL License."
031: *
032: */
033:
034: package com.icesoft.faces.component.menubar;
035:
036: import com.icesoft.faces.component.ext.HtmlCommandLink;
037:
038: import javax.faces.component.NamingContainer;
039: import javax.faces.component.UICommand;
040: import javax.faces.component.UIComponent;
041: import javax.faces.context.FacesContext;
042: import javax.faces.event.AbortProcessingException;
043: import javax.faces.event.FacesEvent;
044: import java.util.List;
045:
046: /**
047: *
048: */
049: public abstract class MenuItemBase extends UICommand implements
050: NamingContainer {
051:
052: protected static String DEFAULT_CSS_IMAGE_DIR = "";
053:
054: public MenuItemBase() {
055: }
056:
057: /* (non-Javadoc)
058: * @see javax.faces.component.UIComponent#processDecodes(javax.faces.context.FacesContext)
059: */
060: public void processDecodes(FacesContext context) {
061: if (context == null) {
062: throw new NullPointerException("context");
063: }
064: if (!isRendered()) {
065: return;
066: }
067:
068: decodeRecursive(this , context);
069: try {
070: decode(context);
071: } catch (RuntimeException e) {
072: context.renderResponse();
073: throw e;
074: }
075: }
076:
077: /**
078: * @param component
079: * @param context
080: */
081: private void decodeRecursive(UIComponent component,
082: FacesContext context) {
083: if (component instanceof MenuItems) {
084: List list = (List) ((MenuItems) component).getValue();
085:
086: for (int j = 0; j < list.size(); j++) {
087: MenuItem item = (MenuItem) list.get(j);
088: item.processDecodes(context);
089: decodeRecursiveItems(item, context);
090: }
091:
092: }
093:
094: for (int i = 0; i < component.getChildCount(); i++) {
095: UIComponent next = (UIComponent) component.getChildren()
096: .get(i);
097: if (next instanceof HtmlCommandLink) {
098: next.processDecodes(context);
099: }
100: decodeRecursive(next, context);
101: }
102: }
103:
104: /**
105: * @param component
106: * @param context
107: */
108: private void decodeRecursiveItems(UIComponent component,
109: FacesContext context) {
110: for (int i = 0; i < component.getChildCount(); i++) {
111: UIComponent next = (UIComponent) component.getChildren()
112: .get(i);
113:
114: next.processDecodes(context);
115:
116: decodeRecursiveItems(next, context);
117: }
118: }
119:
120: /* (non-Javadoc)
121: * @see javax.faces.component.UIComponent#queueEvent(javax.faces.event.FacesEvent)
122: */
123: public void queueEvent(FacesEvent event) {
124: super .queueEvent(event);
125: }
126:
127: /* (non-Javadoc)
128: * @see javax.faces.component.UIComponent#broadcast(javax.faces.event.FacesEvent)
129: */
130: public void broadcast(FacesEvent event)
131: throws AbortProcessingException {
132: super.broadcast(event);
133: return;
134:
135: }
136:
137: }
|