myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject svn commit: r582379 - in /myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago: taglib/extension/LabelExtensionTag.java util/LayoutUtil.java
Date Fri, 05 Oct 2007 20:00:54 GMT
Author: weber
Date: Fri Oct  5 13:00:53 2007
New Revision: 582379

URL: http://svn.apache.org/viewvc?rev=582379&view=rev
Log:
<tx:selectBooleanCheckbox> with attribute "labelWidth" doesn't work
<http://issues.apache.org/jira/browse/TOBAGO-505>

Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/extension/LabelExtensionTag.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutUtil.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/extension/LabelExtensionTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/extension/LabelExtensionTag.java?rev=582379&r1=582378&r2=582379&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/extension/LabelExtensionTag.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/extension/LabelExtensionTag.java
Fri Oct  5 13:00:53 2007
@@ -17,6 +17,9 @@
  * limitations under the License.
  */
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import static org.apache.myfaces.tobago.TobagoConstants.FACET_LAYOUT;
 import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
 import org.apache.myfaces.tobago.apt.annotation.Tag;
@@ -25,6 +28,7 @@
 import org.apache.myfaces.tobago.taglib.component.PanelTag;
 import org.apache.myfaces.tobago.taglib.decl.HasTip;
 import org.apache.myfaces.tobago.taglib.decl.HasValue;
+import org.apache.myfaces.tobago.util.LayoutUtil;
 
 import javax.faces.webapp.FacetTag;
 import javax.servlet.jsp.JspException;
@@ -35,10 +39,14 @@
 public class LabelExtensionTag extends BodyTagSupport
     implements HasValue, HasTip {
 
+  private final Log LOG = LogFactory.getLog(LabelExtensionTag.class);
+  
+  public static final String DEFAULT_COLUMNS = "fixed;*";
+
   private String value;
   private String tip;
   private String rendered;
-  private String columns = "fixed;*";
+  private String columns = DEFAULT_COLUMNS;
   private String rows = "fixed";
 
   private PanelTag panelTag;
@@ -46,6 +54,8 @@
   @Override
   public int doStartTag() throws JspException {
 
+    checkValidColums();
+
     panelTag = new PanelTag();
     panelTag.setPageContext(pageContext);
     panelTag.setParent(getParent());
@@ -84,6 +94,13 @@
     labelTag.doEndTag();
 
     return super.doStartTag();
+  }
+
+  private void checkValidColums() {
+    if (!LayoutUtil.checkTokens(columns)) {
+      LOG.warn("Illegal value for columns = \"" + columns + "\" replacing with default: \""
+ DEFAULT_COLUMNS + "\"");
+      columns = DEFAULT_COLUMNS;
+    }
   }
 
   @Override

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutUtil.java?rev=582379&r1=582378&r2=582379&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutUtil.java
(original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/LayoutUtil.java
Fri Oct  5 13:00:53 2007
@@ -40,11 +40,16 @@
 import java.awt.Dimension;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.StringTokenizer;
+import java.util.regex.Pattern;
 
 public final class LayoutUtil {
 
   private static final Log LOG = LogFactory.getLog(LayoutUtil.class);
 
+  private static final Pattern TOKEN_PATTERN
+      = Pattern.compile("^(\\d*px|\\d*\\*|\\d*%|fixed)$");
+
   private LayoutUtil() {
     // to prevent instantiation
   }
@@ -263,5 +268,15 @@
     return dimension;
   }
 
+  public static boolean checkTokens(String columns) {
+    StringTokenizer st = new StringTokenizer(columns, ";");
+    while (st.hasMoreTokens()) {
+      String token = st.nextToken();
+      if (!TOKEN_PATTERN.matcher(token).matches()) {
+        return false;
+      }
+    }
+    return true;
+  }
 }
 



Mime
View raw message