gwt - Accessing non-static objects from anonymous objects in Java -
Working with Google Web Toolkit I wrote an application based on the model-view-controller concept, now my
Client controller Two types of class ClientModel and ClientView have been declared as private and non-static I have some remote with the object for asynchronous calls Procedure calls are written which work, however AsyncCallback client modell and client view objects to some bad last variable Without my function can write like: package com .foo.bar; / ** * represents the representatives of the main handlers and controls the content of the {@link client modules} and sends notifications and messages to both the {@link clientmodel} and {@link ClientView}. * / Local Client Controller Displays Asynchronous Tasks for Calling Server Component by RPC * / Public Fixed Last MyServiceAsync mySvc = GWT.create (myService.class); / ** * {@link ClientController} represents the model associated with the object * / Private client modemModel = Faucet; / ** * {@link ClientController} represents an object-related view * / Private Client view theView = null; / ** * Creates a new {@link ClientController} object and instantiates both * {@link ClientModel} and {@link ClientView}. * / Public Client Administrator () {this.theModel = New ClientModel (); This.theView = New Client View (this.the model); } / * Some more code * / / ** * The user attempts to login and {@link ClientView} * updates an object on an error message or main interface. * * @ PRM User * {@link User} object to login to object * / Public Wide Lounge user (end user user) {/////////////////// //////////////////////////// This is not completely and I do not know how to fix it. /////////////////////////////////////// Last ClientModelWorldel = this.the model; // Access Protocol Client Controller.messvlogin (user, new asynchroncate & lt; boolean & gt; ()} / / * request was successfully executed. Return boolean value * indicates that the user was logged in. * * @The ultimate result * True, if the user is logged in; Otherwise, Incorrect. * / @ Override Success on Public Zero (Boolean result) {// User was successfully logged in and both of us were in the model Store and then update the view if (the result) {// TODO: Update the view to show the chat and save the current user in the client modem System.out.println ("user" + user.getUsername () + "Is now logged in!"); // Anonymous object can not directly use the client controller's model and theView // objects ... // Drunk, fix later! // Yuji Fix For Now the current model. Settuck user (user);} else {// TODO: Show the error label of login form and output / some good error message. System.out.println ("login user failed" + user.getUsername () + "!");}} / ** * Th e request an error harassed * public @ on @afiride (throwable) {try (throw; // ha ha} hold (throal e) {// who cares? }}}); }} For now I am using the last indicator for the internal model in loginUser which is hoghlighted twice, can anyone explain to me that Without a valid code, themodel and theView have no better solution or not? Writing such components is annoying in the "last cover" in every function ...
When you make an example of an non-static internal class, or make an example of an anonymous class, then an implied bond for example of the external class of that example It's made you OuterClassName.this.member .
Comments
Post a Comment