jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@apache.org
Subject svn commit: r332939 - /jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/SelectOne.java
Date Sun, 13 Nov 2005 07:38:05 GMT
Author: rahul
Date: Sat Nov 12 23:38:04 2005
New Revision: 332939

URL: http://svn.apache.org/viewcvs?rev=332939&view=rev
Log:
Enhance rdc:select1 functionality when the option elements are constructed programmatically.

Nudge from Shane Smith:

http://marc.theaimsgroup.com/?l=taglibs-dev&m=112380398730865&w=2

Modified:
    jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/SelectOne.java

Modified: jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/SelectOne.java
URL: http://svn.apache.org/viewcvs/jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/SelectOne.java?rev=332939&r1=332938&r2=332939&view=diff
==============================================================================
--- jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/SelectOne.java (original)
+++ jakarta/taglibs/proper/rdc/trunk/src/org/apache/taglibs/rdc/SelectOne.java Sat Nov 12
23:38:04 2005
@@ -128,6 +128,8 @@
         
         private List values;
         private List utterances;
+        private List dtmfs;
+        private List accepts;
         
         /**
          * Constructor
@@ -136,16 +138,90 @@
         public Options() {
             values = new ArrayList();
             utterances = new ArrayList();
+            dtmfs = new ArrayList();
+            accepts = new ArrayList();
         }
 
         /**
          * Add this option to the list. Option contains an utterance
-         * and an optional value.
+         * and an optional value, dtmf and accept.
          *
-         */        
+         * @param option_utterance The utterance for this option
+         */
+        public void add(String option_utterance) {
+            add(null, option_utterance, null, false); 
+        }
+
+        /**
+         * Add this option to the list. Option contains an utterance
+         * and an optional value, dtmf and accept.
+         *
+         * @param option_utterance The utterance for this option
+         * @param option_approximate Whether an exact or approximate match is
+         *                           sought
+         */
+        public void add(String option_utterance, boolean option_approximate) {
+            add(null, option_utterance, null, option_approximate);
+        }
+
+        /**
+         * Add this option to the list. Option contains an utterance
+         * and an optional value, dtmf and accept.
+         *
+         * @param option_value The value for this option
+         * @param option_utterance The utterance for this option
+         */
         public void add(String option_value, String option_utterance) {
+            add(option_value, option_utterance, null, false);
+        }
+
+        /**
+         * Add this option to the list. Option contains an utterance
+         * and an optional value, dtmf and accept.
+         *
+         * @param option_value The value for this option
+         * @param option_utterance The utterance for this option
+         * @param option_approximate Whether an exact or approximate match is
+         *                           sought
+         */
+        public void add(String option_value, String option_utterance, 
+                boolean option_approximate) {
+            add(option_value, option_utterance, null, option_approximate);
+        }
+
+        /**
+         * Add this option to the list. Option contains an utterance
+         * and an optional value, dtmf and accept.
+         *
+         * @param option_value The value for this option
+         * @param option_utterance The utterance for this option
+         * @param option_dtmf The DTMF value for this option
+         */
+        public void add(String option_value, String option_utterance,
+                String option_dtmf) {
+            add(option_value, option_utterance, option_dtmf, false);
+        }
+
+        /**
+         * Add this option to the list. Option contains an utterance
+         * and an optional value, dtmf and accept.
+         *
+         * @param option_value The value for this option
+         * @param option_utterance The utterance for this option
+         * @param option_dtmf The DTMF value for this option
+         * @param option_approximate Whether an exact or approximate match is
+         *                           sought
+         */
+        public void add(String option_value, String option_utterance, 
+                String option_dtmf, boolean option_approximate) {
             values.add(option_value);
             utterances.add(option_utterance);
+            dtmfs.add(option_dtmf);
+            if (option_approximate == true) {
+                accepts.add("approximate");
+            } else {
+                accepts.add("exact");
+            }
         }
 
         /**
@@ -154,20 +230,27 @@
          * @return String the VXML markup
          */        
         public String getVXMLOptionsMarkup() {
-            String options = "";
+            StringBuffer buf = new StringBuffer();
             for (int i=0; i < utterances.size(); i++) {
                 String val = (String) values.get(i);
                 String utt = (String) utterances.get(i);
-                if (utt != null && utt.trim().length() > 0) {
-                    if (val == null || val.trim().length() == 0) {
-                        options += "<option>" + utt + "</option>";
-                    } else {
-                        options += "<option value=\"" + val.trim() + "\">" + 
-                            utt + "</option>";
+                String dtm = (String) dtmfs.get(i);
+                String acc = (String) accepts.get(i);
+                if (!RDCUtils.isStringEmpty(utt)) {
+                    buf.append("<option");
+                    if (!RDCUtils.isStringEmpty(val)){
+                        buf.append(" value=\"").append(val.trim()).append("\"");
+                    }
+                    if (!RDCUtils.isStringEmpty(dtm)) {
+                        buf.append(" dtmf=\"").append(dtm.trim()).append("\"");
+                    }
+                    if (!RDCUtils.isStringEmpty(acc)) {
+                        buf.append(" accept=\"").append(acc.trim()).append("\"");
                     }
+                    buf.append(">").append(utt.trim()).append("</option>");
                 }
             }
-            return options;
+            return buf.toString();
         }
 
     } // end class Options{}



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org


Mime
View raw message