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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:26:52+00:00 2026-05-24T13:26:52+00:00

I have following editor class, and I’m curious what’s wrong with it. When running,

  • 0

I have following editor class, and I’m curious what’s wrong with it. When running, it does correctly set the right radio button as selected. However, when flushing the top level editor, getValue is never called, and my object’s property never get updated. Here’s the code (hint – modified ValueListBox):

    public class ValueRadioList<T> extends FlowPanel implements
        HasConstrainedValue<T>, LeafValueEditor<T>, ValueChangeHandler<Boolean> {

    private final List<T> values = new ArrayList<T>();
    private final Map<Object, Integer> valueKeyToIndex =
            new HashMap<Object, Integer>();

    private final String name;
    private final Renderer<T> renderer;
    private final ProvidesKey<T> keyProvider;

    private T value;

    public ValueRadioList(Renderer<T> renderer) {
        this(renderer, new SimpleKeyProvider<T>());
    }

    public ValueRadioList(Renderer<T> renderer, ProvidesKey<T> keyProvider) {
        super();
        this.name = DOM.createUniqueId();
        this.keyProvider = keyProvider;
        this.renderer = renderer;
    }

    private void addValue(T value) {
        Object key = keyProvider.getKey(value);
        if (valueKeyToIndex.containsKey(key)) {
            throw new IllegalArgumentException("Duplicate value: " + value);
        }

        valueKeyToIndex.put(key, values.size());
        values.add(value);
        RadioButton radio = new RadioButton(name, renderer.render(value));
        radio.addValueChangeHandler(this);
        add(radio);
        assert values.size() == getWidgetCount();
    }

    @Override public HandlerRegistration addValueChangeHandler(
            ValueChangeHandler<T> handler) {
        return addHandler(handler, ValueChangeEvent.getType());
    }

    @Override public T getValue() {
        return value;
    }

    @Override public void onValueChange(ValueChangeEvent<Boolean> event) {
        int selectedIndex = -1;
        for (int i = 0, l = getWidgetCount(); i < l; i++) {
            if (((RadioButton) getWidget(i)).getValue()) {
                selectedIndex = i;
                break;
            }
        }

        if (selectedIndex < 0) {
            return; // Not sure why this happens during addValue
        }
        T newValue = values.get(selectedIndex);
        setValue(newValue, true);
    }

    @Override public void setAcceptableValues(Collection<T> newValues) {
        values.clear();
        valueKeyToIndex.clear();
        clear();

        for (T nextNewValue : newValues) {
            addValue(nextNewValue);
        }

        updateRadioList();
    }

    @Override public void setValue(T value) {
        setValue(value, false);
    }

    @Override public void setValue(T value, boolean fireEvents) {
        if (value == this.value
                || (this.value != null && this.value.equals(value))) {
            return;
        }

        T before = this.value;
        this.value = value;
        updateRadioList();

        if (fireEvents) {
            ValueChangeEvent.fireIfNotEqual(this, before, value);
        }
    }

    private void updateRadioList() {
        Object key = keyProvider.getKey(value);
        Integer index = valueKeyToIndex.get(key);
        if (index == null) {
            addValue(value);
        }

        index = valueKeyToIndex.get(key);
        ((RadioButton) getWidget(index)).setValue(true);
    }
}
  • 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-24T13:26:52+00:00Added an answer on May 24, 2026 at 1:26 pm

    Solved it, my POJO missed a setter for that field.

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

Sidebar

Related Questions

If I have the following text in my Eclipse editor: Text Line 1 Text
I have following classes. class A { public: void fun(); } class B: public
I have the following setup: class Publication < ActiveRecord::Base has_and_belongs_to_many :authors, :class_name=>'Person', :join_table =>
I have a Joomla 1.5 component that uses a call to the editor class
I have the following editor template @model DateTime? @Html.TextBox(, (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty),
I have the following winforms classes: class EntityEditorForm<T>: System.Windows.Forms.Form where T: ICloneable<T> {} class
In server side I have following class public class EditorContext { public Module Module
I have a curious problem with ASP.NET MVC3 client-side validation. I have the following
my problem is the following I have an instance of a class and a
I have the following model in MVC: public class IndexViewModel { public SubViewModel SubViewModel

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.