Results 1 to 8 of 8

Thread: GXT [1.2.1] BUG Filtering ListStore with StoreFilterField gives an error

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default GXT [1.2.1] BUG Filtering ListStore with StoreFilterField gives an error

    Hi, i found the following issue in 1.2 upgraded to 1.2.1 and the problem persists.

    When i filter in the liststore it shows perfectly in the listview, if i try to filter also using the storefilterfield it gives me a nullpointerexpection, but only if i'm filtering in the liststore (and i need this to show different data depending on the type).

    This is my example, that i was testing.

    public class Teste10 extends VerticalPanel{
    private ListView<ModelTest> listview;
    private ListStore<ModelTest> store;
    private StoreFilterField<ModelTest> filter;

    public Teste10() {

    List<ModelTest> list = new ArrayList<ModelTest>();

    list.add(new ModelTest("A1","X1"));
    list.add(new ModelTest("B1","X1"));
    list.add(new ModelTest("C1","X1"));
    list.add(new ModelTest("D1","X1"));

    list.add(new ModelTest("A2","X2"));
    list.add(new ModelTest("B2","X2"));
    list.add(new ModelTest("C2","X2"));
    list.add(new ModelTest("D2","X2"));
    //---------------------------------
    listview = new ListView<ModelTest>();
    listview.setDisplayProperty("name");
    store = new ListStore<ModelTest>();
    store.setStoreSorter(new StoreSorter<ModelTest>());
    //order by name
    store.setSortField("name");
    store.add(list);
    //model has name and type fields
    store.filter("type", "X1");

    listview.setStore(store);

    filter = new StoreFilterField<ModelTest>()
    {

    @Override
    protected boolean doSelect(Store<ModelTest> store,
    ModelTest parent, ModelTest record, String property,
    String filter) {
    String name = record.get("name");

    name = name.toLowerCase();

    if (name.startsWith(filter.toLowerCase())) {
    return true;
    }
    return false;
    }

    };

    filter.bind(store);

    this.add(filter);
    this.add(listview);

    }

    //This is my model if you need it
    class ModelTest extends BaseModelData{
    public ModelTest(String name, String type) {
    setName(name);
    setType(type);
    }

    public String getName(){
    return get("name");
    }

    public String getType(){
    return get("type");
    }

    public void setName(String name){
    set("name", name);
    }

    public void setType(String type){
    set("type", type);
    }
    }
    }


    This is the error:

    [ERROR] Uncaught exception escaped
    java.lang.NullPointerException: null
    at com.extjs.gxt.ui.client.data.NestedModelUtil.isNestedProperty(NestedModelUtil.java:68)
    at com.extjs.gxt.ui.client.data.BaseModelData.get(BaseModelData.java:42)
    at com.extjs.gxt.ui.client.store.Store.applyFilters(Store.java:167)
    at com.extjs.gxt.ui.client.widget.StoreFilterField.applyFilters(StoreFilterField.java:89)
    at com.extjs.gxt.ui.client.widget.StoreFilterField.onFilter(StoreFilterField.java:97)
    at com.extjs.gxt.ui.client.widget.StoreFilterField.validateValue(StoreFilterField.java:115)
    at com.extjs.gxt.ui.client.widget.form.Field.validate(Field.java:768)
    at com.extjs.gxt.ui.client.widget.form.TextField$1.handleEvent(TextField.java:440)
    at com.extjs.gxt.ui.client.util.DelayedTask$1.run(DelayedTask.java:52)
    at com.google.gwt.user.client.Timer.fireImpl(Timer.java:164)
    at com.google.gwt.user.client.Timer.fireAndCatch(Timer.java:150)
    at com.google.gwt.user.client.Timer.fire(Timer.java:142)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
    at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
    at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
    at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
    at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
    at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
    at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)


    If this is not an BUG and I'm doing something wrong, please correct me.


    Cheers.

  2. #2

    Default

    I'm getting the same thing now in 2.0, except I'm trying to remove from a store.
    The code worked fine until I converted from a ListStore to a GroupingStore.

    Any solution?

  3. #3
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976

    Default

    I cant reproduce this with the latest GXT 2 release. There was a nullcheck added in some prior version and it cant throw a nullpointerexception anymore.

  4. #4

    Default

    I upgraded to 2.0.1 and I haven't been able to reproduce it either. Thanks!

  5. #5

    Default

    I believe I spoke too soon. I'm still having a similar problem with 2.0.1.
    If I group by columns, then ungroup, then update an item that is already in the store,
    I get the following exception:

    java.lang.NullPointerException
    at com.extjs.gxt.ui.client.data.NestedModelUtil.isNestedProperty(NestedModelUtil.java:71)
    at com.brit.gwt.api.BeanModel_com_brit_gwt_api_TestBean.get(transient source for com.brit.gwt.api.BeanModel_com_brit_gwt_api_TestBean:57)
    at com.extjs.gxt.ui.client.widget.grid.GroupingView.onRemove(GroupingView.java:408)
    at com.extjs.gxt.ui.client.widget.grid.GridView.refreshRow(GridView.java:1490)
    at com.extjs.gxt.ui.client.widget.grid.GroupingView.refreshRow(GroupingView.java:430)
    at com.extjs.gxt.ui.client.widget.grid.GridView.onUpdate(GridView.java:1453)
    at com.extjs.gxt.ui.client.widget.grid.GridView$5.storeUpdate(GridView.java:1209)
    at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:36)
    at com.extjs.gxt.ui.client.store.StoreListener.handleEvent(StoreListener.java:1)
    at com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:176)
    at com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:96)
    at com.extjs.gxt.ui.client.store.Store.update(Store.java:557)

    Grouping View contains this code:
    @Override
    protected void onRemove(ListStore<ModelData> ds, ModelData m, int index, boolean isUpdate) {
    super.onRemove(ds, m, index, isUpdate);
    String groupField = getGroupField();
    Element g = XDOM.getElementById(getGroupId(grid.getId(), groupField, getGroup(m.get(groupField), m, index,
    cm.findColumnIndex(groupField), ds)));
    if (g != null && !g.getChildNodes().getItem(1).hasChildNodes()) {
    fly(g).removeFromParent();
    }
    // appply empty text
    }

    The debugger shows that "groupField" is null, as I would expect since I've un-grouped.

    So we get an exception in isNestedProperty():

    public static boolean isNestedProperty(String property) {
    return property.indexOf(".") != -1;
    }

    Is it possible to add a null check?

  6. #6
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976

    Default

    isNestedProperty doesnt look like that in the latest release of 2. Please make sure which version you are really using.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •