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 8668641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:15:50+00:00 2026-06-12T18:15:50+00:00

I think I am just doing something stupid but I can’t figure this one

  • 0

I think I am just doing something stupid but I can’t figure this one out.

I am using GWT, and I have a submit button where submit sends some information to a remote server via a REST API. The problem is, you can click submit multiple times while the operation is completing, and multiple posts are made.

I have tried adding

 sendButton.setEnabled(false);

to the click handler, but it does not seem to be working. The button remains enabled and I can still click it as many times as I want resulting in multiple posts. Can someone see what I am doing wrong? Complete code below.

public class HelpDeskTest implements EntryPoint {
private final HelpDeskTestServiceAsync helpDeskTest= GWT.create (HelpDeskTestService.class);

final Button sendButton = new Button("Submit");
final TextBox nameField = new TextBox();
final Label errorLabel = new Label();
final TextBox subjectField = new TextBox();
final TextArea descriptionField= new TextArea();


/**
 * This is the entry point method.
 */
public void onModuleLoad() {


    // We can add style names to widgets
    //sendButton.addStyleName("sendButton");

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(nameField);
    RootPanel.get("subjectFieldContainer").add(subjectField);
    RootPanel.get("descriptionFieldContainer").add(descriptionField);
    RootPanel.get("sendButtonContainer").add(sendButton);
    RootPanel.get("errorLabelContainer").add(errorLabel);

    //set name field text
    nameField.setText("GWT User");

    // Focus the cursor on the name field when the app loads
    subjectField.setFocus(true);
    subjectField.selectAll();


    //set widths and heights
    descriptionField.setWidth("100%");
    descriptionField.setHeight("200px");
    nameField.setWidth("100%");
    subjectField.setWidth("100%");


    //click handler
    sendButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {

            sendButton.setEnabled(false);

            String uName = nameField.getText();
            String subject = subjectField.getText();
            String desc = descriptionField.getText();

            String newURLp1 = "http://xxx.xx.xx/sdpapi/request?" +
                    "OPERATION_NAME=ADD_REQUEST&TECHNICIAN_KEY=D4xxxxxxxB6" +
                    "&INPUT_DATA=<?xml version=";
            String urlp2 = "%221.0%22";
            String urlp3 = " encoding=";
            String urlp4 = "%22utf-8%22";
            String urlp5 = "?><Operation><Details><requester>" + uName + "</requester><subject>" + subject + 
            "</subject><description>" + desc + "</description></Details></Operation>";

            String encUrl = URL.encode(newURLp1) + urlp2 + URL.encode(urlp3) + urlp4 + URL.encode(urlp5);
            System.out.println(encUrl);

            helpDeskTest.postToRemoteServer(encUrl,
                    new AsyncCallback<String>() {
                        @Override
                        public void onFailure(Throwable caught)  {
                            Window.alert("Failure getting XML through proxy");
                        }

                        @Override
                        public void onSuccess(String result) {
                            processXML(result);
                        }


                    });
            sendButton.setEnabled(true);
        }
    });

}

    public void processXML(final String xml) {

        try {

            Document doc = XMLParser.parse(xml);

           // get the status using Node's getNodeValue() function - this will determine success or failure.
            String status = doc.getElementsByTagName("status").item(0).getFirstChild().getNodeValue();

            //if success:
            if (status.equals("Success")) {

                String statCode = doc.getElementsByTagName("statuscode").item(0).getFirstChild().getNodeValue();
                String msg = doc.getElementsByTagName("message").item(0).getFirstChild().getNodeValue();
                String woid = doc.getElementsByTagName("workorderid").item(0).getFirstChild().getNodeValue();

                System.out.println("Result from HelpDesk:");
                System.out.println("Status Code: " + statCode);
                System.out.println("Status: " + status);
                System.out.println(msg);

                System.out.println(msg + ".  Ticket Number is: "  + woid);

                errorLabel.setText(msg + ".  Ticket Number is: "  + woid);

            } else if (status.equals("Failed")){
                //get message
                String failmsg = doc.getElementsByTagName("message").item(0).getFirstChild().getNodeValue();
                errorLabel.setText(failmsg);

            } 


        }
        catch ( Exception e ) {
            e.printStackTrace();
        }


    }

}

  • 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-12T18:15:52+00:00Added an answer on June 12, 2026 at 6:15 pm
    sendButton.setEnabled(true);
    

    You have enabled your button again at the end of the onClick() method.. See your click handler..
    This might be the problem..

    Try moving this line inside onSuccess() method: –

    @Override
    public void onSuccess(String result) {
        processXML(result);
        sendButton.setEnabled(true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Page in question: http://www.rjlacount.com/public/lander/ I'm probably just doing something stupid, but I'm trying to
Hi I think this is just a syntax problem, but I might be doing
I can proxy a single function in javascript by doing something like this (just
I think this is just a Best Practices question, but I was wondering if
I think I'm just missing something simple here but here is what I am
Okay, I think I'm just making a stupid mistake here, but I want to
For some reason this function is doing something weird just in Firefox function fadeOUT_sect(id)
I think I'm close and I bet the solution is something stupid. I have
This may just be a simple mistake that I'm not seeing, but I think
I have just installed django-cnotes But it wont work. It just throws up this

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.