Country name with space not accepted in BlackBerry ObjectChoiceField

后端 未结 1 2028
无人及你
无人及你 2021-01-27 04:53

I am developing a registration page in BlackBerry app. I am sending all the fields entered to the local server.Country is one of the form fields and is in a ObjectChoiceField. W

相关标签:
1条回答
  • 2021-01-27 05:11

    There is no problem in ObjectChoiceField. For example if you want to send the Value like "Black Berry" you must send it to the web service like "Black%20Berry". Because %20 takes the space character. So after you are taking the value form ObjectChoiceField means......

    ar[obchfield.getSelectedIndex()];// this is your value say for example:"Black Berry".

    Take this below code in seperate Classname Utility.java:

    public class Utility {
    public static String escapeHTML(String s){
        StringBuffer sb = new StringBuffer();
        int n = s.length();
           for (int i = 0; i < n; i++) {
              char c = s.charAt(i);
              switch (c) {
                 case ' ': sb.append("%20"); break;
                 default:  sb.append(c); break;
            }
        }
        return sb.toString();
    }}
    

    Then do like this:

    Utility.escapeHTML(ar[obchfield.getSelectedIndex()]);//converts the "Black Berry" to "Black%20Berry".
    

    then it returns a String like: "Black%20Berry" and send it to server. Enough. Your problem is solved.

    If you have any doubt come on StackOverFlow chat room name "Life for Blackberry" to clarify Your and our doubts.

    0 讨论(0)
提交回复
热议问题