Author: amarkhel
Date: 2010-12-03 08:32:11 -0500 (Fri, 03 Dec 2010)
New Revision: 20339
Removed:
sandbox/trunk/examples/dropdownmenu-demo/src/main/webapp/indexWithToolBar.xhtml
Modified:
sandbox/trunk/examples/dropdownmenu-demo/src/main/java/org/richfaces/demo/MenuBean.java
sandbox/trunk/examples/dropdownmenu-demo/src/main/webapp/index.xhtml
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
sandbox/trunk/ui/dropdown-menu/ui/src/main/resources/META-INF/resources/org.richfaces/dropdownmenu.ecss
sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/dropdownmenu.template.xml
Log:
RF-9676 :Dropdown menu component. Changes added.
Modified:
sandbox/trunk/examples/dropdownmenu-demo/src/main/java/org/richfaces/demo/MenuBean.java
===================================================================
---
sandbox/trunk/examples/dropdownmenu-demo/src/main/java/org/richfaces/demo/MenuBean.java 2010-12-03
13:16:32 UTC (rev 20338)
+++
sandbox/trunk/examples/dropdownmenu-demo/src/main/java/org/richfaces/demo/MenuBean.java 2010-12-03
13:32:11 UTC (rev 20339)
@@ -7,7 +7,34 @@
@SessionScoped
public class MenuBean {
private String current;
+ private String mode = "server";
+ private boolean disabled = false;
+ private boolean checkbox = false;
+
+ public boolean isCheckbox() {
+ return checkbox;
+ }
+
+ public void setCheckbox(boolean checkbox) {
+ this.checkbox = checkbox;
+ }
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
public String getCurrent() {
return this.current;
}
@@ -32,12 +59,12 @@
this.current="Save";
return null;
}
- public String doSaveAll() {
- this.current="Save All";
- return null;
- }
public String doExit() {
this.current="Exit";
return null;
}
+
+ public void setValue(String value) {
+ this.current = value;
+ }
}
Modified: sandbox/trunk/examples/dropdownmenu-demo/src/main/webapp/index.xhtml
===================================================================
--- sandbox/trunk/examples/dropdownmenu-demo/src/main/webapp/index.xhtml 2010-12-03
13:16:32 UTC (rev 20338)
+++ sandbox/trunk/examples/dropdownmenu-demo/src/main/webapp/index.xhtml 2010-12-03
13:32:11 UTC (rev 20339)
@@ -7,22 +7,18 @@
xmlns:a4j="http://richfaces.org/a4j">
<h:head>
<title>Drop Down Menu</title>
- <style>
- .pic {
- margin-bottom: -4px;
- margin-right: 2px;
- }
- </style>
</h:head>
<h:body>
<h:form id="form">
- <br />
+ <h:panelGrid id="panel" columns="2">
+ <h:panelGroup layout="block" style="width:300px;">
+
<a4j:outputPanel ajaxRendered="true">
<h:outputText value="Current Selection: "></h:outputText>
<h:outputText style="font-weight:bold"
value="#{menuBean.current}"></h:outputText>
</a4j:outputPanel>
<br />
- <ddm:dropDownMenu disabled="false" mode="ajax"
onshow="console.info('onshow event');">
+ <ddm:dropDownMenu id="ddmenu"
disabled="#{menuBean.disabled}" mode="#{menuBean.mode}">
<f:facet name="label">
<h:panelGroup>
<h:graphicImage value="images/copy.gif"
styleClass="pic"/>
@@ -35,9 +31,11 @@
<h:outputText value="(disabled)File"/>
</h:panelGroup>
</f:facet>
- <ddm:menuItem label="New"
icon="images/create_doc.gif"
- action="#{menuBean.doNew}">
-
+ <ddm:menuItem id="menuNew" label="New"
icon="images/create_doc.gif"
+ action="#{menuBean.doNew}" execute="@form">
+ <f:facet name="icon">
+ <h:selectBooleanCheckbox id="checkbox"
value="#{menuBean.checkbox}"/>
+ </f:facet>
</ddm:menuItem>
<ddm:menuItem label="Open"
action="#{menuBean.doOpen}">
<f:facet name="icon">
@@ -50,20 +48,49 @@
<h:graphicImage value="images/save.gif" />
</f:facet>
</ddm:menuItem>
- <ddm:menuItem label="Save All"
icon="images/save_all.gif" ></ddm:menuItem>
+ <ddm:menuItem label="Save All"
icon="images/save_all.gif" >
+ <f:setPropertyActionListener target="#{menuBean.value}"
value="Save All" />
+ </ddm:menuItem>
</ddm:menuGroup>
<ddm:menuGroup label="Save As...">
- <ddm:menuItem label="Save"
icon="images/save.gif" />
- <ddm:menuItem label="Save All"
icon="images/save_all.gif" ></ddm:menuItem>
+ <ddm:menuItem label="Save"
icon="images/save.gif" >
+ <f:setPropertyActionListener target="#{menuBean.value}"
value="Save" />
+ </ddm:menuItem>
+ <ddm:menuGroup label="Save All" icon="images/save_all.gif"
>
+ <ddm:menuItem label="Save All 1"
icon="images/save_all.gif">
+ <f:setPropertyActionListener target="#{menuBean.value}"
value="Save All 1" />
+ </ddm:menuItem>
+ <ddm:menuItem label="Save All 2" icon="images/save_all.gif"
>
+ <f:setPropertyActionListener target="#{menuBean.value}"
value="Save All 2" />
+ </ddm:menuItem>
+ </ddm:menuGroup>
</ddm:menuGroup>
<ddm:menuItem label="Close"
action="#{menuBean.doClose}"/>
<ddm:menuItem label="Close" disabled="true"/>
<ddm:menuSeparator id="menuSeparator11" />
<ddm:menuItem label="Exit"
action="#{menuBean.doExit}"/>
<ddm:menuItem action="#{menuBean.doExit}">
- ---EXIT--- <input type="text" />
+ <h:inputText />
</ddm:menuItem>
</ddm:dropDownMenu>
+
+ </h:panelGroup>
+ <h:panelGrid columns="2">
+
+ <h:outputText value="Disabled" />
+ <h:selectBooleanCheckbox value="#{menuBean.disabled}">
+ <f:ajax event="click" execute="@form" render="ddmenu
@this" />
+ </h:selectBooleanCheckbox>
+
+ <h:outputText value="Mode" />
+ <h:selectOneMenu value="#{menuBean.mode}"
onchange="submit()">
+ <f:selectItem itemValue="server"/>
+ <f:selectItem itemValue="ajax"/>
+ <f:selectItem itemValue="client"/>
+ </h:selectOneMenu><br/>
+ </h:panelGrid>
+
+ </h:panelGrid>
</h:form>
</h:body>
</html>
\ No newline at end of file
Deleted: sandbox/trunk/examples/dropdownmenu-demo/src/main/webapp/indexWithToolBar.xhtml
===================================================================
---
sandbox/trunk/examples/dropdownmenu-demo/src/main/webapp/indexWithToolBar.xhtml 2010-12-03
13:16:32 UTC (rev 20338)
+++
sandbox/trunk/examples/dropdownmenu-demo/src/main/webapp/indexWithToolBar.xhtml 2010-12-03
13:32:11 UTC (rev 20339)
@@ -1,65 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:ddm="http://richfaces.org/dropDownMenu"
-
xmlns:tb="http://richfaces.org/toolBar">
- <h:head>
- <title>Drop Down Menu</title>
- <style>
- .pic {
- margin-bottom: -4px;
- margin-right: 2px;
- }
- </style>
- </h:head>
- <h:body>
-
- <tb:toolBar height="45" itemSeparator="grid"
contentStyle="color:red;">
- <f:facet name="itemSeparator">
- ||
- </f:facet>
- <tb:toolBarGroup itemSeparator="line"
onitemclick="22">
- <h:graphicImage value="/images/icons/create_doc.gif"
styleClass="pic"/>
- <a href="sdsd">link 1</a> Text
- <a href="sdsd 2">link 2</a>
- <h:graphicImage value="/images/icons/create_folder.gif"
styleClass="pic" onclick="q1"/>
- <h:graphicImage value="/images/icons/copy.gif"
styleClass="pic"/>
- <a href="sdsd">link 3</a> Text
- <a href="sdsd 2">link 4</a>
- </tb:toolBarGroup>
- <tb:toolBarGroup itemSeparator="none">
- <h:graphicImage value="/images/icons/save.gif"
styleClass="pic" onclick="q2"/>
- <h:graphicImage value="/images/icons/save.gif"
styleClass="pic" onclick="q2"/>
- <h:graphicImage value="/images/icons/save.gif"
styleClass="pic" onclick="q2"/>
- <h:graphicImage value="/images/icons/save.gif"
styleClass="pic" onclick="q2"/>
- </tb:toolBarGroup>
- <tb:toolBarGroup itemSeparator="line">
- <h:graphicImage value="/images/icons/save.gif"
styleClass="pic" onclick="q2"/>
- <h:graphicImage value="/images/icons/save.gif"
styleClass="pic" onclick="q2"/>
- </tb:toolBarGroup>
-
- <tb:toolBarGroup location="right"
itemSeparator="square">
- <h:graphicImage value="/images/icons/find.gif"
styleClass="pic"/>
- <h:graphicImage value="/images/icons/filter.gif"
styleClass="pic"/>
- </tb:toolBarGroup>
- </tb:toolBar>
-
- <ddm:dropDownMenu value="File">
- <ddm:menuItem value="New"
icon="/images/icons/create_doc.gif">
-
- </ddm:menuItem>
- <ddm:menuItem value="Open"
icon="/images/icons/open.gif" />
- <ddm:menuGroup value="Save As...">
- <ddm:menuItem value="Save"
icon="/images/icons/save.gif" />
- <ddm:menuItem value="Save All">
-
- </ddm:menuItem>
- </ddm:menuGroup>
- <ddm:menuItem value="Close" />
- <ddm:menuSeparator id="menuSeparator11" />
- <ddm:menuItem value="Exit" />
- </ddm:dropDownMenu>
- </h:body>
-</html>
\ No newline at end of file
Modified:
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
---
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2010-12-03
13:16:32 UTC (rev 20338)
+++
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2010-12-03
13:32:11 UTC (rev 20339)
@@ -37,7 +37,7 @@
public static final int DEFAULT_MIN_POPUP_WIDTH = 250;
@Override
- public void encodeChildren(FacesContext facesContext, UIComponent component) throws
IOException {
+ public void renderChildren(FacesContext facesContext, UIComponent component) throws
IOException {
AbstractDropDownMenu dropDownMenu = (AbstractDropDownMenu) component;
for (UIComponent child : dropDownMenu.getChildren()) {
@@ -75,7 +75,11 @@
public List<Map<String, Object>> getMenuGroups(FacesContext facesContext,
UIComponent component) {
List<Map<String, Object>> results = new ArrayList<Map<String,
Object>>();
List<AbstractMenuGroup> groups = new ArrayList<AbstractMenuGroup>();
- getMenuGroups(component, groups);
+ if (component instanceof AbstractDropDownMenu) {
+ if (component.isRendered() && !((AbstractDropDownMenu)
component).isDisabled()) {
+ getMenuGroups(component, groups);
+ }
+ }
for (AbstractMenuGroup group : groups) {
if (group.isRendered() && !group.isDisabled()) {
Map<String, Object> map = new HashMap<String, Object>();
Modified:
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
---
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2010-12-03
13:16:32 UTC (rev 20338)
+++
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2010-12-03
13:32:11 UTC (rev 20339)
@@ -14,12 +14,7 @@
public static final String RENDERER_TYPE =
"org.richfaces.MenuGroupRenderer";
public static final int DEFAULT_MIN_POPUP_WIDTH = 250;
-
- @Override
- public void encodeChildren(FacesContext facesContext, UIComponent component) throws
IOException {
- }
-
protected boolean isDisabled(FacesContext facesContext, UIComponent component) {
if (component instanceof AbstractMenuGroup) {
return ((AbstractMenuGroup) component).isDisabled();
Modified:
sandbox/trunk/ui/dropdown-menu/ui/src/main/resources/META-INF/resources/org.richfaces/dropdownmenu.ecss
===================================================================
---
sandbox/trunk/ui/dropdown-menu/ui/src/main/resources/META-INF/resources/org.richfaces/dropdownmenu.ecss 2010-12-03
13:16:32 UTC (rev 20338)
+++
sandbox/trunk/ui/dropdown-menu/ui/src/main/resources/META-INF/resources/org.richfaces/dropdownmenu.ecss 2010-12-03
13:32:11 UTC (rev 20339)
@@ -105,3 +105,17 @@
height: 16px;
line-height: 16px;
}
+
+.rf-ddm-itm-ic input[type="checkbox"] {
+ margin:0;
+ width:16px;
+}
+
+.rf-ddm-itm-lbl input[type="text"] {
+ font-family:Arial,Verdana,sans-serif;
+ font-size:11px;
+ background-position:1px 1px;
+ background-repeat:no-repeat;
+ border-style:inset;
+ border-width:1px;
+}
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/dropdownmenu.template.xml
===================================================================
---
sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/dropdownmenu.template.xml 2010-12-03
13:16:32 UTC (rev 20338)
+++
sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/dropdownmenu.template.xml 2010-12-03
13:32:11 UTC (rev 20339)
@@ -38,21 +38,25 @@
</c:choose>
</div>
- <div class="rf-ddm-pos">
- <div id="#{clientId}_list" class="rf-ddm-lst"
style="display:none;min-width:#{getMinPopupWidth(facesContext,
component)}px;">
- <div class="rf-ddm-lst-bg">
- <cdk:body />
+
+ <c:if test="#{not isDisabled(facesContext, component)}">
+ <div class="rf-ddm-pos">
+ <div id="#{clientId}_list" class="rf-ddm-lst"
style="display:none;min-width:#{getMinPopupWidth(facesContext,
component)}px;">
+ <div class="rf-ddm-lst-bg">
+ <cdk:call expression="renderChildren(facesContext, component)" />
+ </div>
</div>
</div>
- </div>
- <script type="text/javascript">
- <cdk:scriptObject name="options">
- <cdk:scriptOption attributes="hideDelay showDelay popupWith
jointPoint direction mode" />
- <cdk:scriptOption attributes="onshow onhide ongroupshow
ongrouphide onitemclick" wrapper="eventHandler"/>
- </cdk:scriptObject>
-
- new RichFaces.ui.Menu(#{toScriptArgs(clientId,
options)}).initiateGroups(#{toScriptArgs(getMenuGroups(facesContext, component))});
- </script>
+ <script type="text/javascript">
+ <cdk:scriptObject name="options">
+ <cdk:scriptOption attributes="hideDelay showDelay popupWith
jointPoint direction mode" />
+ <cdk:scriptOption attributes="onshow onhide ongroupshow
ongrouphide onitemclick" wrapper="eventHandler"/>
+ </cdk:scriptObject>
+
+ new RichFaces.ui.Menu(#{toScriptArgs(clientId,
options)}).initiateGroups(#{toScriptArgs(getMenuGroups(facesContext, component))});
+
+ </script>
+ </c:if>
</div>
</cc:implementation>