Get Component Name in the ValueChangeListener

Hi everybody,

I have a class implements ValueChangeListener contain some component like ListSelect, Combobox

I have set the event on it with:

component.addListener(this)

and i have a method

@Override
	public void valueChange(ValueChangeEvent event) {
		//to do something
	}

i want to get name for the processing when i change the event on each.

Or please give me the best solution for all.

Thank you !

Hi,

for your purpose, I would use anonymouse inner classes for each component, like this:

[code]

    component.addListener(new Property.ValueChangeListener() {
        
        @Override
        public void valueChange(ValueChangeEvent event) 
           // Do something here when value change fired
        }
    });

[/code]}

If you want to use a single ValueChangeListener, ValueChangeEvent.getProperty() of a listener on a Field should return the Field itself, so you can check if getProperty() is a Component/Field and cast it in that case to get the name.

I have fixed my problem.
Thank you so much !

Hi… how was the Problem solved.
I have similar Problem … wherin I have a single ValueChangelistener for all components
I want the Component name and changed values for logging the changes in Components on a single Screen

On valuechangelistner I get the Component Value but couldnt associate which component it it associated with

Did you find a solution or a workaround? I’m encountering the same issue.

This seems to work.

If I cast the property to the Component type I am expecting.

something like ((OptionGroup)e.getProperty()).getData() for example.