Filtered SQLContainer - addItem

Hi Folks,

got a question:
i want to use a SQLContainer which has an added equals filter, and add new items to it. this results in an error.

in detail: i’ve got a table which holds strings, and this strings are seperated in two groups 0 and 1, stored via an extra field “POSITION” (its pre and postfixes). so it looks like:
1 - pre1 - 0 - 0
2 - pre2 - 0 - 0
3 - post1 - 1 - 0

when adding a new record via addItem, it fails, because the newly created ID falls out of the search pattern and therefore it ends in an nullpointerexception.
i tryed overruling this by creating my own container, where i

  • remove all active filtering before adding
  • get the newly added item from the whole, unfiltered container
  • add the filtering again
  • alter the returned item
public class TitleContainer extends SQLContainer {
	private int iFilterType;	//0 or1

	public TitleContainer(QueryDelegate delegate, int aFilterType) throws SQLException {
		this.iFilterType = aFilterType;
	public Property getContainerProperty(Object itemId, Object propertyId) {
		Property lTempProperty = super.getContainerProperty(itemId, propertyId);
		addContainerFilter(new Equal("POSITION", iFilterType));
		return lTempProperty;

this works quite well for adding new items, but here is the next (unfortunately unsolved) problem:
when binding this container to a ComboBox and using it on a Form, the ValueChanges are not captured.
The Combos (2 different, one for group 0, one for group 1) show the right values and when there is already data in the DB this is also correctly pre-selected, only when i select another value of the (correct - all items that should appear are there!!) list, i dont get any event, telling me a ValueChange has happened…

anyone got an idea where the problem could be found?

From my Form:

		iCmbTitlePre.addListener(new Property.ValueChangeListener() {
			public void valueChange( event) {
				System.out.println("Selection from iCmbTitlePre: " + event.getProperty());

has anyone got an idea of what im doing wrong? or is the whole setting crap? with two different tables it would be no problem… but i’d like to know, why it doesn’t work :wink:

best regards an thanks in advance

Not sure I quite follow so don’t know if this is valid advice or not.

I do know if you have a filtered SQLContainer and add an item to it you need to use the “getItemUnfiltered(Object itemId)” instead of the “getItem(Object itemId)” before it’s committed.

Hope that might help