morciuch    2002/09/20 12:31:44

  Modified:    src/java/org/apache/jetspeed/modules/parameters
                        CheckBoxGroup.java
  Log:
  Added prefix option to prevent clashing of check box names with other parameters 
with the same name
  
  Revision  Changes    Path
  1.2       +14 -6     
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/parameters/CheckBoxGroup.java
  
  Index: CheckBoxGroup.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/parameters/CheckBoxGroup.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CheckBoxGroup.java        20 Aug 2002 17:37:17 -0000      1.1
  +++ CheckBoxGroup.java        20 Sep 2002 19:31:44 -0000      1.2
  @@ -73,8 +73,9 @@
   /**
    *  Returns a group of check boxes using the following options:
    *  <UL>
  - *  <LI><code>items</code>: list of comma-delimited check box names</LI>
  + *  <LI><code>items</code>: list of comma-delimited check box names/values</LI>
    *  <LI><code>layout</code> [$northsouth|<strong>$eastwest</strong>]: presentation 
layout</LI>
  + *  <LI><code>prefix</code>: prefix to use for check box names, default="cb"</LI> 
    * </UL>
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Mark Orciuch</a>
  @@ -87,6 +88,8 @@
       public static final String LAYOUT = "layout";
       public static final String LAYOUT_EW = "$eastwest";
       public static final String LAYOUT_NS = "$northsouth";
  +    public static final String PREFIX = "prefix";
  +    public static final String PREFIX_DEFAULT = "cb";
   
       /**
        * Returns presentation control
  @@ -97,6 +100,11 @@
           ElementContainer result = new ElementContainer();
           String items = (String)parms.get(this.ITEMS);
           String layout = (String)parms.get(this.LAYOUT);
  +        String prefix = (String)parms.get(this.PREFIX);
  +        if (prefix == null)
  +        {
  +            prefix = PREFIX_DEFAULT;
  +        }
   
           StringTokenizer st = new StringTokenizer(items, ",");
           Vector v = new Vector();
  @@ -114,9 +122,9 @@
           for ( Enumeration e = v.elements(); e.hasMoreElements(); )
           {
               String item = ((String)e.nextElement()).trim();
  -            Input cb = new Input(Input.CHECKBOX, item, item);
  +            Input cb = new Input(Input.CHECKBOX, prefix + item, item);
               cb.setChecked(value.indexOf(item) >= 0);
  -            cb.setOnClick(getJavascript(name, v));
  +            cb.setOnClick(getJavascript(name, v, prefix));
               ElementContainer temp = new ElementContainer();
               temp.addElement(cb).addElement("&nbsp;").addElement(item);
               if ( layout.equalsIgnoreCase(this.LAYOUT_NS) )
  @@ -145,7 +153,7 @@
        * @param v
        * @return string
        */
  -    private String getJavascript(String name, Vector v)
  +    private String getJavascript(String name, Vector v, String prefix)
       {
   
           StringBuffer result = new StringBuffer();
  @@ -153,7 +161,7 @@
   
           for ( Enumeration e = v.elements(); e.hasMoreElements(); )
           {
  -            String item = (String)e.nextElement();
  +            String item = prefix + (String)e.nextElement();
               result.append("((");
               result.append(item);
               result.append(".checked) ? ");
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to