click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From med...@apache.org
Subject svn commit: r777090 - /incubator/click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java
Date Thu, 21 May 2009 12:05:22 GMT
Author: medgar
Date: Thu May 21 12:05:22 2009
New Revision: 777090

URL: http://svn.apache.org/viewvc?rev=777090&view=rev
Log:
CLK-551 rollback

Modified:
    incubator/click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java

Modified: incubator/click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java?rev=777090&r1=777089&r2=777090&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java (original)
+++ incubator/click/trunk/click/extras/src/org/apache/click/extras/control/Menu.java Thu May
21 12:05:22 2009
@@ -20,7 +20,6 @@
 
 import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -34,7 +33,6 @@
 import org.apache.click.service.ConfigService;
 import org.apache.click.util.ClickUtils;
 import org.apache.click.util.HtmlStringBuffer;
-
 import org.apache.commons.lang.StringUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -155,7 +153,14 @@
  *       <menu label="Home" path="admin/admin.htm" roles="admin"/>
  *    </menu>
  * &lt;/menu&gt; </pre>
- * 
+ *
+ * The underlying implementation of isUserInRoles() method is provided by an
+ * {@link AccessController} interface. The default AccessController is provided
+ * by the {@link RoleAccessController} which uses the JEE container is user in
+ * role facility. By providing your own AccessController you can have menu
+ * access control using other security frameworks such as JSecurity or Spring
+ * ACEGI.
+ *
  * <h3>Menu Configuration DTD</h3>
  *
  * The Menu config file DTD is provided below:
@@ -173,6 +178,8 @@
  *     &lt;!ATTLIST <span class="red">menu</span> <span class="st">roles</span>
CDATA #IMPLIED&gt;
  *     &lt;!ATTLIST <span class="red">menu</span> <span class="st">pages</span>
CDATA #IMPLIED&gt; </pre>
  *
+ * @see org.apache.click.extras.security.AccessController
+ *
  * @author Malcolm Edgar
  */
 public class Menu extends AbstractControl {
@@ -551,7 +558,7 @@
             }
         }
 
-        for (int i = 0; i < getChildren().size(); i++) {
+        for (int i = 0, size = getChildren().size(); i < size; i++) {
             Menu menu = (Menu) getChildren().get(i);
             if (menu.isSelected()) {
                 selected = true;
@@ -592,8 +599,8 @@
     public boolean isUserInRoles() {
         HttpServletRequest request = getContext().getRequest();
 
-        for (Iterator i = getRoles().iterator(); i.hasNext();) {
-            String rolename = (String) i.next();
+        for (int i = 0, size = getRoles().size(); i < size; i++) {
+            String rolename = (String) getRoles().get(i);
             if (getAccessController().hasAccess(request, rolename)) {
                 return true;
             }
@@ -612,8 +619,8 @@
      * @return true if the user is in one of the child menu roles, or false otherwise
      */
     public boolean isUserInChildMenuRoles() {
-        for (Iterator i = getChildren().iterator(); i.hasNext();) {
-            Menu child = (Menu) i.next();
+         for (int i = 0, size = getChildren().size(); i < size; i++) {
+            Menu child = (Menu) getChildren().get(i);
             if (child.isUserInRoles()) {
                 return true;
             }
@@ -748,7 +755,7 @@
     }
 
     /**
-     * Render the HTML representation of the Menu.
+     * Render an anchor tag HTML representation of the Menu.
      *
      * @see #toString()
      *
@@ -779,10 +786,6 @@
                 buffer.appendAttributeEscaped("title", getTitle());
             }
 
-            if (isSelected()) {
-                buffer.appendAttribute("class", "selected");
-            }
-
             buffer.closeTag();
 
             if (StringUtils.isNotBlank(getImageSrc())) {
@@ -844,8 +847,8 @@
      */
     public Menu getSelectedChild() {
         if (isSelected()) {
-            for (Iterator i = getChildren().iterator(); i.hasNext();) {
-                Menu menu = (Menu) i.next();
+            for (int i = 0, size = getChildren().size(); i < size; i++) {
+                Menu menu = (Menu) getChildren().get(i);
                 if (menu.isSelected()) {
                     return menu;
                 }



Mime
View raw message