Shane Smith <[EMAIL PROTECTED]> wrote on 08/11/2005 07:46:21 PM:
> Hey Folks,
>
> In using the Select1 RDC, I've found that I won't always use a
> configuration file to set my options, but will also set them
> dynamically using the available method to add. The problem is, when I
> use dynamic data, the method to add only allows me to specify the
> utterance and the value. I intend to also set the dtmf and accept
> attributes of the option tag. I reworked the class a bit, adding
> overloaded methods to allow for a range of options with option. Here
> it is, please point out any glaring reasons not to do this....
<snip/>
We don't have this already ;-? Please file a bugzilla ticket and attach a
patch.
I have some minor nits (thanks for your suggestion and your code, this is
not a criticism):
1) Use real spaces (4) instead of tabs (the recent boatload of commits
from me was to correct that in the first place ;-)
2) Use braces around single line if/else blocks
3) We should use a StringBuffer (moresoever now that the rendering bit is
a little more involved)
4) Please make sure you compile against the latest RDC nightly (eg:
StringUtils.isNotEmpty should be replaced by !RDCUtils.isStringEmpty)
-Rahul
>
> Also attached as txt, in case my or your email reader hates tabs:
>
> public static class Options implements Serializable {
>
> private List values;
> private List utterances;
> private List dtmfs;
> private List accepts;
>
> /**
> * Constructor
> *
> */
> 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, dtmf, and accept.
> *
> */
> public void add(String option_utterance) {
> this.add("",option_utterance,"",false);
> }
>
> public void add(String option_utterance, boolean option_approximate)
{
> this.add("",option_utterance,"",option_approximate);
> }
>
> public void add(String option_value, String option_utterance) {
> this.add(option_value,option_utterance,"",false);
> }
>
> public void add(String option_value, String option_utterance, boolean
> option_approximate) {
> this.add(option_value,option_utterance,"",option_approximate);
> }
>
> public void add(String option_value, String option_utterance, String
> option_dtmf) {
> this.add(option_value,option_utterance,option_dtmf,false);
> }
>
> 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");
> }
>
> /**
> * Generate the markup of the vxml <option> elements as a
String
> *
> * @return String the VXML markup
> */
> public String getVXMLOptionsMarkup() {
> String options = "";
> for (int i=0; i < utterances.size(); i++) {
> String val = (String) values.get(i);
> String utt = (String) utterances.get(i);
> String dtm = (String) dtmfs.get(i);
> String acc = (String) accepts.get(i);
> if (StringUtils.isNotEmpty(utt)) {
> options += "<option";
>
> if (StringUtils.isNotEmpty(val)){
> options += " value=\"" + val.trim() + "\"";
> }
> if (StringUtils.isNotEmpty(dtm)) {
> options += " dtmf=\"" + dtm.trim() + "\"";
> }
> if (StringUtils.isNotEmpty(acc)) {
> options += " accept=\"" + acc.trim() + "\"";
> }
> options += ">" + utt.trim() + "</option>";
> }
> }
> return options;
> }
> | // end class Options{}
>
>
> Thanks,
> Shane Smith
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]