Author: d.bulahov
Date: 2007-03-29 02:35:07 -0400 (Thu, 29 Mar 2007)
New Revision: 197
Modified:
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/component/UIDropDownMenu.java
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
Log:
Development
Modified:
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/component/UIDropDownMenu.java
===================================================================
---
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/component/UIDropDownMenu.java 2007-03-29
01:56:36 UTC (rev 196)
+++
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/component/UIDropDownMenu.java 2007-03-29
06:35:07 UTC (rev 197)
@@ -32,6 +32,11 @@
public static final String COMPONENT_TYPE = "org.richfaces.dropDownMenu";
+
+ public abstract void setEvent(String Event);
+ public abstract String getEvent();
+
+
public static final String SERVER_TYPE = "server";
public static final String CLIENT_TYPE = "client";
public static final String AJAX_TYPE = "ajax";
Modified:
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
---
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-03-29
01:56:36 UTC (rev 196)
+++
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-03-29
06:35:07 UTC (rev 197)
@@ -23,17 +23,21 @@
+
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.richfaces.component.UIDropDownMenu;
import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;
import org.richfaces.component.UIMenuItem;
+import org.richfaces.component.UIMenuGroup;
import java.io.IOException;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.framework.ajax.AjaxContainer;
-
public class DropDownMenuRendererBase extends HeaderResourcesRendererBase {
protected Class getComponentClass() {
@@ -44,10 +48,79 @@
return true;
}
+
+
+/*
+ public void encodeChildren(FacesContext context, UIComponent component) throws
IOException {
+ UIDropDownMenu uiMenu = (UIDropDownMenu) component;
+ List flatListOfNodes = new LinkedList();
+ MenuLayerRendererHelper helper = new MenuLayerRendererHelper(context);
+
+ flatten(uiMenu.getChildren(), flatListOfNodes);
+
+ helper.processLayer(uiMenu);
+
+ for (Iterator iter = flatListOfNodes.iterator(); iter.hasNext();) {
+ UIMenuGroup node = (UIMenuGroup) iter.next();
+
+ helper.processLayer(node);
+ }
+ }
+
+ private class MenuLayerRendererHelper {
+ private boolean ajaxRequest;
+ private FacesContext context;
+ //private PreparedTemplate template;
+ private AjaxContainer ajaxContainer;
+ public MenuLayerRendererHelper(FacesContext context) {
+ super();
+ this.context = context;
+ ajaxRequest = AjaxRendererUtils.isAjaxRequest(context);
+
+ if (ajaxRequest) {
+ // ajaxContainer = AjaxRendererUtils. .getSubmittedAjaxContainer(context, null);
+
+ }
+
+ //template = getLayerTemplate();
+ }
+
+ public void processLayer(UIComponent layer) throws IOException{
+ //determineLayerHasIcons(layer);
+ String clientId = layer.getClientId(context);
+ //template.encode(MenuRendererBase.this, context, layer);
+ layer.encodeBegin(context);
+ //if (ajaxContainer != null) {
+ AjaxRendererUtils.addRegionByName(context, layer, clientId + "_iframe");
+ AjaxRendererUtils.addRegionByName(context, layer, clientId + "_iframe1");
+ AjaxRendererUtils.addRegionByName(context, layer, clientId + "_script");
+ // ajaxContainer.addAjaxArea(clientId + "_iframe");
+ // ajaxContainer.addAjaxArea(clientId + "_iframe1");
+ // ajaxContainer.addAjaxArea(clientId + "_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
{
int showdelay = 300;
int hideDelay = 300;
-
+ UIDropDownMenu menu = (UIDropDownMenu) component;
try {
@@ -65,8 +138,17 @@
buffer
.append(".asDropDown('")
.append(component.getClientId(context))
- .append("','onmouseover')");
+ .append("'");
+
+ String evt = menu.getEvent();
+
+ if(evt == null || evt.trim().length() == 0){
+ evt = "onmouseover";
+ }
+
+ buffer.append(",'").append(evt).append("')");
+
List kids = component.getChildren();
for (Iterator iter = kids.iterator(); iter.hasNext();) {
UIComponent kid = (UIComponent) iter.next();
@@ -74,27 +156,27 @@
if (kid instanceof UIMenuItem) {
itemId = kid.getClientId(context);
}
- //else if (kid instanceof UIMenuNode) {
- // itemId = "ref" + kid.getClientId(context);
- //}
+ else if (kid instanceof UIMenuGroup) {
+ itemId = "ref" + kid.getClientId(context);
+ }
- //if(itemId != null){
+ if(itemId != null){
// if (kid instanceof UIMenuItem) {
- // //UIMenuItem styledComponent = (UIMenuItem) kid;
- // buffer
- // .append(".addItem('")
- // .append(itemId)
- // .append("','")
- // .append("null")
- // .append("','")
- // .append("null")
- // .append("','")
- // .append("null")
- // .append("','")
- // .append("null")
- // .append("')");
+ //UIMenuItem styledComponent = (UIMenuItem) kid;
+ buffer
+ .append(".addItem('")
+ .append(itemId)
+ .append("','")
+ .append("null")
+ .append("','")
+ .append("null")
+ .append("','")
+ .append("null")
+ .append("','")
+ .append("null")
+ .append("')");
// }
- //}
+ }
}
ResponseWriter out = context.getResponseWriter();
String script =buffer.append(";").toString();
Modified:
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
---
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-03-29
01:56:36 UTC (rev 196)
+++
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-03-29
06:35:07 UTC (rev 197)
@@ -446,7 +446,7 @@
}
this.event = e;
- this.element = Event.findElement(e, 'td');
+ this.element = Event.findElement(e, 'div').firstChild();
this.layer = $(layer);
this.show = function() {
Modified:
trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx
===================================================================
---
trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-03-29
01:56:36 UTC (rev 196)
+++
trunk/richfaces/dropdown-menu/src/main/templates/org/richfaces/htmlDropDownMenu.jspx 2007-03-29
06:35:07 UTC (rev 197)
@@ -44,6 +44,9 @@
style="width: #{component.attributes['popupWidth']};
visibility: hidden; z-index:100;"
class="dr-menu-list-border dr-menu-list-position
rich-menu-list-border rich-menu-list-position">
<div class="dr-menu-list-bg rich-menu-list-bg">
+ <script type="text/javascript">
+ <f:call name="encodeScript" />
+ </script>
<f:call name="renderChildren" />
</div>
</div>
@@ -52,9 +55,6 @@
</iframe>
<iframe class="underneath_iframe" id="#{clientId}_menu_iframe1"
style="position:absolute">
</iframe>
- <script type="text/javascript">
- <f:call name="encodeScript" />
- </script>
</div>
Show replies by date