protected void respond(final ACAjaxRequestTarget _target,
                           final String _val)
    {
        final AutoCompleteField field = (AutoCompleteField) getComponent();

        final Iterator<Map<String, String>> choices = field.getChoices(_val);

        try {
            final JSONArray jsonArray = new JSONArray();
            int i = 0;
            while (choices.hasNext() && (i < this.settings.getMaxResult() || this.settings.getMaxResult() == -1)) {
                final Map<String, String> map = choices.next();
                final String key = map.get(EFapsKey.AUTOCOMPLETE_KEY.getKey()) != null
                                ? map.get(EFapsKey.AUTOCOMPLETE_KEY.getKey())
                                : map.get(EFapsKey.AUTOCOMPLETE_VALUE.getKey());
                final String choice = map.get(EFapsKey.AUTOCOMPLETE_CHOICE.getKey()) != null
                                ? map.get(EFapsKey.AUTOCOMPLETE_CHOICE.getKey())
                                : map.get(EFapsKey.AUTOCOMPLETE_VALUE.getKey());
                final String value = map.get(EFapsKey.AUTOCOMPLETE_VALUE.getKey());

                final JSONObject object = new JSONObject();
                if (Type.SUGGESTION.equals(this.settings.getAutoType())) {
                    if (this.settings.getMaxChoiceLength() > 0 && choice.length() > this.settings
                                    .getMaxChoiceLength()) {
                        object.put("label", StringUtils.left(choice, this.settings.getMaxChoiceLength()) + "...");
                    } else {
                        object.put("label", choice);
                    }
                    if (this.settings.getMaxValueLength() > 0 && value.length() > this.settings.getMaxValueLength()) {
                        object.put("name", StringUtils.left(value, this.settings.getMaxChoiceLength()) + "...");
                    } else {
                        object.put("name", value);
                    }
                } else {
                    object.put("id", key);
                    if (this.settings.getMaxChoiceLength() > 0 && choice.length() > this.settings
                                    .getMaxChoiceLength()) {
                        object.put("name", StringUtils.left(choice, this.settings.getMaxChoiceLength()) + "...");
                    } else {
                        object.put("name", choice);
                    }
                    if (!choice.equals(value)) {
                        if (this.settings.getMaxValueLength() > 0 && value.length() > this.settings
                                        .getMaxValueLength()) {
                            object.put("label", StringUtils.left(value, this.settings.getMaxChoiceLength()) + "...");
                        } else {
                            object.put("label", value);
                        }
                    }
                }
                jsonArray.put(object);
                i++;
            }
            if (!(i < this.settings.getMaxResult() || this.settings.getMaxResult() == -1)) {
                final JSONObject object = new JSONObject();
                object.put("id", "MAXRESULT");
                object.put("name", "...");
                object.put("label", "...");
                jsonArray.put(object);
            }
            _target.appendJSON(jsonArray.toString());
        } catch (final JSONException e) {
            AutoCompleteBehavior.LOG.error("Catched JSONException", e);
        }
    }
protected void respond ( final ACAjaxRequestTarget _target , final String _val ) { final AutoCompleteField field = ( AutoCompleteField ) getComponent ( ) ; final Iterator < Map < String , String > > choices = field . getChoices ( _val ) ; try { final JSONArray jsonArray = new JSONArray ( ) ; int i = 0 ; while ( choices . hasNext ( ) && ( i < this . settings . getMaxResult ( ) || this . settings . getMaxResult ( ) == - 1 ) ) { final Map < String , String > map = choices . next ( ) ; final String key = map . get ( EFapsKey . AUTOCOMPLETE_KEY . getKey ( ) ) != null ? map . get ( EFapsKey . AUTOCOMPLETE_KEY . getKey ( ) ) : map . get ( EFapsKey . AUTOCOMPLETE_VALUE . getKey ( ) ) ; final String choice = map . get ( EFapsKey . AUTOCOMPLETE_CHOICE . getKey ( ) ) != null ? map . get ( EFapsKey . AUTOCOMPLETE_CHOICE . getKey ( ) ) : map . get ( EFapsKey . AUTOCOMPLETE_VALUE . getKey ( ) ) ; final String value = map . get ( EFapsKey . AUTOCOMPLETE_VALUE . getKey ( ) ) ; final JSONObject object = new JSONObject ( ) ; if ( Type . SUGGESTION . equals ( this . settings . getAutoType ( ) ) ) { if ( this . settings . getMaxChoiceLength ( ) > 0 && choice . length ( ) > this . settings . getMaxChoiceLength ( ) ) { object . put ( "label" , StringUtils . left ( choice , this . settings . getMaxChoiceLength ( ) ) + "..." ) ; } else { object . put ( "label" , choice ) ; } if ( this . settings . getMaxValueLength ( ) > 0 && value . length ( ) > this . settings . getMaxValueLength ( ) ) { object . put ( "name" , StringUtils . left ( value , this . settings . getMaxChoiceLength ( ) ) + "..." ) ; } else { object . put ( "name" , value ) ; } } else { object . put ( "id" , key ) ; if ( this . settings . getMaxChoiceLength ( ) > 0 && choice . length ( ) > this . settings . getMaxChoiceLength ( ) ) { object . put ( "name" , StringUtils . left ( choice , this . settings . getMaxChoiceLength ( ) ) + "..." ) ; } else { object . put ( "name" , choice ) ; } if ( ! choice . equals ( value ) ) { if ( this . settings . getMaxValueLength ( ) > 0 && value . length ( ) > this . settings . getMaxValueLength ( ) ) { object . put ( "label" , StringUtils . left ( value , this . settings . getMaxChoiceLength ( ) ) + "..." ) ; } else { object . put ( "label" , value ) ; } } } jsonArray . put ( object ) ; i ++ ; } if ( ! ( i < this . settings . getMaxResult ( ) || this . settings . getMaxResult ( ) == - 1 ) ) { final JSONObject object = new JSONObject ( ) ; object . put ( "id" , "MAXRESULT" ) ; object . put ( "name" , "..." ) ; object . put ( "label" , "..." ) ; jsonArray . put ( object ) ; } _target . appendJSON ( jsonArray . toString ( ) ) ; } catch ( final JSONException e ) { AutoCompleteBehavior . LOG . error ( "Catched JSONException" , e ) ; } }
@param _target   target
@param _val      value