Results 1 to 8 of 8
Thread: Suggestions return all
- 03-26-2011, 09:29 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
-
we don't know the problem without looking at your code for the suggestbox.
as for converting returned result into an array, that also depends on the return Type of the suggestbox.
fetching into labels is easy,
myLabel.setText(returnResultArray[index]);
- 03-26-2011, 10:43 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
Java Code:public class ItemSuggestionOracle extends SuggestOracle { public static final RPCSuggestAsync rpcService = RPCSuggest.App.getInstance(); public boolean isDisplayStringHTML() { return true; } public void requestSuggestions(SuggestOracle.Request req,SuggestOracle.Callback callback) { rpcService.getQuote(req, new ItemSuggestCallback(req, callback)); } class ItemSuggestCallback implements AsyncCallback { private SuggestOracle.Request req; private SuggestOracle.Callback callback; public ItemSuggestCallback(SuggestOracle.Request _req, SuggestOracle.Callback _callback) { req = _req; callback = _callback; } public void onFailure(Throwable error) { callback.onSuggestionsReady(req, new SuggestOracle.Response()); } public void onSuccess(Object retValue) { callback.onSuggestionsReady(req, (SuggestOracle.Response) retValue); } } }Java Code:public class ItemSuggestion implements IsSerializable, SuggestOracle.Suggestion { private String s; // Required for IsSerializable to work public ItemSuggestion() { } // Convenience method for creation of a suggestion public ItemSuggestion(String s) { this.s = s; } public String getDisplayString() { return s; } public String getReplacementString() { return s; } } // end inner class ItemSuggestionand server side...Java Code:public interface RPCSuggest extends RemoteService { SuggestOracle.Response getQuote(SuggestOracle.Request req);
Java Code:public class RPCSuggestImpl extends RemoteServiceServlet implements RPCSuggest { public SuggestOracle.Response getQuote(SuggestOracle.Request req) { SuggestOracle.Response resp = new SuggestOracle.Response(); List<ItemSuggestion> suggestions=new ArrayList<ItemSuggestion>(); for (int i=0;i<1000;i++) { Integer j=i; suggestions.add(new ItemSuggestion(j.toString())); } resp.setSuggestions(suggestions); return resp; } }
- 03-30-2011, 06:01 AM #4
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
-
i'm surprised that you can't see why this would give you ALL data instead of the required data:
Java Code:List<ItemSuggestion> suggestions=new ArrayList<ItemSuggestion>(); for (int i=0;i<1000;i++) { Integer j=i; suggestions.add(new ItemSuggestion(j.toString())); }
on the positive side, you're almost there. this is what your code says in English:
Java Code:Make a new List to store our results //thats fine Loop 1000 items { add new ItemSuggestion to our List //adding items unconditionally not good }
But this is what it should say in English:
Java Code:Make a new List to store our results Loop 1000 items { if we find 'the right suggestion' or 'a match' { add it to our List } }
- 03-31-2011, 09:36 AM #6
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
ok, I got advice very very useful, but sorry if my English not so correct, caused that is not my native, but what about parsing gettin results to arraylist, I know how use data from array list and paste it in labels, but there is problem for getting List<ItemSuggestions> instead of SuggestOracle.Response in server side
-
I am not so sure what you mean...
but there is problem for getting List<ItemSuggestions> instead of SuggestOracle.Response in server side
what do you want to do?
- 04-01-2011, 05:32 AM #8
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
[suggestions] minesweeper
By temyong in forum New To JavaReplies: 7Last Post: 12-30-2010, 03:10 AM -
looks good looking for suggestions..
By search4survival in forum New To JavaReplies: 10Last Post: 11-30-2010, 12:59 PM -
Looking for suggestions
By tonino in forum New To JavaReplies: 5Last Post: 09-26-2010, 07:17 PM -
Book suggestions
By Lil_Aziz1 in forum Java AppletsReplies: 3Last Post: 01-04-2010, 02:38 AM -
any suggestions?
By PureAwesomeness in forum New To JavaReplies: 4Last Post: 01-19-2009, 07:34 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks