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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:10:12+00:00 2026-06-05T22:10:12+00:00

Good day I have a custom TextBox that has a IndicatorTextBox.ui.xml file as well

  • 0

Good day

I have a custom TextBox that has a IndicatorTextBox.ui.xml file as well as IndicatorTextBox.java file.
Ussually adding an evenhadler to a textbox is simple.

This is in my main .java file

@UiHandler("txtFirstName")
void onTxtFirstNameKeyUp(KeyUpEvent event){ 
validateFields();
}

How would I add the handler if the txtFirstName was the custom textbox with label that I am adding to this page.?
So, in other words txtFirstnName is not @UiField TextBox txtFirstName but IndicatorTextField txtFirstName instead.

The IndicatorTextBox.java file looks as follow

import com.google.gwt.core.client.GWT;

public class IndicatorTextField extends Composite implements HasText{

public interface Binder extends UiBinder<Widget, IndicatorTextField> {
}

private static final Binder binder = GWT.create(Binder.class);

public interface Style extends CssResource{
    String textStyling();
    String requiredInputLabel();
    String colorNotValidated();


}

@UiField Style style;
@UiField Label label;
@UiField TextBox textBox;


public IndicatorTextField()
{

    initWidget(binder.createAndBindUi(this));
}

public void setBackgroundValidateTextbox(boolean validated)
{
    if(validated)
    {
        textBox.getElement().addClassName(style.colorNotValidated());
    }
    else
    {
        textBox.getElement().removeClassName(style.colorNotValidated());

    }

}

@Override
public String getText() {

    return label.getText();
}

@Override
public void setText(String text) {
    label.setText(text);

}
  • 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-05T22:10:15+00:00Added an answer on June 5, 2026 at 10:10 pm

    Your IndicatorTextField first has to implements the HasKeyUpHandlers interface, catch the KeyUpEvents from the textBox and fire them to its handlers.

    public class IndicatorTextField extends Composite implements HasText, HasKeyUpHandlers {
        ...
    
        @Override
        public HandlerRegistration addKeyUpHandler(KeyUpHandler handler)  {
            return addHandler(handler, KeyUpEvent.getType());
        }
    
        ...
    
        @UiHandler("textBox")
        public void onKeyUp(KeyUpEvent event) {
            DomEvent.fireNativeEvent(event.getNativeEvent(), this);
        }
    
    }
    

    Then in your main java class, if you’re creating this IndicatorTextField with uiBinder, then you can just add a UiHandler to it the regular way

    @UiField
    IndicatorTextField myIndicatorTextField;
    
    @UiHandler("myIndicatorTextField)
    public void onKeyUp(KeyUpEvent event) {
        validateFields();
    }
    

    If you’re creating by calling the constructor, then call addKeyUpHandler on it

    IndicatorTextField myIndicatorTextField = new IndicatorTextField();
    myIndicatorTextField.addKeyUpHandler(new KeyUpHandler() {
        public void onKeyUp(KeyUpEvent event) {
            validateFields();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day, I have a local csv file with values that change daily called
Good Day I have a project that makes use of custom assemblies in the
Good day to you guys I have an application that has a UITabBarController for
Good day, I have a class that implements the LoaderCallbacks, and hence have the
Good Day, I have a simple working routine in Perl that swaps two words:
Good Day, I have a Hibernate mapping that looks something like this: public class
Good day, I have created an object that will manage data access. My app
Good day, I have found a strange quirk in Vim that I can't explain
Good day code knights, I have a tricky problem that I cannot see a
Good day everyone, I have the following XML data : <?xml version=1.0 encoding=utf-8 ?>

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.