Hmm I have something similar, though not getting npe (from 1.3 project) :


/**
 *
 *
 */
public class SortableSearchDataProvider extends SortableDataProvider {

        private SearchParameters searchParameters;
        /**
         * constructor
         */
        public SortableSearchDataProvider(SearchParameters searchParameters) {
                this.searchParameters=searchParameters;
                // set default sort
                setSort("alias", true);
                InjectorHolder.getInjector().inject(this);
        }

        @SpringBean
        private IDBDao dbDao;

        protected IDBDao getDao() {
                return dbDao;
        }

        /**
         * @see 
org.apache.wicket.markup.repeater.data.IDataProvider#iterator(int,
         *      int)
         */
        public Iterator iterator(int first, int count) {
                SortParam sp = getSort();
                return getDao().searchForSchemes(first, count, sp.getProperty(),
                                sp.isAscending(),searchParameters)
                                .iterator();
        }

        /**
         * @see org.apache.wicket.markup.repeater.data.IDataProvider#size()
         */
        public int size() {
                return getDao().searchForSchemesCount(searchParameters);
        }

        /**
         * @see 
org.apache.wicket.markup.repeater.data.IDataProvider#model(java.lang.Object)
         */
        public IModel model(Object object) {
                return new BaseEntityDetachableModel((Person) object);
        }

}


2009/4/29 HHB <hubaghd...@yahoo.ca>:
>
> Actually, thats what I'm doing (you can check my code).
> The NPE is regarding the Group object instance, not Spring bean.
>
>
> Willis Blackburn wrote:
>>
>> Hi,
>>
>> The @SpringBean annotation is only resolved by Component and its
>> subclasses.  (Actually it's resolved by SpringComponentInjector--but
>> that only works with components.)
>>
>> You can call InjectorHolder.getInjector().inject(whatever) to resolve
>> @SpringBean annotations in the whatever object.
>>
>> W
>>
>>
>>
>> On Apr 29, 2009, at 6:38 AM, HHB wrote:
>>
>>> Hey,
>>> I'm trying to employ DataTable in our application.
>>> *************************
>>> public class SortableContactDataProvider
>>>    extends SortableDataProvider {
>>>
>>>   �...@springbean
>>>    private Service service;
>>>
>>>    private Group group;
>>>
>>>    public SortableContactDataProvider(Group group) {
>>>        if (group == null)
>>>          throw new IllegalStateException("Group is null");
>>>        InjectorHolder.getInjector().inject(this);
>>>        setSort("gsm", true);
>>>        this.group = group;
>>>    }
>>>
>>>    public Iterator iterator(int first, int max) {
>>>        return service.list(group, first, max,
>>>                getSort().getProperty(),
>>>                getSort().isAscending()).iterator();
>>>    }
>>>
>>>    public int size() {
>>>        return service.listContactsSize(group);
>>>    }
>>>
>>>    public IModel model(Object object) {
>>>        Contact contact = (Contact) object;
>>>        return new DomainEntityModel<Contact>
>>>           (Contact.class, contact.getId());
>>>    }
>>>
>>>    public void setGroup(Group group) {
>>>        if (group == null)
>>>           throw new IllegalStateException("Group is null");
>>>        this.group = group;
>>>    }
>>>
>>> }
>>> *************************
>>> And I use it this way (inside the panel constructor):
>>> *************************
>>> Group group = new Group();group.setId(1L);
>>> SortableContactDataProvider scdp = new
>>>   SortableContactDataProvider(group);
>>>        scdp.setGroup(group);
>>> final List<IColumn> columns = new ArrayList<IColumn>();
>>> columns.add(new PropertyColumn(new Model("GSM"), "gsm", "gsm"));
>>> AjaxFallbackDefaultDataTable contacts = new
>>>    AjaxFallbackDefaultDataTable("table", columns, scdp, 10);
>>> final WebMarkupContainer wmc = new
>>> WebMarkupContainer("contactsTable");
>>> wmc.setOutputMarkupId(true);
>>> wmc.add(contacts);
>>> add(wmc);
>>> *************************
>>> When running the application, I got NullPointerException
>>> from the method size() of the provider, the group object is null.
>>> Why the object is null?
>>> and if it is null, why IllegalStateException is not being thrown?
>>> I'm using Wicket 1.3.5
>>> Thanks for help.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/Why-I%27m-getting-NPE--tp23294732p23295098.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to