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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:37:33+00:00 2026-05-18T08:37:33+00:00

This may sound very weird, but let’s start with an example: <my:MagicWidget ui:field=someFieldName fieldName=someFieldName/>

  • 0

This may sound very weird, but let’s start with an example:

<my:MagicWidget ui:field="someFieldName" fieldName="someFieldName"/>

It’s pretty much asured that we’ll always want to have the same value in ui:field and in fieldName. Clearly there is some duplucation in this code, I’d like to avoid it and make the fieldName optional.

So, this is what I have in the widget’s code:

@UiConstructor
public MagicWidget(String fieldName) {
    this.fieldName = fieldName;
}

But I’d like, if possible to allow this constructor to be optional, and provide an default constructor that would “by magic” find out it’s ui:field value:

@UiConstructor
public MagicWidget() {
    this.fieldName = /*some magic to get ui:field's value*/;
}

I was wondering if there is a way to get the value of “ui:field” inside my MagickWidget? (The widget extends Composite). I fear this might not be possible, because most of the time it’s not so useful, but if anyone has an idea – feel free to share!

PS: I’m using GWT 2.1.0.RC1.

  • 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-18T08:37:34+00:00Added an answer on May 18, 2026 at 8:37 am

    As you may know, the ui:field is there so you can interact with a UI Object in Java code after you’ve declared it with UiBinder. So, for example, if you add a MagicWidget in a UiBinder template, you can write

    @UiField MagicWidget someWidget

    in order to be able to interact with it programatically. Having your magic widget aware of the name of the reference that is pointing to it might not be all that helpful (or possible), as you can pass the reference to that specific MagicWidget back and forth between different parts of your application. A single MagicWidget could easily have several references with different names pointing at is simultaneously. That’s why it’s difficult to pick it out “by magic” at runtime. I realize this isn’t much of an issue if you only want this value when the object is constructed, but keep in mind that you’re not required to include a ui:field when you add a widget using UiBinder.

    Why is it important that the Widget know its field name? Knowing that might make it easier to provide suggestions about other ways to accomplish what you are looking to do.

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

Sidebar

Related Questions

This may sound very noobish but I have tried to read the forum posts
Okay this may sound silly, but I am not very familiar with XML. What
This may sound like a weird question but is there any where I can
This may sound like a weird question but I will give it a shot
This may sound strange but sometimes when your ASP.NET webapp isn't working and you
This question may sound fairly elementary, but this is a debate I had with
This may not really sound hard to do but it is currently killing me.
This may sound very basic... can someone please explain the use of the toString()
I am relatively new to socket programming so this may sound like a very
This may sound totally stupid, but is a case of real life :( I'm

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.