CALL FOR: Hack, Last Of Array function in mm:import

Description:
In light of bug #5296, which when I fixed it caused some unfortunate
side effects. Like creating arrays instead of single value parameters.
I made this fix, which enhances the mm:import tag with a lastofarray
attribute, which let you only import the last value of an array. 
This will ease the transition of current Orion Jsp sites to a new
version of MMBase. It also makes it possible to override parameters
when using the mm:include tag, enhancing the usefullnes of that tag.
I would like to incorporate this enhancement in CVS.

Modified files:
===============
org.mmbase.bridge.taglib.jsp.ImportTag
org.mmbase.bridge.taglib.jsp.mmbase-taglib.xml

Attached, the diffs to the current version.

START OF CALL: 2003-02-10

END OF CALL:   2003-02-13

[_] +1 (YEA)

[_] +0 (ABSTAIN )

[_] -1 (NAY), because :

[_] VETO, because:

-- 
Rico Jansen ([EMAIL PROTECTED])
"You call it untidy, I call it LRU ordered" -- Daniel Barlow
RCS file: /usr/local/cvs/mmbase/bridge/jsp/taglib/mmbase-taglib.xml,v
retrieving revision 1.149.2.4
diff -c -r1.149.2.4 mmbase-taglib.xml
*** mmbase-taglib.xml   18 Dec 2002 19:41:17 -0000      1.149.2.4
--- mmbase-taglib.xml   10 Feb 2003 13:41:20 -0000
***************
*** 2477,2482 ****
--- 2477,2495 ----
        <see tag="context" />
      </attribute>
      <attribute>
+       <name>lastofarray</name>
+       <!-- Should this be a contextwriter attribute? -->
+       <required>false</required>
+       <info>
+         <p>
+           On default, this tag will only use the last value of an externid
+           when it is an Array. When setting this to false the whole array
+           will be used.
+         </p>
+       </info>
+       <see tag="context" />
+     </attribute>
+     <attribute>
        <name>from</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>

RCS file: /usr/local/cvs/mmbase/bridge/jsp/taglib/ImportTag.java,v
retrieving revision 1.22
diff -c -r1.22 ImportTag.java
*** ImportTag.java      24 Sep 2002 19:34:35 -0000      1.22
--- ImportTag.java      10 Feb 2003 13:39:56 -0000
***************
*** 11,16 ****
--- 11,17 ----
  
  import javax.servlet.jsp.tagext.BodyContent;
  import javax.servlet.jsp.JspTagException;
+ import java.util.List;
  
  
  import org.mmbase.bridge.jsp.taglib.util.StringSplitter;
***************
*** 36,41 ****
--- 37,43 ----
      protected int     from         = ContextTag.LOCATION_NOTSET;
  
      protected String  externid      = null;
+     protected boolean lastofarray   = true;
  
      private   boolean found = false;
      private   boolean reset = false;
***************
*** 61,66 ****
--- 63,76 ----
      }
  
      /**
+      * The variable that changes the behaviour of only using the last of an Array
+      */
+ 
+     public void setLastofarray(boolean b) throws JspTagException {
+         lastofarray = b;
+     }
+ 
+     /**
       * If 'required' then the variable must be available in the
       * external source, otherwise exception.
       *
***************
*** 115,120 ****
--- 125,134 ----
              }
              if (found) {
                  value = getObject(useId);
+                 if (lastofarray && value instanceof List) {
+                     // get last element;
+                     value=((List)value).get(((List)value).size()-1);
+                 }
                  if (log.isDebugEnabled()) {
                      log.debug("found value for " + useId + " " + value);
                  }

Reply via email to