# Dynamic Combo clear method

**URL:** <https://techcommunity.softwareag.com/t/dynamic-combo-clear-method/57192>\
**Category:** Forum\
**Tags:** Former-Crossvision-Products, Application-Composer\
**Created:** [February 10, 2006, 3:02pm UTC](https://techcommunity.softwareag.com/t/dynamic-combo-clear-method/57192 "2006-02-10T15:02:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serhat](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Serhat](https://techcommunity.softwareag.com/u/Serhat)\
**Post date:** [February 10, 2006, 3:02pm UTC](https://techcommunity.softwareag.com/t/dynamic-combo-clear-method/57192/1 "2006-02-10T15:02:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Bjoern\_Mueller](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Bjoern\_Mueller](https://techcommunity.softwareag.com/u/Bjoern_Mueller)\
**Post date:** [February 10, 2006, 3:47pm UTC](https://techcommunity.softwareag.com/t/dynamic-combo-clear-method/57192/2 "2006-02-10T15:47:46Z")

</div>

…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

---

<div class="post-metadata">

**Author:** ![Serhat](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Serhat](https://techcommunity.softwareag.com/u/Serhat)\
**Post date:** [February 10, 2006, 4:01pm UTC](https://techcommunity.softwareag.com/t/dynamic-combo-clear-method/57192/3 "2006-02-10T16:01:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bjoern\_Mueller](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Bjoern\_Mueller](https://techcommunity.softwareag.com/u/Bjoern_Mueller)\
**Post date:** [February 10, 2006, 4:17pm UTC](https://techcommunity.softwareag.com/t/dynamic-combo-clear-method/57192/4 "2006-02-10T16:17:55Z")

</div>

…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

---

<div class="post-metadata">

**Author:** ![Serhat](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Serhat](https://techcommunity.softwareag.com/u/Serhat)\
**Post date:** [February 10, 2006, 5:36pm UTC](https://techcommunity.softwareag.com/t/dynamic-combo-clear-method/57192/5 "2006-02-10T17:36:17Z")

</div>

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

```auto
<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:

```auto
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

---

<div class="post-metadata">

**Author:** ![Bjoern\_Mueller](https://avatars.discourse-cdn.com/v4/letter/b/e9bcb4/32.png) [@Bjoern\_Mueller](https://techcommunity.softwareag.com/u/Bjoern_Mueller)\
**Post date:** [February 15, 2006, 4:35pm UTC](https://techcommunity.softwareag.com/t/dynamic-combo-clear-method/57192/6 "2006-02-15T16:35:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:38pm UTC](https://techcommunity.softwareag.com/t/dynamic-combo-clear-method/57192/7 "2021-04-02T14:38:28Z")

</div>

Closed on April 2, 2021, 2:38pm UTC


