Dynamic Combo clear method

I use clear method of dynamic combo in order to delete all options before I regenerate them.But the clear method doesn’t delete currently selected option.So when I try to regenerate options for combo I always have one extra undesired option .
But same code works well when I set renderasfield option to true.

Is there any advice ?

Thanks in advance.

…the combobox always adds the item that is currently selected. If the list of options is 1,2,3,4 and the current value is 5, then automatically 5 is added - otherwise nothing is displayed…

Bjoern

So how can I regenerate content of combo from the ground then ?
(And which logic changes if I set renderasfield option to true ? )

…you must make sure that the content of the field (VALUEPROP) is either not set (null) or is part of the lsit of valid values…

Bjoern

Hi Bjoern ,
I made an simple example to make myself clear and I recognized that my problem happens just in one case.If the value of previously selected item does not exists in new option list , the combo box automatically adds that value to new option list.
To see this problem can you please try the following codes in your ide.Just select option2 from combo1 and select an option from combo2 which has a value greater than 2.After that choose value 1 from combo1 again and you’ll see one extra option appears in combo2.

Page Code

<page model="test.ADPTest">
    <titlebar name="Template">
    </titlebar>
    <header withdistance="false">
    </header>
    <pagebody>
        <itr>
            <combodyn2 valueprop="combo1" validvaluesprop="combo1Vals" flush="server">
            </combodyn2>
            <hdist>
            </hdist>
            <combodyn2 valueprop="combo2" validvaluesprop="combo2Values">
            </combodyn2>
        </itr>
    </pagebody>
    <statusbar withdistance="false">
    </statusbar>
</page>

Adapter Code:

package test;

import com.softwareag.cis.server.Adapter;
import com.softwareag.cis.server.util.COMBODYNValidValues;

public class ADPTest extends Adapter {
	private String m_combo1;

	private String m_combo2;

	public String getCombo1() {
		return m_combo1;
	}

	public void setCombo1(String value) {
		m_combo1 = value;
		refreshCombo2Values();
	}

	private COMBODYNValidValues m_combo1Vals = new COMBODYNValidValues();

	public COMBODYNValidValues getCombo1Vals() {
		return m_combo1Vals;
	}

	public String getCombo2() {
		return m_combo2;
	}

	public void setCombo2(String value) {
		m_combo2 = value;
	}

	private COMBODYNValidValues m_combo2Values = new COMBODYNValidValues();

	public COMBODYNValidValues getCombo2Values() {
		return m_combo2Values;
	}

	@Override
	public void init() {
		getCombo1Vals().addValidValue("1", "combo1-val1");
		getCombo1Vals().addValidValue("2", "combo1-val2");
	}

	private void refreshCombo2Values(){
		setCombo2("");
		m_combo2Values.clear();
		if (getCombo1().equals("1")){
			m_combo2Values.addValidValue("1", "Val1-Option1");
			m_combo2Values.addValidValue("2", "Val1-Option2");
		}else{
			m_combo2Values.addValidValue("1", "Val2-Option1");
			m_combo2Values.addValidValue("2", "Val2-Option2");
			m_combo2Values.addValidValue("3", "Val2-Option3");
			m_combo2Values.addValidValue("4", "Val2-Option4");
			m_combo2Values.addValidValue("5", "Val2-Option5");
		}
	}
}

Thanks

Hi Serhat,

this is by intention, not by error. In Mozilla an item is only displayed if it is part of the list of available items. As consequence we artificially create one if missing.

Thanks for your example.

Bjoern