What will be implementation of the method getMatchingCities() in customSuggestionOracle ?
Thanks
Deepak
--
Deepak Singh
-- On Mon, Aug 27, 2012 at 12:42 PM, Ümit Seren <uemit.seren@gmail.com> wrote:
It depends how you want to access your backend. Assuming you do a normal Ajax call you could do something like this:private List<CustomSuggestion> getMatchingCities(String query, int limit) {List<CustomSuggestion> list = new ArrayList<CustomSuggestion>();RequestBuilder request = new RequestBuilder(RequestBuilder.GET,url+"?query="+query+"&limit=" + limit);request.setCallback(new RequestCallback() {@Overridepublic void onResponseReceived(Request request, Response response) {//parse the result (maybe JSON) and populate your ArrayList}@Overridepublic void onError(Request request, Throwable exception) {// TODO Auto-generated method stub}});try{request.send();}catch (Exception e) {}}
On Sunday, August 26, 2012 11:20:31 PM UTC+2, Deepak Singh wrote:Hi,I tried this waypublic class CustomSuggestion implements Suggestion{public CityNameDTO dto = null;public CustomSuggestion(CityNameDTO dto) {this.dto = dto;}@Overridepublic String getDisplayString() {return dto.getCityName();}@Overridepublic String getReplacementString() {return dto.getCityId();}}public class CustomSuggestOracle extends SuggestOracle{List<CustomSuggestion> citySugggestions = null;@Overridepublic void requestSuggestions(Request request, Callback callback) {Response response = new Response(getMatchingCities(request.getQuery(), request.getLimit()));}private List<CustomSuggestion> getMatchingCities(String query, int limit) {List<CustomSuggestion> list = new ArrayList<CustomSuggestion>();}}Now i am not able to understand how to go ahead with this customSuggestOracle.Could you pls guide me here?ThanksDeepakOn Sun, Aug 26, 2012 at 11:18 PM, Thomas Broyer <t.br...@gmail.com> wrote:
On Sunday, August 26, 2012 6:36:11 PM UTC+2, Deepak Singh wrote:But after selecting a value, how do i get the id of the selected value?
SuggestBox works best if you use the ID as the "replacementString" and the label as the "displayString" of the Suggestions in your SuggestOracle. In that case, you don't have to do anything, the ID will be set in the text box upon selecting a suggestion.(e.g. the "replacement string" is an email address, and the display string also contains the full name, the oracle using both the full name and email address for providing suggestions)--To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/Ldxgth8ifd0J.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
--
Deepak Singh
--To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/cGP5gBfv5soJ.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Deepak Singh
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment