Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8789109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:18:40+00:00 2026-06-13T22:18:40+00:00

Function canReveal() returns true if class ClientState has user information. If not, it first

  • 0

Function canReveal() returns true if class ClientState has user information. If not, it first tries to get that user information using asyncronous call to GetUser. What I need to do inside the IF is to wait somehow until this asyncronous call returns (onSuccess), so that I can check whether ClientState has now the user information or not. How can I do that? Thanks

public class MyGatekeeper implements Gatekeeper{

private DispatchAsync dispatcher;

@Inject
public MyGatekeeper(DispatchAsync dispatcher) {
        this.dispatcher = dispatcher;
}

@Override
public boolean canReveal() {
    if(ClientState.isUserLoggedin()==false) {
        dispatcher.execute(new GetUser(Window.Location.getHref()),
        new DispatchCallback<GetUserResult>() {
                @Override
                        public void onSuccess(GetUserResult result) {
                if (!result.getErrorText().isEmpty()) {
                     Window.alert(result.getErrorText());
                     return;
                }
                ClientState.setUserInfo(result.getUserInfo());
            }
        });
        return ClientState.isUserLoggedin(); // WAIT till onSuccess returns!
    }
}
    return ClientState.isUserLoggedin();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:18:41+00:00Added an answer on June 13, 2026 at 10:18 pm

    The way to do this is to have canReveal take a Callback<Boolean>:

    public void canReveal(Callback<Boolean> cb) {
      if (!ClientState.isUserLoggedIn()) {
        dispatcher.execute(..., new DispatchCallback<Result>() {
          @Override
          public void onSuccess(Result result) {
            cb.onSuccess(result.isGoodOrWhatever());
          }
        });
      } else {
        cb.onSuccess(true); // User is logged in
      }
    }
    

    Unfortunately there’s no way to tell GWT to “wait” for the async callback, since that would basically freeze JS execution, since JS is single-threaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function checkuser(user) { var ret = false; $.ajax({ type:'POST', url:'user.php', async:false, data:{'user':user}, success:function (data)
Function calculate_attribute does not return a value; it only works through side effects. Often
function getNTAccounts { Add-PSSnapin Quest.ActiveRoles.ADManagement connect-QADService $accounts = @() Get-QADUser -CreatedAfter (Get-Date).AddDays(-3) -SerializeValue |
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
function anchor($text) { return preg_replace('#\&gt;\&gt;([0-9]+)#','<span class=anchor><a href=#$1>>>$1</a></span>', $text); } This piece of code is
function filterRows(statusName) { $(#mainTable tbody tr.+statusName).hide(); } It hides the rows that have the
function drawLabel(labelsIndex) { // Check not deleted Label data:(DBID, text, styling, x, y, isDeleted)
function selected() { var selObj = window.getSelection(); } This function returns selected text from
function SendInfo(href) { var subject= Some information; var body = I thought you might
function Apple(){ this.name=apple; } function Orange(){ this.name=orange; this.apple = new Apple(); this.apple.onCalled=function(){ alert(this.name); }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.