You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by to...@apache.org on 2006/05/02 22:56:15 UTC
svn commit: r399048 [1/2] - in /myfaces/tomahawk/trunk:
core/src/main/java/org/apache/myfaces/custom/navmenu/
core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/
core/src/main/tld/tomahawk-entities/
examples/simple/src/main/java/org/apach...
Author: tomsp
Date: Tue May 2 13:56:12 2006
New Revision: 399048
URL: http://svn.apache.org/viewcvs?rev=399048&view=rev
Log:
new attribute externalUrl
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/NavigationMenuItem.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/UINavigationMenuItem.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlCommandNavigationItem.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlCommandNavigationItemTag.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlNavigationMenuRenderer.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlNavigationMenuRendererUtils.java
myfaces/tomahawk/trunk/core/src/main/tld/tomahawk-entities/tomahawk_command_navigation_2_attributes.xml
myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/misc/NavigationMenu.java
myfaces/tomahawk/trunk/examples/simple/src/main/resources/org/apache/myfaces/examples/resource/example_messages.properties
myfaces/tomahawk/trunk/examples/simple/src/main/webapp/panelnavigation_4.jsp
myfaces/tomahawk/trunk/examples/simple/src/main/webapp/panelnavigation_5.jsp
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/NavigationMenuItem.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/NavigationMenuItem.java?rev=399048&r1=399047&r2=399048&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/NavigationMenuItem.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/NavigationMenuItem.java Tue May 2 13:56:12 2006
@@ -22,11 +22,11 @@
/**
* A node in a tree of menu items.<br>
+ *
* @author Thomas Spiegl (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class NavigationMenuItem extends SelectItem
-{
+public class NavigationMenuItem extends SelectItem {
private static final long serialVersionUID = 2801735314476639024L;
private String _icon;
private String _action;
@@ -40,17 +40,16 @@
private boolean _disabled;
private String _disabledStyle;
private String _disabledStyleClass;
+ private String _externalLink;
- public NavigationMenuItem(String label, String action)
- {
+ public NavigationMenuItem(String label, String action) {
super(label, label);
_action = action;
_icon = null;
_split = false;
}
- public NavigationMenuItem(String label, String action, String icon, boolean split)
- {
+ public NavigationMenuItem(String label, String action, String icon, boolean split) {
super(label, label);
_action = action;
_icon = icon;
@@ -63,8 +62,7 @@
boolean disabled,
String action,
String icon,
- boolean split)
- {
+ boolean split) {
super(value, label, description, disabled);
_action = action;
_icon = icon;
@@ -78,8 +76,7 @@
boolean rendered,
String action,
String icon,
- boolean split)
- {
+ boolean split) {
this(value, label, description, disabled, action, icon, split);
this.rendered = rendered;
}
@@ -92,45 +89,37 @@
String action,
String icon,
boolean split,
- String target)
- {
+ String target) {
this(value, label, description, disabled, rendered, action, icon, split);
this.setTarget(target);
}
- public boolean isRendered()
- {
+ public boolean isRendered() {
return rendered;
}
- public String getAction()
- {
+ public String getAction() {
return _action;
}
- public void setAction(String action)
- {
+ public void setAction(String action) {
_action = action;
}
- public boolean isSplit()
- {
+ public boolean isSplit() {
return _split;
}
- public void setSplit(boolean split)
- {
+ public void setSplit(boolean split) {
_split = split;
}
- public String getIcon()
- {
+ public String getIcon() {
return _icon;
}
- public void setIcon(String icon)
- {
+ public void setIcon(String icon) {
_icon = icon;
}
@@ -139,116 +128,109 @@
* state across requests. Returns true if the menu is currently open
* (displaying its child items).
*/
- public boolean isOpen()
- {
+ public boolean isOpen() {
return _open;
}
- public void setOpen(boolean open)
- {
+ public void setOpen(boolean open) {
_open = open;
}
- public boolean isActive()
- {
+ public boolean isActive() {
return _active;
}
- public void setActive(boolean active)
- {
+ public void setActive(boolean active) {
_active = active;
}
- public String getActionListener()
- {
+ public String getActionListener() {
return _actionListener;
}
- public void setActionListener(String actionListener)
- {
+ public void setActionListener(String actionListener) {
_actionListener = actionListener;
}
- public String getTarget()
- {
+ public String getTarget() {
return _target;
}
- public void setTarget(String target)
- {
+ public void setTarget(String target) {
_target = target;
}
- public boolean isDisabled()
- {
+ public boolean isDisabled() {
return _disabled;
}
- public void setDisabled(boolean disabled)
- {
+ public void setDisabled(boolean disabled) {
_disabled = disabled;
}
- public String getDisabledStyle()
- {
+ public String getDisabledStyle() {
return _disabledStyle;
}
- public void setDisabledStyle(String disabledStyle)
- {
+ public void setDisabledStyle(String disabledStyle) {
_disabledStyle = disabledStyle;
}
- public String getDisabledStyleClass()
- {
+ public String getDisabledStyleClass() {
return _disabledStyleClass;
}
- public void setDisabledStyleClass(String disabledStyleClass)
- {
+ public void setDisabledStyleClass(String disabledStyleClass) {
_disabledStyleClass = disabledStyleClass;
}
+ public String getExternalLink() {
+ return _externalLink;
+ }
+
+ public void setExternalLink(String externalLink) {
+ _externalLink = externalLink;
+ }
+
/**
* Get the array of child nodes of this menu item. If this node has
* no children then an empty array is returned. The array is a copy
* of the internal data of this object, so changes to the array will
- * not affect the state of this object. The members of the array
+ * not affect the state of this object. The members of the array
* are the actual children of this object, however (the copy is not
* a "deep clone").
*/
- public NavigationMenuItem[] getNavigationMenuItems()
- {
- if (_navigationMenuItems == null)
- {
+ public NavigationMenuItem[] getNavigationMenuItems() {
+ if (_navigationMenuItems == null) {
return new NavigationMenuItem[0];
}
return (NavigationMenuItem[]) _navigationMenuItems.toArray(
- new NavigationMenuItem[_navigationMenuItems.size()]);
+ new NavigationMenuItem[_navigationMenuItems.size()]);
}
- /** Set the child nodes of this menu item. */
- public void setNavigationMenuItems(NavigationMenuItem[] navigationMenuItems)
- {
+ /**
+ * Set the child nodes of this menu item.
+ */
+ public void setNavigationMenuItems(NavigationMenuItem[] navigationMenuItems) {
_navigationMenuItems = Arrays.asList(navigationMenuItems);
}
- /** Set the child nodes of this menu item. */
- public void setNavigationMenuItems(List list)
- {
+ /**
+ * Set the child nodes of this menu item.
+ */
+ public void setNavigationMenuItems(List list) {
_navigationMenuItems = list;
}
/**
* Add another node to the end of the list of child nodes of
* this menu item.
- * <p>
+ * <p/>
* Note that if setNavigationMenuItems(array) was called previously,
* then this method will throw an exception as the child list will
* be of fixed length.
*/
- public void add(NavigationMenuItem navigationMenuItem)
- {
+ public void add(NavigationMenuItem navigationMenuItem) {
if (_navigationMenuItems == null)
_navigationMenuItems = new ArrayList();
_navigationMenuItems.add(navigationMenuItem);
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/UINavigationMenuItem.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/UINavigationMenuItem.java?rev=399048&r1=399047&r2=399048&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/UINavigationMenuItem.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/UINavigationMenuItem.java Tue May 2 13:56:12 2006
@@ -40,8 +40,7 @@
* @version $Revision$ $Date$
*/
public class UINavigationMenuItem extends UISelectItem implements
- UserRoleAware, ActionSource
-{
+ UserRoleAware, ActionSource {
private static final boolean DEFAULT_IMMEDIATE = true;
public static final String COMPONENT_TYPE = "org.apache.myfaces.NavigationMenuItem";
@@ -61,285 +60,254 @@
private String _disabledStyle = null;
private String _disabledStyleClass = null;
private String _activeOnViewIds = null;
+ private String _externalLink = null;
- public UINavigationMenuItem()
- {
+ public UINavigationMenuItem() {
super();
}
- public String getFamily()
- {
+ public String getFamily() {
return COMPONENT_FAMILY;
}
- public void setIcon(String icon)
- {
+ public void setIcon(String icon) {
_icon = icon;
}
- public String getIcon()
- {
+ public String getIcon() {
if (_icon != null)
return _icon;
ValueBinding vb = getValueBinding("icon");
return vb != null ? _ComponentUtils.getStringValue(getFacesContext(),
- vb) : null;
+ vb) : null;
}
- public void setSplit(boolean split)
- {
+ public void setSplit(boolean split) {
_split = Boolean.valueOf(split);
}
- public boolean isSplit()
- {
+ public boolean isSplit() {
if (_split != null)
return _split.booleanValue();
ValueBinding vb = getValueBinding("split");
Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext())
- : null;
+ : null;
return v != null && v.booleanValue();
}
- public void setOpen(boolean open)
- {
+ public void setOpen(boolean open) {
_open = Boolean.valueOf(open);
}
- public boolean isOpen()
- {
+ public boolean isOpen() {
if (_open != null)
return _open.booleanValue();
ValueBinding vb = getValueBinding("open");
Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext())
- : null;
+ : null;
return v != null && v.booleanValue();
}
- public void setActive(boolean active)
- {
+ public void setActive(boolean active) {
_active = Boolean.valueOf(active);
}
- public boolean isActive()
- {
+ public boolean isActive() {
if (_active != null)
return _active.booleanValue();
ValueBinding vb = getValueBinding("active");
Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext())
- : null;
+ : null;
return v != null && v.booleanValue();
}
- public void setImmediate(boolean immediate)
- {
+ public void setImmediate(boolean immediate) {
_immediate = Boolean.valueOf(immediate);
}
- public boolean isImmediate()
- {
+ public boolean isImmediate() {
if (_immediate != null)
return _immediate.booleanValue();
ValueBinding vb = getValueBinding("immediate");
Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext())
- : null;
+ : null;
return v != null ? v.booleanValue() : DEFAULT_IMMEDIATE;
}
+ public String getExternalLink() {
+ if (_externalLink != null)
+ return _externalLink;
+ ValueBinding vb = getValueBinding("externalLink");
+ return vb != null ? _ComponentUtils.getStringValue(getFacesContext(),
+ vb) : null;
+ }
+
+ public void setExternalLink(String externalLink) {
+ _externalLink = externalLink;
+ }
+
// Action Source
- public void setAction(MethodBinding action)
- {
+ public void setAction(MethodBinding action) {
_action = action;
}
- public MethodBinding getAction()
- {
+ public MethodBinding getAction() {
return _action;
}
- public void setActionListener(MethodBinding actionListener)
- {
+ public void setActionListener(MethodBinding actionListener) {
_actionListener = actionListener;
}
- public MethodBinding getActionListener()
- {
+ public MethodBinding getActionListener() {
return _actionListener;
}
- public void addActionListener(ActionListener listener)
- {
+ public void addActionListener(ActionListener listener) {
addFacesListener(listener);
}
- public ActionListener[] getActionListeners()
- {
+ public ActionListener[] getActionListeners() {
return (ActionListener[]) getFacesListeners(ActionListener.class);
}
- public void removeActionListener(ActionListener listener)
- {
+ public void removeActionListener(ActionListener listener) {
removeFacesListener(listener);
}
// Action Source
- public void setEnabledOnUserRole(String enabledOnUserRole)
- {
+ public void setEnabledOnUserRole(String enabledOnUserRole) {
_enabledOnUserRole = enabledOnUserRole;
}
- public String getEnabledOnUserRole()
- {
+ public String getEnabledOnUserRole() {
if (_enabledOnUserRole != null)
return _enabledOnUserRole;
ValueBinding vb = getValueBinding("enabledOnUserRole");
return vb != null ? _ComponentUtils.getStringValue(getFacesContext(),
- vb) : null;
+ vb) : null;
}
- public void setVisibleOnUserRole(String visibleOnUserRole)
- {
+ public void setVisibleOnUserRole(String visibleOnUserRole) {
_visibleOnUserRole = visibleOnUserRole;
}
- public String getVisibleOnUserRole()
- {
+ public String getVisibleOnUserRole() {
if (_visibleOnUserRole != null)
return _visibleOnUserRole;
ValueBinding vb = getValueBinding("visibleOnUserRole");
return vb != null ? _ComponentUtils.getStringValue(getFacesContext(),
- vb) : null;
+ vb) : null;
}
- public void setTarget(String target)
- {
+ public void setTarget(String target) {
_target = target;
}
- public String getTarget()
- {
+ public String getTarget() {
if (_target != null)
return _target;
ValueBinding vb = getValueBinding("target");
return vb != null ? _ComponentUtils.getStringValue(getFacesContext(),
- vb) : null;
+ vb) : null;
}
- public void setDisabled(boolean disabled)
- {
+ public void setDisabled(boolean disabled) {
_disabled = Boolean.valueOf(disabled);
}
- public boolean isDisabled()
- {
+ public boolean isDisabled() {
if (_disabled != null)
return _disabled.booleanValue();
ValueBinding vb = getValueBinding("disabled");
Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext())
- : null;
+ : null;
return v != null && v.booleanValue();
}
- public String getDisabledStyle()
- {
+ public String getDisabledStyle() {
if (_disabledStyle != null)
return _disabledStyle;
ValueBinding vb = getValueBinding("disabledStyle");
return vb != null ? _ComponentUtils.getStringValue(getFacesContext(),
- vb) : null;
+ vb) : null;
}
- public void setDisabledStyle(String disabledStyle)
- {
+ public void setDisabledStyle(String disabledStyle) {
_disabledStyle = disabledStyle;
}
/**
* @see javax.faces.component.UIComponent#broadcast(javax.faces.event.FacesEvent)
*/
- public void broadcast(FacesEvent event) throws AbortProcessingException
- {
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
super.broadcast(event);
- if (event instanceof ActionEvent)
- {
+ if (event instanceof ActionEvent) {
FacesContext context = getFacesContext();
MethodBinding actionListenerBinding = getActionListener();
- if (actionListenerBinding != null)
- {
- try
- {
+ if (actionListenerBinding != null) {
+ try {
actionListenerBinding.invoke(context,
- new Object[] { event });
+ new Object[]{event});
}
- catch (EvaluationException e)
- {
+ catch (EvaluationException e) {
Throwable cause = e.getCause();
if (cause != null
- && cause instanceof AbortProcessingException)
- {
+ && cause instanceof AbortProcessingException) {
throw (AbortProcessingException) cause;
}
- else
- {
+ else {
throw e;
}
}
}
ActionListener defaultActionListener = context.getApplication()
- .getActionListener();
- if (defaultActionListener != null)
- {
+ .getActionListener();
+ if (defaultActionListener != null) {
defaultActionListener.processAction((ActionEvent) event);
}
}
}
- public String getDisabledStyleClass()
- {
+ public String getDisabledStyleClass() {
if (_disabledStyleClass != null)
return _disabledStyleClass;
ValueBinding vb = getValueBinding("disabledStyleClass");
return vb != null ? _ComponentUtils.getStringValue(getFacesContext(),
- vb) : null;
+ vb) : null;
}
- public void setDisabledStyleClass(String disabledStyleClass)
- {
+ public void setDisabledStyleClass(String disabledStyleClass) {
_disabledStyleClass = disabledStyleClass;
}
- public String getActiveOnViewIds()
- {
+ public String getActiveOnViewIds() {
if (_activeOnViewIds != null) return _activeOnViewIds;
ValueBinding vb = getValueBinding("activeOnViewIds");
return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
}
- public String getActiveOnViewIdsDirectly()
- {
+ public String getActiveOnViewIdsDirectly() {
return _activeOnViewIds;
}
- public void setActiveOnViewIds(String activeOnViewIds)
- {
+ public void setActiveOnViewIds(String activeOnViewIds) {
this._activeOnViewIds = activeOnViewIds;
}
- public boolean isRendered()
- {
+ public boolean isRendered() {
if (!UserRoleUtils.isVisibleOnUserRole(this))
return false;
return super.isRendered();
}
- public Object saveState(FacesContext context)
- {
- Object values[] = new Object[15];
+ public Object saveState(FacesContext context) {
+ Object values[] = new Object[16];
values[0] = super.saveState(context);
values[1] = _icon;
values[2] = _split;
@@ -355,11 +323,11 @@
values[12] = _disabledStyle;
values[13] = _disabledStyleClass;
values[14] = _activeOnViewIds;
+ values[15] = _externalLink;
return ((Object) (values));
}
- public void restoreState(FacesContext context, Object state)
- {
+ public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
_icon = (String) values[1];
@@ -370,104 +338,86 @@
_open = (Boolean) values[6];
_active = (Boolean) values[7];
_actionListener = (MethodBinding) restoreAttachedState(context,
- values[8]);
+ values[8]);
_immediate = (Boolean) values[9];
_target = (String) values[10];
_disabled = (Boolean) values[11];
_disabledStyle = (String) values[12];
_disabledStyleClass = (String) values[13];
_activeOnViewIds = (String) values[14];
+ _externalLink = (String) values[15];
}
- public void toggleActive(FacesContext context)
- {
+ public void toggleActive(FacesContext context) {
StringTokenizer tokenizer = new StringTokenizer(this.getActiveOnViewIdsDirectly(), ";");
- while (tokenizer.hasMoreTokens())
- {
- String token = tokenizer.nextToken();
- if(token.trim().equals(context.getViewRoot().getViewId()))
- {
+ while (tokenizer.hasMoreTokens()) {
+ String token = tokenizer.nextToken();
+ if (token.trim().equals(context.getViewRoot().getViewId())) {
this.deactivateAll();
this.setActive(true);
openParents();
}
- else
- {
+ else {
this.setActive(false);
}
}
}
- private void openParents()
- {
+ private void openParents() {
UIComponent comp = this;
- while((comp = comp.getParent()) instanceof UINavigationMenuItem)
- {
+ while ((comp = comp.getParent()) instanceof UINavigationMenuItem) {
UINavigationMenuItem parent = (UINavigationMenuItem) comp;
- if(!parent.isOpen())
+ if (!parent.isOpen())
parent.setOpen(true);
else
return;
}
}
- public void deactivateAll()
- {
+ public void deactivateAll() {
UIComponent parent = this.getParent();
- while(!(parent instanceof HtmlPanelNavigationMenu) && parent != null)
- {
+ while (!(parent instanceof HtmlPanelNavigationMenu) && parent != null) {
parent = parent.getParent();
}
- if(parent == null)
- {
+ if (parent == null) {
throw new IllegalStateException("no PanelNavigationMenu!");
}
HtmlPanelNavigationMenu root = (HtmlPanelNavigationMenu) parent;
- for(Iterator it = root.getChildren().iterator(); it.hasNext();)
- {
+ for (Iterator it = root.getChildren().iterator(); it.hasNext();) {
Object o = it.next();
- if(o instanceof UINavigationMenuItem)
- {
+ if (o instanceof UINavigationMenuItem) {
UINavigationMenuItem navItem = (UINavigationMenuItem) o;
navItem.setActive(false);
- if(navItem.getChildCount() > 0)
- {
+ if (navItem.getChildCount() > 0) {
navItem.deactivateChildren();
}
}
- if(o instanceof HtmlCommandNavigationItem)
- {
+ if (o instanceof HtmlCommandNavigationItem) {
HtmlCommandNavigationItem current = (HtmlCommandNavigationItem) o;
current.setActive(false);
- if(current.getChildCount() > 0)
- {
+ if (current.getChildCount() > 0) {
current.deactivateChildren();
}
}
}
}
- public void deactivateChildren()
- {
- for(Iterator it = this.getChildren().iterator(); it.hasNext();)
- {
+ public void deactivateChildren() {
+ for (Iterator it = this.getChildren().iterator(); it.hasNext();) {
Object o = it.next();
- if(o instanceof UINavigationMenuItem)
- {
+ if (o instanceof UINavigationMenuItem) {
UINavigationMenuItem current = (UINavigationMenuItem) o;
current.setActive(false);
- if(current.getChildCount() > 0)
- {
+ if (current.getChildCount() > 0) {
current.deactivateChildren();
}
}
}
}
- public Boolean getActiveDirectly()
- {
+ public Boolean getActiveDirectly() {
return _active;
}
}
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlCommandNavigationItem.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlCommandNavigationItem.java?rev=399048&r1=399047&r2=399048&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlCommandNavigationItem.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlCommandNavigationItem.java Tue May 2 13:56:12 2006
@@ -30,83 +30,83 @@
import java.util.*;
/**
- * Many thanks to the guys from Swiss Federal Institute of Intellectual Property & Marc Bouquet
+ * Many thanks to the guys from Swiss Federal Institute of Intellectual Property & Marc Bouquet
* for helping to develop this component.
+ *
* @author Manfred Geiler
* @author Thomas Spiegl
*/
-public class HtmlCommandNavigationItem extends HtmlCommandLink
-{
+public class HtmlCommandNavigationItem extends HtmlCommandLink {
private static final Log log = LogFactory.getLog(HtmlCommandNavigationItem.class);
private Boolean _open = null;
private Boolean _active = null;
private String _activeOnViewIds = null;
+ private String _externalLink = null;
- public boolean isImmediate()
- {
+ public boolean isImmediate() {
//always immediate
return true;
}
- public void setImmediate(Boolean immediate)
- {
+ public void setImmediate(Boolean immediate) {
if (log.isWarnEnabled()) log.warn("Immediate property of HtmlCommandNavigation cannot be set --> ignored.");
}
- public boolean isOpen()
- {
+ public boolean isOpen() {
if (_open != null) return _open.booleanValue();
ValueBinding vb = getValueBinding("open");
- Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
+ Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
return v != null && v.booleanValue();
}
- public Boolean getOpenDirectly()
- {
+ public Boolean getOpenDirectly() {
return _open;
}
- public void setOpen(boolean open)
- {
+ public void setOpen(boolean open) {
_open = open ? Boolean.TRUE : Boolean.FALSE;
}
- public boolean isActive()
- {
+ public boolean isActive() {
if (_active != null) return _active.booleanValue();
ValueBinding vb = getValueBinding("active");
- Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) : null;
+ Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
return v != null && v.booleanValue();
}
- public Boolean getActiveDirectly()
- {
+ public Boolean getActiveDirectly() {
return _active;
}
- public void setActive(boolean active)
- {
+ public void setActive(boolean active) {
_active = active ? Boolean.TRUE : Boolean.FALSE;
}
- public String getActiveOnViewIds()
- {
+ public String getActiveOnViewIds() {
if (_activeOnViewIds != null) return _activeOnViewIds;
ValueBinding vb = getValueBinding("activeOnViewIds");
return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
}
- public void setActiveOnViewIds(String activeOnViewIds)
- {
+ public void setActiveOnViewIds(String activeOnViewIds) {
this._activeOnViewIds = activeOnViewIds;
}
+ public String getExternalLink() {
+ if (_externalLink != null) return _externalLink;
+ ValueBinding vb = getValueBinding("externalLink");
+ return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+ }
+
+ public void setExternalLink(String externalLink) {
+ this._externalLink = externalLink;
+ }
+
/**
* @return false, if this item is child of another HtmlCommandNavigation, which is closed
*/
- public boolean isRendered()
- {
+ public boolean isRendered() {
if (! super.isRendered()) {
return false;
}
@@ -116,22 +116,17 @@
return true;
UIComponent parent = getParent();
- while (parent != null)
- {
- if (parent instanceof HtmlCommandNavigationItem)
- {
- if (!((HtmlCommandNavigationItem)parent).isOpen())
- {
+ while (parent != null) {
+ if (parent instanceof HtmlCommandNavigationItem) {
+ if (!((HtmlCommandNavigationItem) parent).isOpen()) {
return false;
}
}
- if (parent instanceof HtmlPanelNavigationMenu)
- {
+ if (parent instanceof HtmlPanelNavigationMenu) {
break;
}
- else
- {
+ else {
parent = parent.getParent();
}
}
@@ -139,19 +134,16 @@
return true;
}
- private HtmlPanelNavigationMenu getParentPanelNavigation()
- {
+ private HtmlPanelNavigationMenu getParentPanelNavigation() {
UIComponent parent = getParent();
// search HtmlPanelNavigation
UIComponent p = parent;
- while (p != null && !(p instanceof HtmlPanelNavigationMenu))
- {
+ while (p != null && !(p instanceof HtmlPanelNavigationMenu)) {
p = p.getParent();
}
// p is now the HtmlPanelNavigation
- if (!(p instanceof HtmlPanelNavigationMenu))
- {
+ if (!(p instanceof HtmlPanelNavigationMenu)) {
log.error("HtmlCommandNavigation without parent HtmlPanelNavigation ?!");
return null;
}
@@ -159,19 +151,15 @@
return (HtmlPanelNavigationMenu) p;
}
- public void toggleOpen()
- {
+ public void toggleOpen() {
HtmlPanelNavigationMenu menu = getParentPanelNavigation();
- if (isOpen() && menu != null && !menu.isExpandAll() )
- {
- if (getChildCount() > 0)
- {
+ if (isOpen() && menu != null && !menu.isExpandAll()) {
+ if (getChildCount() > 0) {
//item is a menu group --> close item
setOpen(false);
}
}
- else
- {
+ else {
UIComponent parent = getParent();
//close all siblings
@@ -179,23 +167,18 @@
//open all parents (to be sure) and search HtmlPanelNavigation
UIComponent p = parent;
- while (p != null && !(p instanceof HtmlPanelNavigationMenu))
- {
- if (p instanceof HtmlCommandNavigationItem)
- {
- ((HtmlCommandNavigationItem)p).setOpen(true);
+ while (p != null && !(p instanceof HtmlPanelNavigationMenu)) {
+ if (p instanceof HtmlCommandNavigationItem) {
+ ((HtmlCommandNavigationItem) p).setOpen(true);
}
p = p.getParent();
}
// p is now the HtmlPanelNavigation
- if (!(p instanceof HtmlPanelNavigationMenu))
- {
+ if (!(p instanceof HtmlPanelNavigationMenu)) {
log.error("HtmlCommandNavigation without parent HtmlPanelNavigation ?!");
}
- else
- {
- if (!hasCommandNavigationChildren() || ((HtmlPanelNavigationMenu) p).isExpandAll())
- {
+ else {
+ if (!hasCommandNavigationChildren() || ((HtmlPanelNavigationMenu) p).isExpandAll()) {
//item is an end node or Menu always expanded --> deactivate all other nodes, and then...
//deactivate all other items
@@ -203,8 +186,7 @@
//...activate this item
setActive(true);
}
- else
- {
+ else {
//open item
setOpen(true);
}
@@ -212,17 +194,13 @@
}
}
- private boolean hasCommandNavigationChildren()
- {
- if (getChildCount() == 0)
- {
+ private boolean hasCommandNavigationChildren() {
+ if (getChildCount() == 0) {
return false;
}
List list = getChildren();
- for (int i = 0, sizei = list.size(); i < sizei; i++)
- {
- if (list.get(i) instanceof HtmlCommandNavigationItem)
- {
+ for (int i = 0, sizei = list.size(); i < sizei; i++) {
+ if (list.get(i) instanceof HtmlCommandNavigationItem) {
return true;
}
}
@@ -230,117 +208,91 @@
}
- private static void deactivateAllChildren(Iterator children)
- {
- while (children.hasNext())
- {
- UIComponent ni = (UIComponent)children.next();
- if (ni instanceof HtmlCommandNavigationItem)
- {
- ((HtmlCommandNavigationItem)ni).setActive(false);
- if (ni.getChildCount() > 0)
- {
+ private static void deactivateAllChildren(Iterator children) {
+ while (children.hasNext()) {
+ UIComponent ni = (UIComponent) children.next();
+ if (ni instanceof HtmlCommandNavigationItem) {
+ ((HtmlCommandNavigationItem) ni).setActive(false);
+ if (ni.getChildCount() > 0) {
deactivateAllChildren(ni.getChildren().iterator());
}
}
}
}
- private static void closeAllChildren(Iterator children)
- {
- while (children.hasNext())
- {
- UIComponent ni = (UIComponent)children.next();
- if (ni instanceof HtmlCommandNavigationItem)
- {
- ((HtmlCommandNavigationItem)ni).setOpen(false);
- if (ni.getChildCount() > 0)
- {
+ private static void closeAllChildren(Iterator children) {
+ while (children.hasNext()) {
+ UIComponent ni = (UIComponent) children.next();
+ if (ni instanceof HtmlCommandNavigationItem) {
+ ((HtmlCommandNavigationItem) ni).setOpen(false);
+ if (ni.getChildCount() > 0) {
closeAllChildren(ni.getChildren().iterator());
}
}
}
}
- public String[] getActiveOnVieIds()
- {
+ public String[] getActiveOnVieIds() {
String value = getActiveOnViewIds();
if (value == null)
- return new String[] {};
+ return new String[]{};
return value.split(",");
}
- private void openParents()
- {
+ private void openParents() {
UIComponent comp = this;
- while((comp = comp.getParent()) instanceof HtmlCommandNavigationItem)
- {
+ while ((comp = comp.getParent()) instanceof HtmlCommandNavigationItem) {
HtmlCommandNavigationItem parent = (HtmlCommandNavigationItem) comp;
- if(!parent.isOpen())
- {
+ if (!parent.isOpen()) {
parent.setOpen(true);
}
- else
- {
+ else {
return;
}
}
}
- public void deactivateAll()
- {
+ public void deactivateAll() {
UIComponent parent = this.getParent();
- while(!(parent instanceof HtmlPanelNavigationMenu) && parent != null)
- {
+ while (!(parent instanceof HtmlPanelNavigationMenu) && parent != null) {
parent = parent.getParent();
}
- if(parent == null)
- {
+ if (parent == null) {
throw new IllegalStateException("no PanelNavigationMenu!");
}
HtmlPanelNavigationMenu root = (HtmlPanelNavigationMenu) parent;
- for(Iterator it = root.getChildren().iterator(); it.hasNext();)
- {
+ for (Iterator it = root.getChildren().iterator(); it.hasNext();) {
Object o = it.next();
- if(o instanceof HtmlCommandNavigationItem)
- {
+ if (o instanceof HtmlCommandNavigationItem) {
HtmlCommandNavigationItem navItem = (HtmlCommandNavigationItem) o;
navItem.setActive(false);
- if(navItem.getChildCount() > 0)
- {
+ if (navItem.getChildCount() > 0) {
navItem.deactivateChildren();
}
}
}
}
- public void deactivateChildren()
- {
- for(Iterator it = this.getChildren().iterator(); it.hasNext();)
- {
+ public void deactivateChildren() {
+ for (Iterator it = this.getChildren().iterator(); it.hasNext();) {
Object o = it.next();
- if(o instanceof HtmlCommandNavigationItem)
- {
+ if (o instanceof HtmlCommandNavigationItem) {
HtmlCommandNavigationItem current = (HtmlCommandNavigationItem) o;
current.setActive(false);
- if(current.getChildCount() > 0)
- {
+ if (current.getChildCount() > 0) {
current.deactivateChildren();
}
}
}
}
- public void broadcast(FacesEvent event) throws AbortProcessingException
- {
- if (event instanceof ActionEvent)
- {
- ActionEvent actionEvent = (ActionEvent)event;
- if (actionEvent.getPhaseId() == PhaseId.APPLY_REQUEST_VALUES)
- {
- HtmlCommandNavigationItem navItem = (HtmlCommandNavigationItem)actionEvent.getComponent();
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ if (event instanceof ActionEvent) {
+ ActionEvent actionEvent = (ActionEvent) event;
+ if (actionEvent.getPhaseId() == PhaseId.APPLY_REQUEST_VALUES) {
+ HtmlCommandNavigationItem navItem = (HtmlCommandNavigationItem) actionEvent.getComponent();
navItem.toggleOpen();
FacesContext.getCurrentInstance().renderResponse();
}
@@ -349,26 +301,25 @@
}
- public Object saveState(FacesContext context)
- {
- Object values[] = new Object[4];
+ public Object saveState(FacesContext context) {
+ Object values[] = new Object[5];
values[0] = super.saveState(context);
values[1] = _open;
values[2] = _active;
values[3] = _activeOnViewIds;
+ values[4] = _externalLink;
return ((Object) (values));
}
- public void restoreState(FacesContext context, Object state)
- {
- Object values[] = (Object[])state;
+ public void restoreState(FacesContext context, Object state) {
+ Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
- _open = ((Boolean)values[1]);
- _active = ((Boolean)values[2]);
- _activeOnViewIds = ((String)values[3]);
+ _open = ((Boolean) values[1]);
+ _active = ((Boolean) values[2]);
+ _activeOnViewIds = ((String) values[3]);
+ _externalLink = ((String) values[4]);
}
-
//------------------ GENERATED CODE BEGIN (do not modify!) --------------------
public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlCommandNavigationItem";
@@ -376,16 +327,13 @@
private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Link";
- public HtmlCommandNavigationItem()
- {
+ public HtmlCommandNavigationItem() {
setRendererType(DEFAULT_RENDERER_TYPE);
}
- public String getFamily()
- {
+ public String getFamily() {
return COMPONENT_FAMILY;
}
-
//------------------ GENERATED CODE END ---------------------------------------
}
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlCommandNavigationItemTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlCommandNavigationItemTag.java?rev=399048&r1=399047&r2=399048&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlCommandNavigationItemTag.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlCommandNavigationItemTag.java Tue May 2 13:56:12 2006
@@ -23,47 +23,47 @@
* @author Manfred Geiler
* @author Thomas Spiegl
*/
-public class HtmlCommandNavigationItemTag extends HtmlCommandLinkTag
-{
- private static final String OPEN_ATTR = "open".intern();
+public class HtmlCommandNavigationItemTag extends HtmlCommandLinkTag {
+ private static final String OPEN_ATTR = "open".intern();
private static final String ACTIVE_ATTR = "active".intern();
private static final String ACTIVE_ON_VIEW_IDS_ATTR = "activeOnViewIds".intern();
+ private static final String EXTERNAL_LINK = "externalLink".intern();
private String _open;
private String _active;
private String _activeOnViewIds;
+ private String _externalLink;
- public String getComponentType()
- {
+ public String getComponentType() {
return HtmlCommandNavigationItem.COMPONENT_TYPE;
}
- public String getRendererType()
- {
+ public String getRendererType() {
return HtmlNavigationMenuRenderer.RENDERER_TYPE;
}
- protected void setProperties(UIComponent component)
- {
+ protected void setProperties(UIComponent component) {
super.setProperties(component);
setBooleanProperty(component, OPEN_ATTR, _open);
setBooleanProperty(component, ACTIVE_ATTR, _active);
setStringProperty(component, ACTIVE_ON_VIEW_IDS_ATTR, _activeOnViewIds);
+ setStringProperty(component, EXTERNAL_LINK, _externalLink);
}
- public void setOpen(String open)
- {
+ public void setOpen(String open) {
_open = open;
}
- public void setActive(String active)
- {
+ public void setActive(String active) {
_active = active;
}
- public void setActiveOnViewIds(String activeOnViewIds)
- {
+ public void setActiveOnViewIds(String activeOnViewIds) {
_activeOnViewIds = activeOnViewIds;
+ }
+
+ public void setExternalLink(String externalLink) {
+ _externalLink = externalLink;
}
}
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlNavigationMenuRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlNavigationMenuRenderer.java?rev=399048&r1=399047&r2=399048&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlNavigationMenuRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlNavigationMenuRenderer.java Tue May 2 13:56:12 2006
@@ -34,81 +34,69 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+
import org.apache.myfaces.renderkit.html.util.AddResource;
import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
/**
* Many thanks to the guys from Swiss Federal Institute of Intellectual Property & Marc Bouquet
* for helping to develop this component.
+ *
* @author Thomas Spiegl
* @author Manfred Geiler
*/
-public class HtmlNavigationMenuRenderer extends HtmlLinkRenderer
-{
+public class HtmlNavigationMenuRenderer extends HtmlLinkRenderer {
private static final Log log = LogFactory.getLog(HtmlNavigationMenuRenderer.class);
public static final String RENDERER_TYPE = "org.apache.myfaces.NavigationMenu";
private static final Integer ZERO_INTEGER = new Integer(0);
-
+
private static final String HORIZ_MENU_SCRIPT = "HMenuIEHover.js";
-
- public boolean getRendersChildren()
- {
+
+ public boolean getRendersChildren() {
return true;
}
- public void decode(FacesContext facesContext, UIComponent component)
- {
- if (component instanceof HtmlCommandNavigationItem)
- {
+ public void decode(FacesContext facesContext, UIComponent component) {
+ if (component instanceof HtmlCommandNavigationItem) {
//HtmlCommandNavigation
super.decode(facesContext, component);
}
}
- public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException
- {
- if (component instanceof HtmlCommandNavigationItem)
- {
+ public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
+ if (component instanceof HtmlCommandNavigationItem) {
//HtmlCommandNavigationItem
super.encodeBegin(facesContext, component);
}
}
- public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException
- {
- if (component instanceof HtmlCommandNavigationItem)
- {
+ public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
+ if (component instanceof HtmlCommandNavigationItem) {
//HtmlCommandNavigationItem
super.encodeChildren(facesContext, component);
}
}
- public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
- {
- if (component instanceof HtmlCommandNavigationItem)
- {
+ public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
+ if (component instanceof HtmlCommandNavigationItem) {
//HtmlCommandNavigationItem
super.encodeEnd(facesContext, component);
return;
}
RendererUtils.checkParamValidity(facesContext, component, HtmlPanelNavigationMenu.class);
- HtmlPanelNavigationMenu panelNav = (HtmlPanelNavigationMenu)component;
-
- if (HtmlNavigationMenuRendererUtils.isListLayout(panelNav))
- {
+ HtmlPanelNavigationMenu panelNav = (HtmlPanelNavigationMenu) component;
+
+ if (HtmlNavigationMenuRendererUtils.isListLayout(panelNav)) {
boolean preprocess = true;
boolean clientStateSaving = facesContext.getApplication().getStateManager().isSavingStateInClient(facesContext);
- if (clientStateSaving)
- {
+ if (clientStateSaving) {
// client statesaving
HtmlPanelNavigationMenu panelNavPrev = findPreviousPanelNav(facesContext, panelNav);
- if (panelNavPrev != null)
- {
+ if (panelNavPrev != null) {
preprocess = false;
- if (!panelNavPrev.equals(panelNav))
- {
+ if (!panelNavPrev.equals(panelNav)) {
// substitute panelnav
UIComponent parent = panelNav.getParent();
int insertPos = parent.getChildren().indexOf(panelNav);
@@ -119,21 +107,17 @@
}
}
}
- else
- {
+ else {
// server statesaving
if (panelNav.getPreprocessed() != null && panelNav.getPreprocessed().booleanValue())
preprocess = false;
}
- if (preprocess)
- {
+ if (preprocess) {
panelNav.setPreprocessed(Boolean.TRUE);
preprocessNavigationItems(facesContext, panelNav, panelNav.getChildren(), new UniqueId());
- if (!clientStateSaving)
- {
+ if (!clientStateSaving) {
HtmlPanelNavigationMenu panelNavPrev = findPreviousPanelNav(facesContext, panelNav);
- if (panelNavPrev != null)
- {
+ if (panelNavPrev != null) {
restoreOpenActiveStates(facesContext, panelNav, panelNavPrev.getChildren());
}
}
@@ -143,44 +127,34 @@
HtmlNavigationMenuRendererUtils.debugTree(log, facesContext, panelNav.getChildren(), 0);
renderListLayout(facesContext, panelNav);
}
- else
- {
+ else {
renderTableLayout(facesContext, panelNav);
}
}
private void restoreOpenActiveStates(FacesContext facesContext,
- HtmlPanelNavigationMenu panelNav, List children)
- {
- for (int i = 0, size = children.size(); i < size; i++)
- {
+ HtmlPanelNavigationMenu panelNav, List children) {
+ for (int i = 0, size = children.size(); i < size; i++) {
UIComponent uiComponent = (UIComponent) children.get(i);
- if (uiComponent instanceof HtmlCommandNavigationItem)
- {
+ if (uiComponent instanceof HtmlCommandNavigationItem) {
HtmlCommandNavigationItem prevItem = (HtmlCommandNavigationItem) uiComponent;
- if (prevItem.isOpen() || prevItem.isActive())
- {
+ if (prevItem.isOpen() || prevItem.isActive()) {
HtmlCommandNavigationItem item = (HtmlCommandNavigationItem) panelNav.findComponent(uiComponent.getClientId(facesContext));
- if (item != null)
- {
- if (item.getActiveDirectly() != null)
- {
+ if (item != null) {
+ if (item.getActiveDirectly() != null) {
item.setActive(prevItem.isActive());
}
- else
- {
+ else {
copyValueBinding(prevItem, item, "active");
}
- if (item.getOpenDirectly() != null)
- {
+ if (item.getOpenDirectly() != null) {
item.setOpen(prevItem.isOpen());
}
- else
- {
+ else {
copyValueBinding(prevItem, item, "open");
}
- if(!panelNav.isExpandAll() || prevItem.isActive() )
+ if (!panelNav.isExpandAll() || prevItem.isActive())
item.toggleOpen();
if (prevItem.isOpen())
restoreOpenActiveStates(facesContext, panelNav, prevItem.getChildren());
@@ -190,39 +164,33 @@
}
}
- private HtmlPanelNavigationMenu findPreviousPanelNav(FacesContext facesContext, HtmlPanelNavigationMenu panelNav)
- {
+ private HtmlPanelNavigationMenu findPreviousPanelNav(FacesContext facesContext, HtmlPanelNavigationMenu panelNav) {
UIViewRoot previousViewRoot = findPreviousRoot(facesContext);
- if (previousViewRoot != null)
- {
+ if (previousViewRoot != null) {
return (HtmlPanelNavigationMenu) previousViewRoot.findComponent(panelNav.getClientId(facesContext));
}
return null;
}
- private UIViewRoot findPreviousRoot(FacesContext facesContext)
- {
- return (UIViewRoot)facesContext.getExternalContext().getRequestMap().get(HtmlPanelNavigationMenu.PREVIOUS_VIEW_ROOT);
+ private UIViewRoot findPreviousRoot(FacesContext facesContext) {
+ return (UIViewRoot) facesContext.getExternalContext().getRequestMap().get(HtmlPanelNavigationMenu.PREVIOUS_VIEW_ROOT);
}
- protected void renderListLayout(FacesContext facesContext, HtmlPanelNavigationMenu panelNav) throws IOException
- {
+ protected void renderListLayout(FacesContext facesContext, HtmlPanelNavigationMenu panelNav) throws IOException {
if (panelNav.isRenderAll())
addResourcesToHeader(facesContext);
-
+
ResponseWriter writer = facesContext.getResponseWriter();
- if (panelNav.getChildCount() > 0)
- {
+ if (panelNav.getChildCount() > 0) {
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
writer.startElement(HTML.UL_ELEM, panelNav);
-
+
HtmlRendererUtils.renderHTMLAttributes(writer, panelNav, HTML.UL_PASSTHROUGH_ATTRIBUTES);
//iterate over the tree and toggleOpen if viewId in item.getActiveOnVieIds()
activeOnViewId(panelNav, facesContext.getViewRoot().getViewId());
//iterate over the tree and set every item open if expandAll
- if (panelNav.isExpandAll())
- {
+ if (panelNav.isExpandAll()) {
expandAll(panelNav);
}
@@ -231,23 +199,19 @@
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
writer.endElement(HTML.UL_ELEM);
}
- else
- {
+ else {
if (log.isWarnEnabled()) log.warn("PanelNavaigationMenu without children.");
}
}
- private void renderTableLayout(FacesContext facesContext, HtmlPanelNavigationMenu panelNav) throws IOException
- {
+ private void renderTableLayout(FacesContext facesContext, HtmlPanelNavigationMenu panelNav) throws IOException {
ResponseWriter writer = facesContext.getResponseWriter();
- if (panelNav.getChildCount() > 0)
- {
+ if (panelNav.getChildCount() > 0) {
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
writer.startElement(HTML.TABLE_ELEM, panelNav);
HtmlRendererUtils.renderHTMLAttributes(writer, panelNav, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
- if (panelNav.getStyle() == null && panelNav.getStyleClass() == null)
- {
+ if (panelNav.getStyle() == null && panelNav.getStyleClass() == null) {
writer.writeAttribute(HTML.BORDER_ATTR, ZERO_INTEGER, null);
}
@@ -256,43 +220,35 @@
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
writer.endElement(HTML.TABLE_ELEM);
}
- else
- {
+ else {
if (log.isWarnEnabled()) log.warn("PanelNavaigationMenu without children.");
}
- }
-
- private void addResourcesToHeader(FacesContext context)
- {
- AddResource addResource = AddResourceFactory.getInstance(context);
- addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlPanelNavigationMenu.class, HORIZ_MENU_SCRIPT);
+ }
+
+ private void addResourcesToHeader(FacesContext context) {
+ AddResource addResource = AddResourceFactory.getInstance(context);
+ addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, HtmlPanelNavigationMenu.class, HORIZ_MENU_SCRIPT);
}
/**
* look for UINavigationMenuItem && UISelectItems & create components
*/
private void preprocessNavigationItems(FacesContext facesContext, UIComponent parent,
- List children, UniqueId uniqueId)
- {
- for (int i = 0; i < children.size(); i++)
- {
- UIComponent child = (UIComponent)children.get(i);
-
- if (child instanceof HtmlCommandNavigationItem)
- {
- HtmlCommandNavigationItem navMenuItem = (HtmlCommandNavigationItem) child;
- preprocessNavigationItems(facesContext, navMenuItem, navMenuItem.getChildren(), uniqueId);
+ List children, UniqueId uniqueId) {
+ for (int i = 0; i < children.size(); i++) {
+ UIComponent child = (UIComponent) children.get(i);
+
+ if (child instanceof HtmlCommandNavigationItem) {
+ HtmlCommandNavigationItem navMenuItem = (HtmlCommandNavigationItem) child;
+ preprocessNavigationItems(facesContext, navMenuItem, navMenuItem.getChildren(), uniqueId);
}
- else if (child instanceof UINavigationMenuItem)
- {
+ else if (child instanceof UINavigationMenuItem) {
UINavigationMenuItem uiNavMenuItem = (UINavigationMenuItem) child;
createHtmlCommandNavigationItem(facesContext, parent, i, uiNavMenuItem, uniqueId);
}
- else if (child instanceof UISelectItems)
- {
+ else if (child instanceof UISelectItems) {
List list = new ArrayList();
- if (child.getId() == null)
- {
+ if (child.getId() == null) {
child.setId("testit");
}
NavigationMenuUtils.addNavigationMenuItems((UISelectItems) child, list);
@@ -301,75 +257,69 @@
}
}
- private void addUINavigationMenuItems(FacesContext facesContext, UIComponent parent, List children, int startIndex, List menuItems)
- {
+ private void addUINavigationMenuItems(FacesContext facesContext, UIComponent parent, List children, int startIndex, List menuItems) {
String clientId = parent.getClientId(facesContext);
clientId = clientId.replaceAll(":", "_");
- for (int j = 0, sizej = menuItems.size(); j < sizej; j++)
- {
- NavigationMenuItem uiNavMenuItem = (NavigationMenuItem) menuItems.get(j);
- UINavigationMenuItem newItem =
+ for (int j = 0, sizej = menuItems.size(); j < sizej; j++) {
+ NavigationMenuItem navigationMenuItem = (NavigationMenuItem) menuItems.get(j);
+ UINavigationMenuItem uiNavigationMenuItem =
(UINavigationMenuItem) facesContext.getApplication().createComponent(UINavigationMenuItem.COMPONENT_TYPE);
- newItem.setId(clientId + "_uinavmitem" + (startIndex + j));
- newItem.getClientId(facesContext); // create clientid
- newItem.setParent(parent);
- children.add(startIndex++, newItem);
- if (uiNavMenuItem.getAction() != null)
- {
- newItem.setAction(HtmlNavigationMenuRendererUtils.getMethodBinding(facesContext, uiNavMenuItem.getAction(), false));
- }
- if (uiNavMenuItem.getActionListener() != null)
- {
- newItem.setActionListener(HtmlNavigationMenuRendererUtils.getMethodBinding(facesContext,
- uiNavMenuItem.getActionListener(), true));
- }
- newItem.setIcon(uiNavMenuItem.getIcon());
- newItem.setRendered(uiNavMenuItem.isRendered());
- newItem.setSplit(uiNavMenuItem.isSplit());
- newItem.setItemLabel(uiNavMenuItem.getLabel());
- newItem.setOpen(uiNavMenuItem.isOpen());
- newItem.setActive(uiNavMenuItem.isActive());
- newItem.setValue(uiNavMenuItem.getValue());
- newItem.setTransient(false);
- newItem.setTarget(uiNavMenuItem.getTarget());
- newItem.setDisabled(uiNavMenuItem.isDisabled());
- newItem.setDisabledStyle(uiNavMenuItem.getDisabledStyle());
- newItem.setDisabledStyleClass(uiNavMenuItem.getDisabledStyleClass());
-
- if (uiNavMenuItem.getNavigationMenuItems() != null && uiNavMenuItem.getNavigationMenuItems().length > 0)
+ uiNavigationMenuItem.setId(clientId + "_uinavmitem" + (startIndex + j));
+ uiNavigationMenuItem.getClientId(facesContext); // create clientid
+ uiNavigationMenuItem.setParent(parent);
+ children.add(startIndex++, uiNavigationMenuItem);
+ if (navigationMenuItem.getAction() != null) {
+ uiNavigationMenuItem.setAction(HtmlNavigationMenuRendererUtils.getMethodBinding(facesContext, navigationMenuItem.getAction(), false));
+ }
+ if (navigationMenuItem.getActionListener() != null) {
+ uiNavigationMenuItem.setActionListener(HtmlNavigationMenuRendererUtils.getMethodBinding(facesContext,
+ navigationMenuItem.getActionListener(), true));
+ }
+ uiNavigationMenuItem.setIcon(navigationMenuItem.getIcon());
+ uiNavigationMenuItem.setRendered(navigationMenuItem.isRendered());
+ uiNavigationMenuItem.setSplit(navigationMenuItem.isSplit());
+ uiNavigationMenuItem.setItemLabel(navigationMenuItem.getLabel());
+ uiNavigationMenuItem.setOpen(navigationMenuItem.isOpen());
+ uiNavigationMenuItem.setActive(navigationMenuItem.isActive());
+ uiNavigationMenuItem.setValue(navigationMenuItem.getValue());
+ HtmlNavigationMenuRendererUtils.setAttributeValue(facesContext, uiNavigationMenuItem,
+ "externalLink", navigationMenuItem.getExternalLink());
+ //uiNavigationMenuItem.setExternalLink(navigationMenuItem.getExternalLink());
+ uiNavigationMenuItem.setTransient(false);
+ uiNavigationMenuItem.setTarget(navigationMenuItem.getTarget());
+ uiNavigationMenuItem.setDisabled(navigationMenuItem.isDisabled());
+ uiNavigationMenuItem.setDisabledStyle(navigationMenuItem.getDisabledStyle());
+ uiNavigationMenuItem.setDisabledStyleClass(navigationMenuItem.getDisabledStyleClass());
+
+ if (navigationMenuItem.getNavigationMenuItems() != null && navigationMenuItem.getNavigationMenuItems().length > 0)
{
- addUINavigationMenuItems(facesContext, newItem, newItem.getChildren(), 0,
- Arrays.asList(uiNavMenuItem.getNavigationMenuItems()));
+ addUINavigationMenuItems(facesContext, uiNavigationMenuItem, uiNavigationMenuItem.getChildren(), 0,
+ Arrays.asList(navigationMenuItem.getNavigationMenuItems()));
}
}
}
- private HtmlPanelNavigationMenu getParentPanelNavigation(UIComponent uiComponent)
- {
- if(uiComponent instanceof HtmlPanelNavigationMenu)
- {
+ private HtmlPanelNavigationMenu getParentPanelNavigation(UIComponent uiComponent) {
+ if (uiComponent instanceof HtmlPanelNavigationMenu) {
return (HtmlPanelNavigationMenu) uiComponent;
}
UIComponent parent = uiComponent.getParent();
- // search HtmlPanelNavigation
- UIComponent p = parent;
- while (p != null && !(p instanceof HtmlPanelNavigationMenu))
- {
- p = p.getParent();
- }
- // p is now the HtmlPanelNavigation
- if (p == null)
- {
- log.error("HtmlCommandNavigation without parent HtmlPanelNavigation ?!");
- return null;
- }
+ // search HtmlPanelNavigation
+ UIComponent p = parent;
+ while (p != null && !(p instanceof HtmlPanelNavigationMenu)) {
+ p = p.getParent();
+ }
+ // p is now the HtmlPanelNavigation
+ if (p == null) {
+ log.error("HtmlCommandNavigation without parent HtmlPanelNavigation ?!");
+ return null;
+ }
return (HtmlPanelNavigationMenu) p;
}
private void createHtmlCommandNavigationItem(FacesContext facesContext, UIComponent parent, int i,
- UINavigationMenuItem uiNavMenuItem, UniqueId uniqueId)
- {
+ UINavigationMenuItem uiNavMenuItem, UniqueId uniqueId) {
HtmlPanelNavigationMenu menu = getParentPanelNavigation(parent);
// Create HtmlCommandNavigationItem
HtmlCommandNavigationItem newItem = (HtmlCommandNavigationItem)
@@ -386,8 +336,7 @@
newItem.setAction(uiNavMenuItem.getAction());
newItem.setActionListener(uiNavMenuItem.getActionListener());
ActionListener[] listeners = uiNavMenuItem.getActionListeners();
- for (int j = 0; j < listeners.length; j++)
- {
+ for (int j = 0; j < listeners.length; j++) {
newItem.addActionListener(listeners[j]);
}
// value
@@ -400,120 +349,103 @@
newItem.setTransient(uiNavMenuItem.isTransient());
if (!copyValueBinding(uiNavMenuItem, newItem, "rendered"))
newItem.setRendered(uiNavMenuItem.isRendered());
+ if (!copyValueBinding(uiNavMenuItem, newItem, "externalLink"))
+ newItem.setExternalLink(uiNavMenuItem.getExternalLink());
if (uiNavMenuItem.isOpen() && ! menu.isExpandAll())
newItem.toggleOpen();
- if(uiNavMenuItem.getActiveDirectly()!=null)
- {
+ if (uiNavMenuItem.getActiveDirectly() != null) {
newItem.setActive(uiNavMenuItem.isActive());
}
- else
- {
- newItem.setValueBinding("active",uiNavMenuItem.getValueBinding("active"));
+ else {
+ newItem.setValueBinding("active", uiNavMenuItem.getValueBinding("active"));
}
if (!copyValueBinding(uiNavMenuItem, newItem, "target"))
- newItem.setTarget(uiNavMenuItem.getTarget());
+ newItem.setTarget(uiNavMenuItem.getTarget());
if (!copyValueBinding(uiNavMenuItem, newItem, "disabled"))
- newItem.setDisabled(uiNavMenuItem.isDisabled());
+ newItem.setDisabled(uiNavMenuItem.isDisabled());
if (!copyValueBinding(uiNavMenuItem, newItem, "disabledStyle"))
- newItem.setDisabledStyle(uiNavMenuItem.getDisabledStyle());
+ newItem.setDisabledStyle(uiNavMenuItem.getDisabledStyle());
if (!copyValueBinding(uiNavMenuItem, newItem, "disabledStyleClass"))
- newItem.setDisabledStyleClass(uiNavMenuItem.getDisabledStyleClass());
+ newItem.setDisabledStyleClass(uiNavMenuItem.getDisabledStyleClass());
- if(uiNavMenuItem.getActiveOnViewIdsDirectly() != null)
- {
+ if (uiNavMenuItem.getActiveOnViewIdsDirectly() != null) {
newItem.setActiveOnViewIds(uiNavMenuItem.getActiveOnViewIdsDirectly());
}
// If the parent-Element is disabled the child is disabled as well
- if(parent instanceof HtmlPanelNavigationMenu){
- if(newItem.getDisabledStyle()==null)
- {
+ if (parent instanceof HtmlPanelNavigationMenu) {
+ if (newItem.getDisabledStyle() == null) {
newItem.setDisabledStyle(
- ((HtmlPanelNavigationMenu)parent).getDisabledStyle()
+ ((HtmlPanelNavigationMenu) parent).getDisabledStyle()
);
}
- if(newItem.getDisabledStyleClass()==null)
- {
+ if (newItem.getDisabledStyleClass() == null) {
newItem.setDisabledStyleClass(
- ((HtmlPanelNavigationMenu)parent).getDisabledStyleClass()
+ ((HtmlPanelNavigationMenu) parent).getDisabledStyleClass()
);
}
- if(((HtmlPanelNavigationMenu)parent).isDisabled())
- {
+ if (((HtmlPanelNavigationMenu) parent).isDisabled()) {
newItem.setDisabled(true);
}
}
- if(parent instanceof HtmlCommandNavigationItem){
- if(newItem.getDisabledStyle()==null)
- {
+ if (parent instanceof HtmlCommandNavigationItem) {
+ if (newItem.getDisabledStyle() == null) {
newItem.setDisabledStyle(
- ((HtmlCommandNavigationItem)parent).getDisabledStyle()
+ ((HtmlCommandNavigationItem) parent).getDisabledStyle()
);
}
- if(newItem.getDisabledStyleClass()==null)
- {
+ if (newItem.getDisabledStyleClass() == null) {
newItem.setDisabledStyleClass(
- ((HtmlCommandNavigationItem)parent).getDisabledStyleClass()
+ ((HtmlCommandNavigationItem) parent).getDisabledStyleClass()
);
}
- if(((HtmlCommandNavigationItem)parent).isDisabled())
- {
+ if (((HtmlCommandNavigationItem) parent).isDisabled()) {
newItem.setDisabled(true);
}
}
- if (uiNavMenuItem.getIcon()!=null)
- {
+ if (uiNavMenuItem.getIcon() != null) {
UIGraphic uiGraphic = (UIGraphic) facesContext.getApplication().createComponent(UIGraphic.COMPONENT_TYPE);
uiGraphic.setId(parentId + "_img" + id);
uiGraphic.getClientId(facesContext);
newItem.getChildren().add(uiGraphic);
uiGraphic.setParent(newItem);
- if (HtmlNavigationMenuRendererUtils.isValueReference(uiNavMenuItem.getIcon()))
- {
- uiGraphic.setValueBinding("value",
- facesContext.getApplication().createValueBinding(uiNavMenuItem.getIcon()));
- }
- else
- {
- uiGraphic.setValue(uiNavMenuItem.getIcon());
- }
+ if (HtmlNavigationMenuRendererUtils.isValueReference(uiNavMenuItem.getIcon())) {
+ uiGraphic.setValueBinding("value",
+ facesContext.getApplication().createValueBinding(uiNavMenuItem.getIcon()));
+ }
+ else {
+ uiGraphic.setValue(uiNavMenuItem.getIcon());
+ }
}
-
- else
- {
+
+ else {
// Create and add UIOutput
UIOutput uiOutput = (UIOutput) facesContext.getApplication().createComponent(UIOutput.COMPONENT_TYPE);
uiOutput.setId(parentId + "_txt" + id);
uiOutput.getClientId(facesContext); // create clientid
newItem.getChildren().add(uiOutput);
uiOutput.setParent(newItem);
- if (uiNavMenuItem.getItemLabel() != null)
- {
- if (HtmlNavigationMenuRendererUtils.isValueReference(uiNavMenuItem.getItemLabel()))
- {
+ if (uiNavMenuItem.getItemLabel() != null) {
+ if (HtmlNavigationMenuRendererUtils.isValueReference(uiNavMenuItem.getItemLabel())) {
uiOutput.setValueBinding("value",
facesContext.getApplication().createValueBinding(uiNavMenuItem.getItemLabel()));
}
- else
- {
+ else {
uiOutput.setValue(uiNavMenuItem.getItemLabel());
}
}
- else
- {
+ else {
Object value = uiNavMenuItem.getValue();
if (value != null &&
- HtmlNavigationMenuRendererUtils.isValueReference(value.toString()))
- {
+ HtmlNavigationMenuRendererUtils.isValueReference(value.toString())) {
uiOutput.setValueBinding("value",
facesContext.getApplication().createValueBinding(value.toString()));
}
- else
- {
+ else {
uiOutput.setValue(uiNavMenuItem.getValue());
}
}
@@ -523,8 +455,7 @@
preprocessNavigationItems(facesContext, newItem, uiNavMenuItem.getChildren(), uniqueId);
}
- private boolean copyValueBinding(UIComponent source, UIComponent target, String binding)
- {
+ private boolean copyValueBinding(UIComponent source, UIComponent target, String binding) {
ValueBinding valueBinding = source.getValueBinding(binding);
if (valueBinding == null)
return false;
@@ -534,91 +465,73 @@
// protected
- protected String getStyle(FacesContext facesContext, UIComponent link)
- {
- if (!(link instanceof HtmlCommandNavigationItem))
- {
+ protected String getStyle(FacesContext facesContext, UIComponent link) {
+ if (!(link instanceof HtmlCommandNavigationItem)) {
throw new IllegalArgumentException("expected instance of " + HtmlCommandNavigationItem.class.getName());
}
UIComponent navPanel = HtmlNavigationMenuRendererUtils.getPanel(link);
- HtmlCommandNavigationItem navItem = (HtmlCommandNavigationItem)link;
- if (navItem.isActive())
- {
- return ((HtmlPanelNavigationMenu)navPanel).getActiveItemStyle();
+ HtmlCommandNavigationItem navItem = (HtmlCommandNavigationItem) link;
+ if (navItem.isActive()) {
+ return ((HtmlPanelNavigationMenu) navPanel).getActiveItemStyle();
}
- else if (navItem.isOpen())
- {
- return ((HtmlPanelNavigationMenu)navPanel).getOpenItemStyle();
+ else if (navItem.isOpen()) {
+ return ((HtmlPanelNavigationMenu) navPanel).getOpenItemStyle();
}
- else
- {
- return ((HtmlPanelNavigationMenu)navPanel).getItemStyle();
+ else {
+ return ((HtmlPanelNavigationMenu) navPanel).getItemStyle();
}
}
- protected String getStyleClass(FacesContext facesContext, UIComponent link)
- {
- if (!(link instanceof HtmlCommandNavigationItem))
- {
+ protected String getStyleClass(FacesContext facesContext, UIComponent link) {
+ if (!(link instanceof HtmlCommandNavigationItem)) {
throw new IllegalArgumentException();
}
UIComponent navPanel = HtmlNavigationMenuRendererUtils.getPanel(link);
- HtmlCommandNavigationItem navItem = (HtmlCommandNavigationItem)link;
- if (navItem.isActive())
- {
- return ((HtmlPanelNavigationMenu)navPanel).getActiveItemClass();
+ HtmlCommandNavigationItem navItem = (HtmlCommandNavigationItem) link;
+ if (navItem.isActive()) {
+ return ((HtmlPanelNavigationMenu) navPanel).getActiveItemClass();
}
- else if (navItem.isOpen())
- {
- return ((HtmlPanelNavigationMenu)navPanel).getOpenItemClass();
+ else if (navItem.isOpen()) {
+ return ((HtmlPanelNavigationMenu) navPanel).getOpenItemClass();
}
- else
- {
- return ((HtmlPanelNavigationMenu)navPanel).getItemClass();
+ else {
+ return ((HtmlPanelNavigationMenu) navPanel).getItemClass();
}
}
- private static class UniqueId
- {
+ private static class UniqueId {
private int _id;
- public int next()
- {
+ public int next() {
return _id++;
}
- public void decrease()
- {
+ public void decrease() {
_id--;
}
}
- private void expandAll(UIComponent parent)
- {
+ private void expandAll(UIComponent parent) {
//Recurse over all Children setOpen if child is HtmlCommandNavigationItem
- if(parent instanceof HtmlCommandNavigationItem)
- {
+ if (parent instanceof HtmlCommandNavigationItem) {
HtmlCommandNavigationItem navItem = (HtmlCommandNavigationItem) parent;
navItem.setOpen(true);
}
List children = parent.getChildren();
UIComponent child;
- for (int i = 0; i < children.size(); i++)
- {
- child = (UIComponent) children.get(i);
+ for (int i = 0; i < children.size(); i++) {
+ child = (UIComponent) children.get(i);
expandAll(child);
}
}
- private void activeOnViewId( UIComponent parent, String viewId)
- {
+ private void activeOnViewId(UIComponent parent, String viewId) {
//Recurse over all Children setOpen if child is HtmlCommandNavigationItem
- if(parent instanceof HtmlCommandNavigationItem)
- {
+ if (parent instanceof HtmlCommandNavigationItem) {
HtmlCommandNavigationItem navItem = (HtmlCommandNavigationItem) parent;
String[] viewIds = navItem.getActiveOnVieIds();
for (int i = 0; i < viewIds.length; i++) {
@@ -627,13 +540,13 @@
navItem.setActive(true);
return;
}
- };
+ }
+ ;
}
List children = parent.getChildren();
UIComponent child;
- for (int i = 0; i < children.size(); i++)
- {
- child = (UIComponent) children.get(i);
+ for (int i = 0; i < children.size(); i++) {
+ child = (UIComponent) children.get(i);
activeOnViewId(child, viewId);
}
}