Quantcast
Channel: Ignite Realtime : Unanswered Discussions - Support
Viewing all articles
Browse latest Browse all 4979

IllegalArgumentException This field only accept list

$
0
0

I want to search all users containing alphabets in a name provided.

 

libraries used - asmack-android-8-4.0.7, dnsjava-2.1.7.

XMPP server - ejabberd 2.1.11

 

For eg. If the input is sammy, then i want all users whose name contains any of the alphabets i.e either 's' or 'a' or 'm' or 'y'

For eg. If the input is michael, then i want all users whose name contains any of the alphabets i.e either 'm' or 'i' or 'c' or 'h' or 'a' or 'e' or 'l'

 

My logic is to make a Arraylist of alphabets from name ie arraylist containing {'s*','a*' ,'m*' ,'y*'} {'m*','i*','c*','h*','a*','e*','l*'}

 

Following is my code :-

 

        ProviderManager.addIQProvider("query","jabber:iq:search", new UserSearch.Provider());

      

        List<String> ls = new ArrayList<String>();

        UserSearchManager search = new UserSearchManager(connection); //connection is passed.

        try {

            Form searchForm = search.getSearchForm("vjud."+ connection.getServiceName());

            Form answerForm = searchForm.createAnswerForm();

          

            ls.add(new String("s*"));

            ls.add(new String("a*"));

            ls.add(new String("m*"));

            ls.add(new String("y*"));

 

            answerForm.setAnswer("user", ls); //--->IllegalArgumentException raised here

 

            ReportedData data = search.getSearchResults(answerForm, "vjud."+ connection.getServiceName());

            if (data.getRows() != null) {

 

                List<Row> listRow = data.getRows();

                for (Row row : listRow) {

                    Log.d(TAG,"****Rows****"+ row.getValues("jid"));

                    for (String ro : row.getValues("jid")) {

                        ls.add(ro);

                    }

                }

            }

        } catch (XMPPException e1) {

            Log.d(TAG,"****getAllUser****"+e1.getMessage());

        }

 

I get IllegalArgumentException, when i pass the arraylist to setAnswer() at code - answerForm.setAnswer("user", ls);

Caused by: java.lang.IllegalArgumentException: This field only accept list of values.

 

I wish to confirm :-

1> Is it correct in XMPP to use searchform to check for multiple values present on server ?

2> Is it possible in XMPP to search for more than values through the forms ?

3> Is it possible to send multiple values through the setAnswer(variable,list) api call using java.util.List subclasses?


Viewing all articles
Browse latest Browse all 4979

Trending Articles