[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util ...

Christian Bauer christian at hibernate.org
Fri Aug 17 09:00:31 EDT 2007


  User: cbauer  
  Date: 07/08/17 09:00:31

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/util  
                        WikiUtil.java Diff.java
  Log:
  Major refactoring of core data schema and some new features
  
  Revision  Changes    Path
  1.11      +38 -26    jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WikiUtil.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- WikiUtil.java	6 Jul 2007 14:38:40 -0000	1.10
  +++ WikiUtil.java	17 Aug 2007 13:00:31 -0000	1.11
  @@ -1,23 +1,27 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.util;
   
  -import org.jboss.seam.annotations.Name;
  -import org.jboss.seam.wiki.core.model.*;
  -import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
   import org.jboss.seam.Component;
  +import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
  +import org.jboss.seam.wiki.core.model.*;
   
  -import javax.faces.component.UIData;
   import javax.faces.context.FacesContext;
  +import javax.imageio.ImageIO;
   import javax.servlet.http.HttpSession;
   import javax.swing.*;
  -import javax.imageio.ImageIO;
  -import java.util.Collection;
  -import java.util.List;
  -import java.util.Collections;
  -import java.math.BigDecimal;
  -import java.awt.image.BufferedImage;
   import java.awt.*;
  +import java.awt.image.BufferedImage;
   import java.io.ByteArrayOutputStream;
   import java.io.IOException;
  +import java.math.BigDecimal;
  +import java.util.Collection;
  +import java.util.Collections;
  +import java.util.List;
   
   /**
    * Adds stuff to and for JSF that should be there but isn't. Also stuff that is exposed
  @@ -26,7 +30,6 @@
    *
    * @author Christian Bauer
    */
  - at Name("wikiUtil")
   public class WikiUtil {
   
       // Creates clean alphanumeric UpperCaseCamelCase
  @@ -89,7 +92,7 @@
       }
   
       public static String renderPermLink(Node node) {
  -        if (node == null) return "";
  +        if (node == null || node.getId() == null) return "";
           if (isFile(node)) return renderFileLink((File)node);
           WikiPreferences wikiPrefs = (WikiPreferences) Component.getInstance("wikiPreferences");
           String contextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
  @@ -97,7 +100,7 @@
       }
   
       public  static String renderWikiLink(Node node) {
  -        if (node == null) return "";
  +        if (node == null || node.getId() == null) return "";
           String contextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
           if (node.getArea().getWikiname().equals(node.getWikiname()))
               return contextPath + "/" + node.getArea().getWikiname();
  @@ -105,7 +108,7 @@
       }
   
       private static String renderFileLink(File file) {
  -        if (file == null) return "";
  +        if (file == null || file.getId() == null) return "";
           String contextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
           return contextPath + "/servlets/files/download.seam?fileId=" + file.getId();
       }
  @@ -131,6 +134,13 @@
           }
       }
   
  +    public static String escapeEmailAddress(String string) {
  +        WikiPreferences wikiPrefs = (WikiPreferences) Component.getInstance("wikiPreferences");
  +        return string.length() >= 7 && string.substring(0, 7).equals("mailto:")
  +                ? string.replaceAll("@", wikiPrefs.getAtSymbolReplacement()) 
  +                : string;
  +    }
  +
       public static String escapeHtml(String string) {
           if (string == null) return null;
           StringBuffer sb = new StringBuffer();
  @@ -180,7 +190,6 @@
           } catch (IOException ex) {
               throw new RuntimeException(ex);
           }
  -
       }
   
       public static Throwable unwrap(Throwable throwable) throws IllegalArgumentException {
  @@ -215,15 +224,6 @@
       }
   
       /**
  -     * Need to bind UI components to non-conversational backing beans.
  -     * That this is even needed makes no sense. Why can't I call the UI components
  -     * in the EL directly? Don't try #{components['id']}, it won't work.
  -     */
  -    private UIData datatable;
  -    public UIData getDatatable() { return datatable; }
  -    public void setDatatable(UIData datatable) { this.datatable = datatable; }
  -
  -    /**
        * Can't use col.size() in a value binding. Why can't I call arbitrary methods, even
        * with arguments, in a value binding? Java needs properties badly.
        */
  @@ -231,7 +231,19 @@
           return col == null ? 0 : col.size();
       }
   
  -    public static int lenth(String string) {
  -        return string.length();
  +    /**
  +     * EL doesn't support a String lenth() operator.
  +     */
  +    public static int length(String string) {
  +        return string == null ? 0 : string.length();
       }
  +
  +    /**
  +     * Used for conditional rendering of JSF messages, again, inflexible EL can't take value bindings with arguments
  +     * or support simple String concat...
  +     */
  +    public static boolean hasMessage(String namingContainer, String componentId) {
  +        return FacesContext.getCurrentInstance().getMessages(namingContainer + ":" + componentId).hasNext();
  +    }
  +
   }
  
  
  
  1.4       +6 -0      jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util/Diff.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Diff.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util/Diff.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- Diff.java	20 Apr 2007 09:10:12 -0000	1.3
  +++ Diff.java	17 Aug 2007 13:00:31 -0000	1.4
  @@ -1,3 +1,9 @@
  +/*
  + * JBoss, Home of Professional Open Source
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
  + */
   package org.jboss.seam.wiki.util;
   
   import java.util.Arrays;
  
  
  



More information about the jboss-cvs-commits mailing list