Author: dbiatenia
Date: 2007-06-07 08:49:22 -0400 (Thu, 07 Jun 2007)
New Revision: 1072
Modified:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuItem.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
trunk/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
Log:
code review bugfix
Modified:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java
===================================================================
---
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java 2007-06-07
11:50:51 UTC (rev 1071)
+++
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java 2007-06-07
12:49:22 UTC (rev 1072)
@@ -1,8 +1,8 @@
package org.richfaces.component.panelmenu;
-import org.richfaces.component.UISwitchablePanel;
+import javax.faces.component.UIComponentBase;
-public abstract class UIPanelMenu extends UISwitchablePanel{
+public abstract class UIPanelMenu extends UIComponentBase{
public static final String COMPONENT_TYPE = "org.richfaces.panelMenu";
Modified:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
===================================================================
---
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java 2007-06-07
11:50:51 UTC (rev 1071)
+++
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java 2007-06-07
12:49:22 UTC (rev 1072)
@@ -55,8 +55,6 @@
public abstract void setIconDisabled(String iconDisabled);
public abstract boolean isDisabled();
public abstract void setDisabled(boolean disabled);
-// public abstract Object getValue();
-// public abstract void setValue(Object value);
public abstract String getTarget();
public abstract void setTarget(String target);
public abstract String getHoverClass();
@@ -88,18 +86,6 @@
setConverter(new UIPanelMenuGroupValueConverter());
}
- public boolean isTopLevel(){
- UIComponent parent = getParent();
- while( !(parent instanceof UIPanelMenu) && !(parent instanceof
UIPanelMenuGroup)) {
- parent = parent.getParent();
- }
- if(parent instanceof UIPanelMenu){
- return true;
- } else {
- return false;
- }
- }
-
public void addActionListener(ActionListener listener) {
addFacesListener(listener);
}
Modified:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuItem.java
===================================================================
---
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuItem.java 2007-06-07
11:50:51 UTC (rev 1071)
+++
trunk/sandbox/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuItem.java 2007-06-07
12:49:22 UTC (rev 1072)
@@ -57,16 +57,4 @@
public abstract String getTarget();
public abstract void setTarget(String target);
- public boolean isTopLevel(){
- UIComponent parent = getParent();
- while( !(parent instanceof UIPanelMenu) && !(parent instanceof
UIPanelMenuGroup)) {
- parent = parent.getParent();
- }
- if(parent instanceof UIPanelMenu){
- return true;
- } else {
- return false;
- }
- }
-
}
Modified:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
===================================================================
---
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-06-07
11:50:51 UTC (rev 1071)
+++
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-06-07
12:49:22 UTC (rev 1072)
@@ -53,18 +53,12 @@
Object property = requestMap.get("panelMenuState"+clientId);
if (property.equals("opened")) {
group.setSubmittedValue("true");
- //group.setSubmittedValue(new Boolean(true));
- //group.setExpanded(true);
} else if (property.equals("closed")) {
group.setSubmittedValue("false");
- //group.setSubmittedValue(new Boolean(false));
- //group.setExpanded(false);
}
}
if(isSubmitted(context, component)){
- //new SwitchablePanelSwitchEvent(findMenu(component), null, component).queue();
- //new ValueChangeEvent(group, group.getValue(), group.getSubmittedValue()).queue();
new ActionEvent(component).queue();
if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
new AjaxEvent(component).queue();
@@ -79,7 +73,7 @@
String align = "";
UIPanelMenu panelMenu = findMenu(component);
- boolean isTopLevel = ((UIPanelMenuGroup)component).isTopLevel();
+ boolean isTopLevel = isTopLevel(component);
if (isTopLevel){
align = panelMenu.getIconItemTopPosition();
@@ -103,8 +97,8 @@
return;
}
UIPanelMenuGroup panelMenuGroup = (UIPanelMenuGroup)component;
- boolean isTopLevel = panelMenuGroup.isTopLevel();
- //TODO by nick - dima - component value should be used here
+ boolean isTopLevel = isTopLevel(panelMenuGroup);
+
boolean isOpened = isOpened(context,component);
String source = "";
@@ -113,7 +107,7 @@
Object iconCollapsed = panelMenuGroup.getIconCollapsed();
Object iconExpanded = panelMenuGroup.getIconExpanded();
String icon = (isOpened ? iconExpanded : iconCollapsed).toString();
- if (icon.equals("")){
+ if ("".equals(icon)){
source = getIconByType("custom", isTopLevel,context, component);
} else {
if (iconNode.equals("none")){
@@ -167,29 +161,6 @@
return styleBuffer.toString();
}
-// public String getHideStyle(FacesContext context, UIComponent component) {
-// if (!(component.getParent() instanceof UIPanelMenu)) {
-// CSSFormat format = new CSSFormat();
-// format.add("display", "none");
-// if(component.getParent() instanceof UIPanelMenuGroup) {
-// UIPanelMenuGroup parent = (UIPanelMenuGroup)component.getParent();
-// //TODO by nick - dima - take opened value from component itself
-// PanelMenuGroupRenderer renderer = (PanelMenuGroupRenderer)
context.getRenderKit().getRenderer(parent.getFamily(), parent.getRendererType());
-// try {
-// if ( renderer.isOpened(context, parent).equals("opened") ){
-// return "";
-// } else
-// return format.toString();
-// } catch (IOException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// } else return format.toString();
-// }
-// return "";
-//
-// }
-
public void insertLabel(FacesContext context, UIComponent component) throws IOException
{
Object label = component.getAttributes().get("label");
if (label!=null){
@@ -233,22 +204,4 @@
}
return false;
}
-/*
- protected boolean isChildrenExpanded(UIComponent component){
- if (component.getChildren() != null){
- Iterator itr = component.getChildren().iterator();
- while(itr.hasNext()){
- UIComponent child = (UIComponent)itr.next();
- if(child instanceof UIPanelMenuGroup){
- if( ((UIPanelMenuGroup)child).isExpanded() ){
- return true;
- } else {
- return isChildrenExpanded(child);
- }
- }
- }
- }
- return false;
- }
-*/
}
Modified:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
===================================================================
---
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-06-07
11:50:51 UTC (rev 1071)
+++
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-06-07
12:49:22 UTC (rev 1072)
@@ -36,7 +36,6 @@
public class PanelMenuItemRenderer extends PanelMenuRendererBase {
protected Class getComponentClass() {
- //TODO by nick - dima - add concrete component class
return UIPanelMenuItem.class;
}
@@ -45,10 +44,11 @@
}
protected void doDecode(FacesContext context, UIComponent component) {
if(isSubmitted(context, component)) {
- new SwitchablePanelSwitchEvent(findMenu(component), null, component).queue();
- new ActionEvent(component).queue();
+ new ActionEvent(component).queue();
if (UISwitchablePanel.AJAX_METHOD.equals(getItemMode(component))) {
new AjaxEvent(component).queue();
+ } else {
+
}
}
}
@@ -57,11 +57,12 @@
}
+ /*
public String getOnClick(FacesContext context, UIComponent component) {
String clientId = component.getClientId(context);
return ";PanelMenuStorage['" + clientId +
"'].trigger(event);";
}
-
+ */
public void insertImage(FacesContext context, UIComponent component, Object data) throws
IOException {
String from = (String)data;
UIPanelMenu panelMenu = findMenu(component);
@@ -70,7 +71,7 @@
}
String align = "";
UIPanelMenuItem panelMenuItem = (UIPanelMenuItem)component;
- boolean isTopLevel = panelMenuItem.isTopLevel();
+ boolean isTopLevel = isTopLevel(panelMenuItem);
if (isTopLevel){
align = panelMenu.getIconItemTopPosition();
@@ -96,7 +97,7 @@
ResponseWriter writer = context.getResponseWriter();
String iconItemTopLevel = panelMenu.getIconTopItem();
String iconItem = panelMenu.getIconItem();
- boolean isTopLevel = component.getParent() instanceof UIPanelMenu;
+ boolean isTopLevel = isTopLevel(component);
String source = "";
String iconType = "";
Object customIcon = ((UIPanelMenuItem)component).getIcon();
@@ -161,29 +162,4 @@
return styleBuffer.toString();
}
-
- //TODO by nick - dima - looks like duplicate code methods. can we add it to super
class?
-// public String getHideStyle(FacesContext context, UIComponent component) {
-// // TODO Auto-generated method stub
-// if (!(component.getParent() instanceof UIPanelMenu)) {
-// CSSFormat format = new CSSFormat();
-// format.add("display", "none");
-// if(component.getParent() instanceof UIPanelMenuGroup) {
-// UIPanelMenuGroup parent = (UIPanelMenuGroup)component.getParent();
-// PanelMenuGroupRenderer renderer = (PanelMenuGroupRenderer)
context.getRenderKit().getRenderer(parent.getFamily(), parent.getRendererType());
-// try {
-// if ( renderer.isOpened(context, parent).equals("opened") ){
-// return "";
-// } else
-// return format.toString();
-// } catch (IOException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// } else return format.toString();
-// }
-// return "";
-// }
-
-
}
Modified:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
===================================================================
---
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-06-07
11:50:51 UTC (rev 1071)
+++
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-06-07
12:49:22 UTC (rev 1072)
@@ -47,7 +47,6 @@
* @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
*/
protected Class getComponentClass() {
- //TODO by nick - dima - add concrete component class
return UIComponent.class;
}
@@ -129,8 +128,7 @@
.append("',parentId:'")
.append((String) child.getParent().getClientId(context))
.append("'},{type:" + (child instanceof UIPanelMenuItem ?
"\"item\"":"\"node\""))
- //TODO by nick - dima - use "".equals(onopen)
- .append(",onopen:"+(onopen.equals("") ?
"\"\"" : "\"" + onopen +
"\"")+",onclose:"+(onclose.equals("") ?
"\"\"" : "\"" + onclose + "\""))
+ .append(",onopen:"+("".equals(onopen) ?
"\"\"" : "\"" + onopen +
"\"")+",onclose:"+("".equals(onclose) ?
"\"\"" : "\"" + onclose + "\""))
.append(",event:\"" + event + "\"")
.append(",mode:\"" + mode + "\"")
.append(",target:\"" + targetString + "\"")
@@ -177,8 +175,6 @@
addImages(buffer,context,child,component.getClientId(context).toString());
-
-
buffer.append(");\n");
}
} else {
@@ -214,7 +210,7 @@
}
private void switchOnImagesIfNeeded(FacesContext context, UIComponent child,
StringBuffer buffer)throws IOException {
- boolean isToplevel = child.getParent() instanceof UIPanelMenu;
+ boolean isToplevel = isTopLevel(child);
String customIconOpened = "";
String customIconClosed = "";
@@ -285,31 +281,6 @@
buffer.append(",").append(String.valueOf(isNodeOpened));
}
}
-/*
- String value = "";
- try {
- value =
context.getExternalContext().getRequestParameterMap().get("panelMenuState"+child.getClientId(context)).toString();
- } catch (Exception e) {
- value = "";
- }
- if (!value.equals("")){
- if (value.equals("opened")) {
- buffer.append(",true");
- } else {
- buffer.append(",false");
- }
- } else {
- Object property = child.getAttributes().get("expanded");
- if (property!=null && property.toString().equals("true")){
- buffer.append(",true");
- } else {
-
- //return isChildrenExpanded(component) ? "opened" : "closed";
- buffer.append(isChildrenExpanded(child) ? ",true" : ",false");
- //buffer.append(",false");
- }
- }
-*/
}
private void addImages(StringBuffer buffer,FacesContext context,UIComponent
component,String id){
Modified:
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
---
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-06-07
11:50:51 UTC (rev 1071)
+++
trunk/sandbox/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-06-07
12:49:22 UTC (rev 1072)
@@ -28,9 +28,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
-import org.ajax4jsf.framework.renderer.RendererUtils;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.ajax4jsf.framework.skin.Skin;
import org.ajax4jsf.framework.util.style.CSSFormat;
@@ -61,8 +59,6 @@
String src = getIconByType("custom",false,context,component);
int w = 16; //width(context);
- RendererUtils utils = getUtils();
-
for (int i=0;i<level;i++){
writer.startElement(HTML.td_ELEM, component);
writer.startElement("img", component);
@@ -75,9 +71,7 @@
writer.writeAttribute("style", "display:block; ", null);
writer.endElement("img");
writer.endElement(HTML.td_ELEM);
- //buffer.append("<td><img src=\"" + src + "\"
alt=\"\" hspace=\"0\" vspace=\"0\"
height=\""+w+"\" width=\""+w+"\"
style=\"display:block;\" /></td>\n");
}
- //writer.write(buffer.toString());
}
protected int calculateLevel (UIComponent component){
@@ -290,4 +284,21 @@
return mode;
}
+ /**
+ *
+ * @param component
+ * @return
+ */
+ public boolean isTopLevel(UIComponent component){
+ UIComponent parent = component.getParent();
+ while( !(parent instanceof UIPanelMenu) && !(parent instanceof
UIPanelMenuGroup)) {
+ parent = parent.getParent();
+ }
+ if(parent instanceof UIPanelMenu){
+ return true;
+ } else {
+ return false;
+ }
+ }
+
}
Modified:
trunk/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
===================================================================
---
trunk/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-06-07
11:50:51 UTC (rev 1071)
+++
trunk/sandbox/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-06-07
12:49:22 UTC (rev 1072)
@@ -60,6 +60,7 @@
this.obj = $(ids.myId);
this.content = this._getDirectChildrenByTag(this.obj,"TD")[level+1];
this.iconAlign = iconAlign;
+ /*
if (level == 0){
this.tdhider.style.display = "";
this.tablehider.style.display = "";
@@ -67,6 +68,7 @@
this.tdhider.style.display = "";
this.tablehider.style.display = "";
}
+ */
this.iconCollapsed = iconCollapsed;
this.iconExpanded = iconExpanded;
this.iconSpacer = iconSpacer;
@@ -180,20 +182,17 @@
this.inputAction.setAttribute('value', this.obj.id);
},
+ postTrigger: function(e){
+ this.inputAction.setAttribute('value', '');
+ },
+
+
trigger: function(e){
if ("none" == this.mode)
return;
if (this.action !="panelMenuItemAction"){
this.preTrigger(e);
var form = Event.findElement(e, "form");
- //TODO by nick - dima - no need to create form
- if(!form || typeof(form) == 'undefined' || !form.tagName ||
form.tagName.toLowerCase() != 'form'){
- form = document.createElement('form');
- form.setAttribute('method', 'post');
- form.setAttribute('enctype', 'application/x-www-form-urlencoded');
- form.action = action;
- document.body.appendChild(form);
- }
if ("server" == this.mode) {
if (this.target)
form.target = this.target;
@@ -203,6 +202,7 @@
var event = e;
eval(this.ajaxSubmit);
}
+ this.postTrigger(e);
}
},
Modified: trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
===================================================================
---
trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2007-06-07
11:50:51 UTC (rev 1071)
+++
trunk/sandbox/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2007-06-07
12:49:22 UTC (rev 1072)
@@ -12,7 +12,8 @@
<f:clientid var="clientId"/>
- <tr id="tdhide#{clientId}" style="#{this:getHideStyle(context,
component)}" >
+ <tr id="tdhide#{clientId}" style="#{this:getHideStyle(context,
component)}" >
+ <!-- "#{this:getHideStyle(context, component)}" -->
<td>
<jsp:scriptlet>
<![CDATA[