[richfaces-svn-commits] JBoss Rich Faces SVN: r231 - in trunk/richfaces/menu-components/src/main: resources/org/richfaces/renderkit/html and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Apr 2 04:25:32 EDT 2007


Author: a.izobov
Date: 2007-04-02 04:25:31 -0400 (Mon, 02 Apr 2007)
New Revision: 231

Removed:
   trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuRendererBase.java
   trunk/richfaces/menu-components/src/main/resources/org/richfaces/renderkit/html/template/
Modified:
   trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
Log:
menu without menuLayer template

Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java	2007-03-30 23:15:15 UTC (rev 230)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java	2007-04-02 08:25:31 UTC (rev 231)
@@ -26,11 +26,12 @@
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 
+import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
 import org.richfaces.component.UIMenuGroup;
 
 
 
-public class MenuGroupRendererBase extends MenuRendererBase {	
+public class MenuGroupRendererBase extends HeaderResourcesRendererBase {	
 	
 	protected Class getComponentClass() {
 		return UIMenuGroup.class;
@@ -40,7 +41,4 @@
 		return true;
 	}
 	
-	public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
-	}	
-	
 }

Deleted: trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuRendererBase.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuRendererBase.java	2007-03-30 23:15:15 UTC (rev 230)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuRendererBase.java	2007-04-02 08:25:31 UTC (rev 231)
@@ -1,153 +0,0 @@
-/**
- * License Agreement.
- *
- *  JBoss RichFaces 3.0 - 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.html;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
-import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
-import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
-import org.richfaces.component.UIMenuGroup;
-import org.richfaces.component.UIMenuItem;
-import org.richfaces.component.UIMenuSeparator;
-
-
-
-public abstract class MenuRendererBase extends HeaderResourcesRendererBase {	
-	
-	public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
-		List flatListOfNodes = new LinkedList();
-		MenuLayerRendererHelper helper = new MenuLayerRendererHelper(context);
-		
-		flatten(component.getChildren(), flatListOfNodes);
-		helper.processLayer(component);
-		
-		for (Iterator iter = flatListOfNodes.iterator(); iter.hasNext();) {
-			UIMenuGroup node = (UIMenuGroup) iter.next();
-			helper.processLayer(node);
-		}
-	}
-	
-	public void encodeItems(FacesContext context, UIComponent component) throws IOException {
-		List kids = component.getChildren();
-		Iterator it = kids.iterator();
-		while (it.hasNext()) {
-			UIComponent kid = (UIComponent)it.next();
-			if (kid instanceof UIMenuGroup || kid instanceof UIMenuItem || kid instanceof UIMenuSeparator) {
-				renderChild(context, kid);
-			}
-		}
-		
-	}
-	
-	private class MenuLayerRendererHelper {
-		private FacesContext context;
-		private PreparedTemplate template;
-
-		public MenuLayerRendererHelper(FacesContext context) {
-			super();
-			this.context = context;
-			template = HtmlCompiler.compileResource("org/richfaces/renderkit/html/template/htmlMenuLayer.jspx");
-
-		}
-		
-		public void processLayer(UIComponent layer) throws IOException{
-			String clientId = layer.getClientId(context);
-			template.encode(MenuRendererBase.this, context, layer);
-			AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_iframe");
-			AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_iframe1");
-			AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_script");
-		}
-		
-	}
-	
-	
-	private void flatten(List kids, List flatList){
-		if(kids != null){
-			for (Iterator iter = kids.iterator(); iter.hasNext();) {
-				UIComponent kid = (UIComponent) iter.next();
-				if (kid instanceof UIMenuGroup) {
-					UIMenuGroup node = (UIMenuGroup) kid;
-					flatList.add(node);
-					flatten(node.getChildren(), flatList);
-				}
-			}
-		}
-	}
-	
-	public void encodeScript(FacesContext context, UIComponent component) throws IOException {
-		StringBuffer buffer = 
-			new StringBuffer("new Exadel.Menu.Layer('")	
-				.append(component.getClientId(context)+"_menu")
-				.append("',")
-				.append(component.getAttributes().get("showDelay"))
-				.append( ")");
-		if (component instanceof UIMenuGroup) {
-			buffer.append(".asSubMenu('")
-				.append(component.getParent().getClientId(context)+"_menu")
-				.append("','")	
-				.append("ref")
-				.append(component.getClientId(context))
-				.append("')");
-		} else {
-		    buffer
-	         .append(".asDropDown('")
-	         .append(component.getClientId(context))		         
-	         .append("'");
-	    
-			String evt = (String) component.getAttributes().get("event");
-			if(evt == null || evt.trim().length() == 0){
-				evt = "onmouseover";
-			}
-			buffer.append(",'").append(evt).append("')");
-			
-		}
-		List children = component.getChildren();
-		for(Iterator it = children.iterator();it.hasNext();) {
-			UIComponent kid = (UIComponent)it.next();
-			String itemId = null;
-			if (kid instanceof UIMenuItem) {
-				itemId = kid.getClientId(context);
-			} else if (kid instanceof UIMenuGroup) {
-				itemId = "ref" + kid.getClientId(context);
-			}
-			if(itemId != null){
-				buffer
-					.append(".addItem('")
-					.append(itemId)
-					.append("')");
-			}
-		}
-		ResponseWriter out = context.getResponseWriter();
-		String script =buffer.append(";").toString();
-		out.write(script); 
-	}
-
-}




More information about the richfaces-svn-commits mailing list