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

  • SEARCH
  • Home
  • 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 8093435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:30:11+00:00 2026-06-05T20:30:11+00:00

This is a question on how to detect which button was clicked in the

  • 0

This is a question on how to detect which button was clicked in the MessageBox/Dialog.
GXT 2.1 or 2.2 only. Please do not answer using GXT 3.

Ideally, this is how I could do a confirm dialog.

final MessageBox box = MessageBox.confirm(
  "Confirm kill avatar",
  "Please remove " + getAvatar().getName(),
  new Listener<MessageBoxEvent>()
  {
    @Override
    public void handleEvent(MessageBoxEvent be)
    {
      Button clicked = be.getButtonClicked();
      if (clicked == box.getDialog().getButtonById("yes"))
        deleteAvatar();
      else
       Info.display("Action cancelled");
    }
  });
  • However. since box has not been defined, box.getDialog() would be NPE,
  • and compiler preempts that by croaking “box not initialised”,
  • and cannot initialise because box has to be final,
  • box has to be final because it is used in the anon Listener class.

Instead, I have to compare buttons using the button text. Which is not i18n friendly. Very bad practice.

    @Override
    public void handleEvent(MessageBoxEvent be)
    {
      Button clicked = be.getButtonClicked();
      if (clicked.getText().equals("Yes")))
        deleteAvatar();
      else
       Info.display("Action cancelled");
    }

In GXT 2.2, is this the recommended way? Or is there a better way to detect button being pressed, i18n-friendly?

I SHOULD compare buttons NOT the text of the buttons.

  • 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-05T20:30:12+00:00Added an answer on June 5, 2026 at 8:30 pm

    You can use:

    if (Dialog.CANCEL.equals(be.getButtonClicked().getItemId())) {
    
        //do action 
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is not like this one: Browser-independent way to detect when image has
This question relates to this question which I asked earlier this week. The answer
Bounty This question raises several issues. The bounty will go to an answer which
I have not marked this question Answered yet. The current accepted answer got accepted
This question already has an answer here: What are Extension Methods? 5 answers Usage
In C++03, Boost's Foreach, using this interesting technique , can detect at run-time whether
Fairly common question this, to which I have a few answers and I'm nearly
I have a question which is mostly answered by this question . However, I
i'm reposting this question because i'm not sure if i asked it correctly before.:)
I have been looking all over the Internet for an answer to this question

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.