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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:16:29+00:00 2026-05-27T07:16:29+00:00

I have a custom widget ( OrderItem ) in a GWT project. This widget

  • 0

I have a custom widget (OrderItem) in a GWT project. This widget has a TextBox. I set it’s id to “Navid”. But what if I create multiple instances of OrderItem in a panel? The id would be repeated then. This’d make the html invalid.

How do I assign a unique id to the TextBox?

  • 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-05-27T07:16:29+00:00Added an answer on May 27, 2026 at 7:16 am

    Well, normally, GWT widgets generate their own IDs that will automatically be unique and you would not typically worry about what the ID is. When you say that you are setting the ID of a TextBox, I’m assuming that you’re calling something like myTextBox.getElement().setId("Navid").

    There are two simple methods I can think of, depending on your use-case. The HTMLPanel class has a static createUniqueId() method on it that you can use either on its own, or to easily create a unique id. Like myTextBox.getElemement().setId("Navid-" + HTMLPanel.createUniqueId()). The only problem with this is that the ID that is generated is not deterministic.

    The other common method would be to generate an ID based on the ID of the parent widget. myTextBox.getElement().setId("Navid-" + myTextBox.getParent().getElement().getId()).

    However, I’m going to take a guess here and assume that the reason why you’re wanting to assign your own custom ID to this widget is so that you can address it from outside of your GWT code, from Javascript, for example, from JQuery. In this case, I would recommend that instead of assigning an ID to it, which has to be unique to be useful, that you instead assign an html class name to the widget’s element. You would then address the widget’s element relative to the id, or class of your OrderItem’s id or class. You can add an html class name to an element as in the example myTextBox.getElement().addStyleName("navid")

    So, assuming that you assign an html class of orderItemWidget to the root HTML element of your OrderItem widget, and an html class of navid to the TextBox, you could refer to the textbox from a JQuery with the selector ".orderItemWidget .navid"

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

Sidebar

Related Questions

I have custom textfield widget and many form in my project. To use this
lets say i have a custom widget which has a ClickHandler. Here's the example:
I'm using the tree control in GWT. I have a custom widget that I
I have a custom widget, defined similar to this: dojo.declare('myWidget', [dijit._WidgetBase, dijit._Templated], { 'templateString':'<span>'
I've tried to create a custom widget plugin for QT Designer following this (
I have several custom widget in my current project. I wish to apply stylesheets
I have created a custom widget which has a link to some ajax functionality.
I have created a custom widget in gwt which extends the composite.I am using
Suppose I have a MyWidget which contains a MySubWidget , e.g. a custom widget
I have developed a custom dijit Templated Widget. I have to do some DOM

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.