Author: sergeyhalipov
Date: 2007-05-18 08:42:08 -0400 (Fri, 18 May 2007)
New Revision: 804
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
Log:
Panel menu: fixed support for actions and for mouse events.
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-18
10:21:54 UTC (rev 803)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-18
12:42:08 UTC (rev 804)
@@ -27,6 +27,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
import org.ajax4jsf.framework.util.style.CSSFormat;
import org.richfaces.component.panelmenu.UIPanelMenu;
@@ -37,6 +38,26 @@
return UIComponent.class;
}
+ protected void doDecode(FacesContext context, UIComponent component) {
+ String clientId = component.getClientId(context);
+ Map requestMap =context.getExternalContext().getRequestParameterMap();
+
+ if(requestMap.containsKey("panelMenuState"+clientId)){
+ Object property = requestMap.get("panelMenuState"+clientId);
+
+ if (property.equals("opened")) {
+ component.getAttributes().put("expanded", "true");
+ } else if (property.equals("closed")) {
+ component.getAttributes().put("expanded", "false");
+ }
+
+ }
+ if(isSubmitted(context, component)){
+ ActionEvent actionEvent = new ActionEvent(component);
+ component.queueEvent(actionEvent);
+ }
+ }
+
public void insertImage(FacesContext context, UIComponent component, Object data)
throws IOException {
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-05-18
10:21:54 UTC (rev 803)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-05-18
12:42:08 UTC (rev 804)
@@ -22,10 +22,13 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.Map;
+import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.richfaces.component.panelmenu.UIPanelMenu;
@@ -37,9 +40,21 @@
return UIComponent.class;
}
- public String getOnClick(TemplateContext templateContext){
- FacesContext context = templateContext.getFacesContext();
- UIComponent component = templateContext.getComponent();
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context,UIComponent
component) throws IOException {
+
+ }
+ protected void doDecode(FacesContext context, UIComponent component) {
+ if(isSubmitted(context, component)){
+ ActionEvent actionEvent = new ActionEvent(component);
+ component.queueEvent(actionEvent);
+ }
+ }
+
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
+
+ }
+
+ public String getOnClick(FacesContext context, UIComponent component) {
String clientId = component.getClientId(context);
return ";PanelMenuStorage['" + clientId +
"'].trigger(event);";
}
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
---
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-18
10:21:54 UTC (rev 803)
+++
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-18
12:42:08 UTC (rev 804)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.util.Map;
+import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -162,4 +163,18 @@
}
return "closed";
}
+
+ protected boolean isSubmitted(FacesContext context, UIComponent component){
+ boolean submitted = false;
+ String clientId = component.getClientId(context);
+ Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
+
+ Object value = requestParameterMap.get("panelMenuAction"+clientId);
+ if (clientId!=null&&value!=null){
+ if (value.equals(clientId)) {
+ submitted = true;
+ }
+ }
+ return submitted;
+ }
}
Modified:
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx
===================================================================
---
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx 2007-05-18
10:21:54 UTC (rev 803)
+++
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx 2007-05-18
12:42:08 UTC (rev 804)
@@ -18,6 +18,10 @@
id="tablehide#{clientId}"
class="rich-pmenu-group dr-pmenu-group #{this:getFullStyleClass( context,
component )}"
style="#{this:getFullStyle( context, component )}" >
+
+ <f:call name="utils.encodeAttributes">
+ <f:parameter value="onclick,onmousedown,onmouseup,onmousemove" />
+ </f:call>
<f:call name="utils.encodePassThru" />
<tr>
<f:call name="utils.encodeId" />
Modified:
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
===================================================================
---
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2007-05-18
10:21:54 UTC (rev 803)
+++
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2007-05-18
12:42:08 UTC (rev 804)
@@ -15,12 +15,12 @@
<tr id="tdhide#{clientId}" style="#{this:getHideStyle(context,
component)}" >
<td>
<table cellpadding="0" cellspacing="0" border="0"
width="100%"
- onclick="#{onClick}"
+ onclick="#{component.attributes['onclick']};#{this:getOnClick( context,
component )}"
class="rich-pmenu-item dr-pmenu-item #{this:getFullStyleClass( context,
component )}"
style="#{this:getFullStyle( context, component )}"
id="tablehide#{clientId}" >
- <f:call name="utils.encodePassThruWithExclusions">
- <f:parameter value="onclick"/>
+ <f:call name="utils.encodeAttributes">
+ <f:parameter value="onmousedown,onmouseup,onmousemove" />
</f:call>
<tr>
<f:call name="utils.encodeId"/>