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

Reply via email to