The GWT-Platform: onReveal () method is not called when the browser is updated when the application is deployed to tomcat / jboss

In one of my GWT-Platform applications, I had a strange problem when I launch an application in Jetty configured in the GWT plugin for eclipse and click on the updated browser page, the current page loads (placeManager.getCurrentPlaceRequest ()) successfully, but when the war The application is deployed to tomcat / jboss, stops after the onBind () method of the current host location request and does not show the page.

During the update processing, the first canReveal () method for GateKeeper for this Presenter returns false, and after the server is called, I again find the current location, which the canReveal () method calls to return true, but the host is still not open. So, here I suspect something is complicated.

Any hint of this behavior?

Below is the code snippet for the implemented LoggedInGatekeeper, which plays a key role:

public class LoggedInGatekeeper implements Gatekeeper {

 private final EventBus eventBus; private final DispatchAsync dispatcher; private final PlaceManager placeManager; private CurrentUser currentUser; private boolean isUserLoggedOut; private String lastPageAccessed; @Inject public LoggedInGatekeeper(final EventBus eventBus, final DispatchAsync dispatcher, final PlaceManager placeManager) { this.eventBus = eventBus; this.dispatcher = dispatcher; this.placeManager = placeManager; this.eventBus.addHandler(LoginAuthenticatedEvent.getType(), new LoginAuthenticatedEventHandler() { @Override public void onLogin(LoginAuthenticatedEvent event) { currentUser = event.getCurrentUser(); isUserLoggedOut = false; } }); this.eventBus.addHandler(LogoutUserEvent.getType(), new LogoutUserEventHandler() { @Override public void onLogoutUser(LogoutUserEvent event) { SessionFactory.removeCookie(Constants.LAST_PAGE_ACCESSED); currentUser = null; isUserLoggedOut = true; } }); } @Override public boolean canReveal() { Log.info("Browser fetched session cookie : " + Cookies.getCookie(Constants.JSESSION_COOKIE_KEY)); if (Cookies.getCookie(Constants.JSESSION_COOKIE_KEY) == null) { SC.say("Your session is expired. Please login again"); NavigateToLoginEvent.fire(eventBus); return false; } if (currentUser != null && !isUserLoggedOut) { lastPageAccessed = placeManager.getCurrentPlaceRequest().getNameToken(); Log.info("canReveal() 1 : " + lastPageAccessed); SessionFactory.addCookie(Constants.LAST_PAGE_ACCESSED, lastPageAccessed); return currentUser.isLoggedIn(); } else if (isUserLoggedOut) { Log.info("canReveal() 2 : User is logged out"); NavigateToLoginEvent.fire(eventBus); return false; } else { Log.info("canReveal() 3 : Check on server for logged in user"); dispatcher.execute(new FetchLoggedInUserAction(), new FetchLoggedInUserAsyncCallback()); return true; } } class FetchLoggedInUserAsyncCallback extends MessageAsyncCallback<FetchLoggedInUserResult> { /** * */ public FetchLoggedInUserAsyncCallback() { super("Loading..."); } @Override public void doOnFailure(Throwable caught) { NavigateToLoginEvent.fire(eventBus); } @SuppressWarnings("unchecked") @Override public void doOnSuccess(FetchLoggedInUserResult result) { if (result == null) { Log.info("doOnSuccess() 1 : LoggedInUser not found on server"); NavigateToLoginEvent.fire(eventBus); } else { Log.info("doOnSuccess() 2 : LoggedInUser found on server"); if (result.getLoggedInUser() != null) { currentUser = new CurrentUser(); currentUser.setMerchantConsoleUser(result.getLoggedInUser()); SessionFactory.getClientSessionInstance().put(SessionKeys.LOGGED_IN_USER, result.getLoggedInUser()); PlaceRequest currentPlaceRequest = placeManager.getCurrentPlaceRequest(); Log.info("doOnSuccess() 3 : " + currentPlaceRequest.getNameToken()); if (currentPlaceRequest != null) { placeManager.revealPlace(currentPlaceRequest); } } else { NavigateToLoginEvent.fire(eventBus); } } } } 

}

code>

Thanks at Advance.

+4
source share
1 answer

There was a secret, the following code was added in the onBind () method, and the browser update began to work in all environments as intended. This is similar to the fuzzy behavior of the structure in which GateKeeper is trying to get data from the server at a time when the visibility of the presenter was set to false, and the same thought made me write the following code, and it worked, I hope someone from GWT-P might look at this post to think about the correct way to handle such a scenario:

 /** * This piece of code takes care of revealing page on browser refresh event. * On browser refresh somehow visibility of page is set to false, so, we need to manually fire the reveal content event. */ if(this.getProxy().canReveal() == true && !this.isVisible()){ revealInParent(); } 
+1
source

Source: https://habr.com/ru/post/1434994/


All Articles