Thank you a lot for these detailed explanation which where very helpfull 
for me Thomas !

I add passed successfully all your methods, going through the proxy method, 
until the delegating object in order to be used with others views.
(just could you give me the utility about the case of the word final in the 
line "private final SuggestOracle oracle = new DelegatingSuggestOracle()" ?)

I have written the call of setSuggestOracle into the revealDisplay() of the 
presenter :
=> with your solution I am even be able to change the call of the service 
by a call of my existing injected model (which calls itself the service)

Many thanks Thomas !

Have a good week-end

Le vendredi 9 septembre 2016 10:38:52 UTC+2, Thomas Broyer a écrit :
>
>
>
> On Friday, September 9, 2016 at 9:31:27 AM UTC+2, Eddy wrote:
>>
>> Thank you for your first help Thomas !
>>
>> What I had tried is to write a get method from the view/display 
>> interface, which return the suggestBox object and which I had called from 
>> the presenter on the onBind or revealDisplay :
>> => I could redefine as the same the requestSuggestions() into the 
>> presenter but then I didn't know how to transmit it to the view / how to 
>> instanciate the visible SuggestBox object for showing it into the view 
>> (regarding the new SuggestBox(oracle) line).
>>
>
> Something like:
> in the presenter:
>     public void getSuggestions(SuggestOracle.Request req, 
> SuggestOracle.Callback callback) {
>       service.getSuggestions(req, callback);
>     }
>
> in the view:
>     SuggestOracleCustom oracle = new SuggestOracleCustom() { 
>         @Override
>         public void requestSuggestions(SuggestOracle.Request req, 
> SuggestOracle.Callback callback) {
>             presenter.getSuggestions(req, new 
> SuggestOracleCallbackCustom(req, callback));
>         }
>     };
>     SuggestBox suggestBox = new SuggestBox(oracle);
>     this.add(suggestBox);
>
> (put the SuggestOracleCallbackCustom where it needs to go, either 
> presenter or view, depends on what it does)
>  
>
>> Excuses-me but I am not familiar enough by making my own proxy / 
>> "delegating" etc. Can you give me some sample please ?
>>
>
> Something like:
>     private SuggestOracle realOracle; // set by the presenter
>     …
>     SuggestBox suggestBox = new SuggestBox(new SuggestOracle() {
>         @Override
>         public boolean isDisplayStringHTML() {
>             return realOracle.isDisplayStringHTML();
>         }
>         @Override
>         public void requestDefaultSuggestions(SuggestOracle.Request 
> request, SuggestOracle.Callback callback) {
>             realOracle.requestDefaultSuggestions(request, callback);
>         }
>         @Override
>         public void requestSuggestions(SuggestOracle.Request req, 
> SuggestOracle.Callback callback) {
>             realOracle.requestSuggestions(req, callback);
>         }
>     });
>     this.add(suggestBox);
>
> That way, the realOracle can be replaced at any time, without the need to 
> re-build the SuggestBox.
> The anonymous SuggestOracle passed to the SuggestBox acts as a proxy 
> (façade) to the 'realOracle' (which is then the proxy's "delegate").
> If you need that pattern many times in your application, then create a 
> DelegatingSuggestOracle similar to the anonymous one but with the 
> realOracle as a field of the DelegatingSuggestOracle, with getter and 
> setter. Your view would then read:
>
>     private final SuggestOracle oracle = new DelegatingSuggestOracle();
>     …
>     SuggestBox suggestBox = new SuggestBox(oracle);
>     this.add(suggestBox);
>     …
>     public void setSuggestOracle(SuggestOracle oracle) { // called by the 
> presenter
>       this.oracle.setDelegate(oracle);
>     }
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to