Updating a variable after a clicked selection in an OptionGroup

Hi all,

I have a form that uses a bunch of OptionGroup components, most of which are single-selection. When someone checks a different check box or radio button other than the default in my form, I want it to update a LinkedHashMap variable (addrInfo in the code).

I am currently using Property.ValueChangeEvent and a corresponding handler, but the handler isn’t even getting called whenever I click on a different selection. I’m not really sure how to bind the component value with the value in the corresponding hash map. If someone can provide a solution or even point me in the right direction, I’d greatly appreciate it! Here’s the relevant part of my code:


public class ShareAddressForm extends InputAddressForm implements Property.ValueChangeListener
{
	private Form shareForm;
	private static final String COMMON_FIELD_WIDTH = "12em";
	private OptionGroup outputRecordType;
	private OptionGroup outputFieldLevelResult;
	private OptionGroup outputFormattedOnFail;

	//parameter options for output record type
	private static final List<String> recType = Arrays.asList(new String[] {
        "A", "E", "I", "P" });
	//parameter options for true/false 
	private static final List<String> yesNo = Arrays.asList(new String[] {
        "Y", "N" });

        public ShareAddressForm()
	{
		super();
		//create an additional form appended to this tab for SHARE details
		shareForm = new Form();
		addComponent(shareForm);
		
		shareForm.setCaption("Additional SHARE parameters (mouseover for more info)");
		shareForm.setWriteThrough(false); // we want explicit 'search'
		shareForm.setInvalidCommitted(false);

		addrInfo.put(Const.OUTPUT_REC_TYPE, "AEIP");
		addrInfo.put(Const.OUTPUT_FLD_LVL_RTRN, "Y");
		addrInfo.put(Const.OUTPUT_FRMTD_ON_FAIL, "Y");

               outputRecordType = new OptionGroup("OutputRecordType ", recType);
		outputRecordType.setMultiSelect(true);
		//select all default values
		for (Iterator i = outputRecordType.getItemIds().iterator(); i.hasNext(); )
			outputRecordType.select(i.next());
		outputRecordType.setDescription("...");
		outputRecordType.addListener(this);
		parameterGrid.addComponent(outputRecordType);

		outputFieldLevelResult = new OptionGroup("FieldLevel \nResultIndicators ", yesNo);
		outputFieldLevelResult.select("Y");
		outputFieldLevelResult.setDescription("...");
                outputFieldLevelResult.addListener(this);
		parameterGrid.addComponent(outputFieldLevelResult);
		
		outputFormattedOnFail = new OptionGroup("FormattedOnFail ", yesNo);
		outputFormattedOnFail.select("Y");
		outputFormattedOnFail.setDescription("...");
                outputFormattedOnFail..addListener(this);
		parameterGrid.addComponent(outputFormattedOnFail);

		addComponent(parameterGrid);
	}

	@Override
	public void valueChange(ValueChangeEvent event)
	{
		if (event.getProperty() == outputRecordType)
			addrInfo.put(Const.OUTPUT_REC_TYPE, outputRecordType.getValue());
		
	}
	

Hi,

Kind of shooting from the hip here, but forgetting
setImmediate(true)
is usually the cause for such problems (your handler should be called at some point though, just not immediately, if immediate==false).

Best Regards,
Marc