1>Thanks Chris, but I dont understand why,when and where should I call this createSimplepager();
2>And If it gets called all by itself can you please help me understand how do I add that newly created instance if SimplePager to a VerticalPanel. As i want to add the simplePager to the south of my Docklayoutpanel, which I do by adding the SimplePager instance to a vertical panel. 3>In brief I want to further use the newly created instance of SimplePager, but I didnt found how to do it. On Sun, Oct 9, 2011 at 4:12 AM, chris <chris.hins...@gmail.com> wrote: > I ran into the same problem today and can tell you that it is most > likely the @UiField(provided=true) annotation. I think I see your > problem and you are creating another SimplePager in your constructor > and it is not being assigned to pager1. This is what is giving you the > null pointer exception. I would recommed using the @UiFactory > annotation on a function to create your objects, then you do not need > the provided=true in you @Uifield. It really doesn't matter which > syntax you use but I like to keep my constructors pretty simple. Hope > that helps. > > @UiFactory > SimplePager createSimplePager() { > SimplePager simplePager = new SimplePager(); > simplePager = new SimplePager(TextLocation.RIGHT); > simplePager.setPageSize(10); > simplePager.setRangeLimited(true); > return simplePager; > } > > > > > On Oct 5, 12:52 am, Karzai <kapil2ka...@gmail.com> wrote: > > Hi I m getting the following error can anyone please help me in > > resolving and getting a proper pagination flow, on clicking of the > > paginate icon. below is the code I have been trying to use and the > > exception I'm getting : > > > > Exception : > > =========== > > > > 11:17:33.939 [ERROR] [myapps] Unable to load module entry point class > > com.apps.app1.client.Myapps (see associated exception for details) > > > > java.lang.NullPointerException: null > > at > > > com.google.gwt.user.client.ui.HTMLPanel.addAndReplaceElement(HTMLPanel.java:197) > > at > > > com.apps.app1.client.GridData_GridDataUiBinderImpl.createAndBindUi(GridData_GridDataUiBinderImpl.java: > > 37) > > at > > > com.apps.app1.client.GridData_GridDataUiBinderImpl.createAndBindUi(GridData_GridDataUiBinderImpl.java: > > 1) > > at com.apps.app1.client.GridData.<init>(GridData.java:61) > > at com.apps.app1.client.Myapps.onModuleLoad(Myapps.java:14) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: > > 39) > > at > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: > > 25) > > at java.lang.reflect.Method.invoke(Method.java:597) > > at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java: > > 396) > > at > > > com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java: > > 200) > > at > > > com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java: > > 525) > > at > > > com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java: > > 363) > > at java.lang.Thread.run(Thread.java:619) > > > > The GridData.java file > > ================== > > > > package com.apps.app1.client; > > > > import java.util.ArrayList; > > import java.util.Comparator; > > import java.util.Date; > > import java.util.List; > > > > import com.apps.app1.client.Contact.Category; > > import com.google.gwt.cell.client.CheckboxCell; > > import com.google.gwt.cell.client.DateCell; > > import com.google.gwt.cell.client.EditTextCell; > > import com.google.gwt.cell.client.FieldUpdater; > > import com.google.gwt.cell.client.NumberCell; > > import com.google.gwt.cell.client.SelectionCell; > > import com.google.gwt.core.client.GWT; > > import com.google.gwt.dom.client.Style.Unit; > > import com.google.gwt.event.dom.client.ClickEvent; > > import com.google.gwt.event.dom.client.ClickHandler; > > import com.google.gwt.safehtml.shared.SafeHtmlUtils; > > import com.google.gwt.uibinder.client.UiBinder; > > import com.google.gwt.uibinder.client.UiField; > > import com.google.gwt.user.cellview.client.Column; > > import com.google.gwt.user.cellview.client.DataGrid; > > import com.google.gwt.user.cellview.client.Header; > > import com.google.gwt.user.cellview.client.SafeHtmlHeader; > > import com.google.gwt.user.cellview.client.SimplePager; > > import com.google.gwt.user.cellview.client.TextColumn; > > import > > com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler; > > import > > > com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy; > > import com.google.gwt.user.cellview.client.SimplePager.TextLocation; > > import com.google.gwt.user.client.ui.Button; > > import com.google.gwt.user.client.ui.Composite; > > import com.google.gwt.user.client.ui.DialogBox; > > import com.google.gwt.user.client.ui.VerticalPanel; > > import com.google.gwt.user.client.ui.Widget; > > import com.google.gwt.view.client.ListDataProvider; > > import com.google.gwt.view.client.SelectionChangeEvent; > > import com.google.gwt.view.client.SingleSelectionModel; > > > > public class GridData extends Composite { > > > > private static GridDataUiBinder uiBinder = GWT > > .create(GridDataUiBinder.class); > > > > interface GridDataUiBinder extends UiBinder<Widget, GridData> { > > } > > > > @UiField(provided = true) > > DataGrid<Contact> table; > > @UiField(provided = true) > > SimplePager pager1; > > > > public GridData() { > > > > table = new DataGrid<Contact>(); > > SimplePager.Resources pagerResources = > > GWT.create(SimplePager.Resources.class); > > SimplePager pager1 = new SimplePager(TextLocation.CENTER, > > pagerResources, false, 0, true); > > pager1.setDisplay(table); > > initWidget(uiBinder.createAndBindUi(this)); > > > table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); > > /*DockLayoutPanel mainPanel = new > DockLayoutPanel(Unit.EM); > > VerticalPanel panel = new VerticalPanel(); > > panel.setBorderWidth(5); > > panel.setTitle("North"); > > VerticalPanel panel1 = new VerticalPanel(); > > panel.setBorderWidth(5); > > panel1.setTitle("East"); > > VerticalPanel panel2 = new VerticalPanel(); > > panel.setBorderWidth(5); > > panel2.setTitle("West"); > > VerticalPanel panel3 = new VerticalPanel(); > > panel.setBorderWidth(5); > > panel2.setTitle("South"); > > > > mainPanel.insertNorth(panel, 10.0, null); > > mainPanel.insertWest(panel1, 10.0, null); > > mainPanel.insertEast(panel2, 10.0, null); > > */ > > > > table.setWidth("100%"); > > final ListDataProvider<Contact> dataProvider = new > > ListDataProvider<Contact>(); > > dataProvider.addDataDisplay(table); > > > > String[] categoryArray = new String[] > > {"Jack","Ron","Hermaine","Harry","Voldermort"}; > > final Category[] categories = new > Category[categoryArray.length]; > > for(int i = 0 ; i< categoryArray.length; i++) > > { > > categories[i] = new Category(categoryArray[i]); > > } > > List<Contact> CONTACTS = dataProvider.getList(); > > Contact contact = new Contact(); > > CONTACTS = contact.getContacts(); > > > > Column<Contact, Number> ageColumn = new Column<Contact, > Number>(new > > NumberCell()) { > > > > @Override > > public Integer getValue(Contact object) { > > // TODO Auto-generated method stub > > return object.age; > > } > > }; > > > > List<String> categoryName = new ArrayList<String>(); > > for(Category category : categories){ > > > > categoryName.add(category.getDisplayName()); > > } > > SelectionCell selectionCell = new > SelectionCell(categoryName); > > Column<Contact, String> categoryColumn = new > Column<Contact, > > String>(selectionCell) { > > > > @Override > > public String getValue(Contact object) { > > // TODO Auto-generated method stub > > return object.category.getDisplayName(); > > } > > }; > > table.setColumnWidth(categoryColumn, 40.0, Unit.PX); > > table.addColumn(categoryColumn, "category", "Category"); > > Header<String> ageFooter = new Header<String>(new > EditTextCell()) { > > @Override > > public String getValue() { > > List<Contact> items = > table.getVisibleItems(); > > if (items.size() == 0) { > > return ""; > > } else { > > int totalAge = 0; > > for (Contact item : items) { > > totalAge += item.age; > > } > > return "Avg: " + totalAge / > items.size(); > > } > > } > > }; > > table.setColumnWidth(ageColumn, 40.0, Unit.PX); > > table.addColumn(ageColumn, new > > SafeHtmlHeader(SafeHtmlUtils.fromSafeConstant("Age")), ageFooter); > > > > ListHandler<Contact> sortHandler = new > > ListHandler<Contact>(dataProvider.getList()); > > table.addColumnSortHandler(sortHandler); > > > > Column<Contact, String> nameColumn = new Column<Contact, > String>(new > > EditTextCell()) { > > > > @Override > > public String getValue(Contact object) { > > // TODO Auto-generated method stub > > return object.name; > > } > > }; > > nameColumn.setSortable(true); > > sortHandler.setComparator(nameColumn, new > Comparator<Contact>() { > > public int compare(Contact o1, Contact o2) { > > return -((o1.name).compareTo(o2.name)); > > } > > }); > > > > table.addColumn(nameColumn, "Name", "Name"); > > nameColumn.setFieldUpdater(new FieldUpdater<Contact, > String>() { > > > > @Override > > public void update(int index, Contact object, > String value) { > > // TODO Auto-generated method stub > > object.name = value; > > dataProvider.refresh(); > > } > > }); > > table.setColumnWidth(nameColumn, 60.0, Unit.PX); > > TextColumn<Contact> addressColumn = new > TextColumn<Contact>() { > > > > @Override > > public String getValue(Contact object) { > > // TODO Auto-generated method stub > > return object.address; > > } > > }; > > addressColumn.setSortable(true); > > addressColumn.setFieldUpdater(new FieldUpdater<Contact, > String>() { > > > > @Override > > public void update(int index, Contact object, > String value) { > > // TODO Auto-generated method stub > > object.address = value; > > dataProvider.refresh(); > > } > > }); > > table.setColumnWidth(addressColumn, 70.0, Unit.PX); > > table.addColumn(addressColumn, "Address", "Address"); > > > > DateCell dateCell = new DateCell(); > > Column<Contact, Date> dateColumn = new Column<Contact, > > Date>(dateCell) { > > > > @Override > > public Date getValue(Contact object) { > > // TODO Auto-generated method stub > > return object.birthday; > > > > } > > }; > > table.setColumnWidth(dateColumn, 40.0, Unit.PX); > > table.addColumn(dateColumn, "Date", "Birthday"); > > /*final SelectionModel<Contact> selectionModel12 = new > > MultiSelectionModel<Contact>(); > > table.setSelectionModel(selectionModel12, > > DefaultSelectionEventManager.<Contact>createCheckboxManager());*/ > > final SingleSelectionModel<Contact> selectionModel1 > = new > > SingleSelectionModel<Contact>(); > > table.setSelectionModel(selectionModel1); > > selectionModel1.addSelectionChangeHandler(new > > SelectionChangeEvent.Handler() { > > @Override > > public void > onSelectionChange(SelectionChangeEvent event) { > > // TODO Auto-generated method stub > > Contact selected = > selectionModel1.getSelectedObject(); > > if(selected != null) > > { > > final DialogBox box = new > DialogBox(); > > box.setAnimationEnabled(true); > > box.setHTML(selected.name); > > box.setText(selected.name); > > VerticalPanel w = new > VerticalPanel(); > > //w.setSize("5px", "10px"); > > w.setBorderWidth(1); > > /*Image image = new > Image("D:\\checkout1\\rocro-modularization\ > > \rocro-web\\rocro-entrypoint\\target\\rocro-entrypoint\ > > \com.subex.rocro.web.app.ROCroApplication\\resources\\common\\icons\ > > \ol_close.png"); > > image.addClickHandler(new > ClickHandler() { > > > > @Override > > public void > onClick(ClickEvent event) { > > // TODO > Auto-generated method stub > > box.hide(); > > } > > }); > > image.setSize("50px", "30px"); > > w.add(image)*/ > > w.add(new Button("Close IT", new > ClickHandler() { > > > > @Override > > public void > onClick(ClickEvent event) { > > // TODO > Auto-generated method stub > > box.hide(); > > } > > })); > > w.setTitle(selected.name); > > box.setPopupPosition(350, 100); > > box.add(w); > > box.show(); > > } > > } > > }); > > Column<Contact, Boolean> checkColumn = new > Column<Contact, > > Boolean>(new CheckboxCell(true, false)) { > > > > @Override > > public Boolean getValue(Contact object) { > > > > return > selectionModel1.isSelected(object); > > } > > }; > > table.addColumn(checkColumn, > SafeHtmlUtils.fromSafeConstant("<br/>")); > > > > table.setColumnWidth(checkColumn, 40, Unit.PX); > > table.setVisibleRange(0, 13); > > table.setRowCount(CONTACTS.size(), true); > > table.setRowData(0, CONTACTS); > > /*mainPanel.insertSouth(pager, 10.0, null); > > VerticalPanel panel4 = new VerticalPanel(); > > panel4.add(table); > > panel4.add(pager); > > mainPanel.add(table); */ > > /*RootLayoutPanel.get().add(mainPanel);*/ > > > > } > > > > } > > > > the GridData.ui.xml file > > =================== > > > > <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> > > <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" > > xmlns:g="urn:import:com.google.gwt.user.client.ui" > > xmlns:c="urn:import:com.google.gwt.user.cellview.client"> > > > > <g:DockLayoutPanel > > unit="EM"> > > <!-- DataGrid. --> > > <g:center> > > <c:DataGrid > > ui:field="table" /> > > </g:center> > > > > <!-- Pager. --> > > <g:south > > size="3"> > > <g:HTMLPanel> > > <table > > style="width:100%"> > > <tr> > > <td > > align='center'> > > <c:SimplePager ui:field="pager1"/> > > </td> > > </tr> > > </table> > > </g:HTMLPanel> > > </g:south> > > </g:DockLayoutPanel> > > </ui:UiBinder> > > > > the Myapps.java file > > =================== > > > > package com.apps.app1.client; > > > > import com.google.gwt.core.client.EntryPoint; > > import com.google.gwt.user.client.ui.RootLayoutPanel; > > > > /** > > * Entry point classes define <code>onModuleLoad()</code>. > > */ > > public class Myapps implements EntryPoint { > > > > @Override > > public void onModuleLoad() { > > GridData data = new GridData(); > > RootLayoutPanel.get().add(data); > > } > > > > } > > > > Please help me out in getting the a proper solution for it. > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to google-web-toolkit@googlegroups.com. > To unsubscribe from this group, send email to > google-web-toolkit+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.