Question about pagedtable

Hi! everyone, I have some problems with the pagedtable addon, I create a simple table that show some system event, but there are so many that I use the pagedtable, but when I try to filter the result, I need to remove the last results on the table, but when I use removeAllItems() method, this happen:


	if(this.getItemIds().size()>0){
    			this.removeAllItems();
    		}
    	    this.dsevent.reload((Date)startdate.getValue(), (Date)enddate.getValue() );   // this make a refresh of the data given two dates
    	    requestRepaint();
   ....
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
at com.jensjansson.pagedtable.PagedTableContainer.removeAllItems(PagedTableContainer.java:128)
    ...

I dont know whats going on there, another thing, this is more like a question, How I can give a default page height? I try to give a default pageLenght of 10 instead of the default 25, but it dosent take it, it still 25 results per page, why is that?


            tablePage.setSizeFull();
    	    tablePage.setContainerDataSource(this.dsevent);
    	    tablePage.setSelectable(true);
    	    tablePage.setPageLength(10);
    	    tablePage.setImmediate(true);

thanks for your help

That’s my bad. A few “delegate” methods called themselves instead of delegating them forward, which caused infinite loops. One of them was removeAllItems(). I have now fixed these and added a test for it in my test suite. 0.6.2 with this patch has now been released on
the Directory
. The internal container won’t probably notify the PagedTable about the change, and it won’t fire a PageChangeEvent so I suggest you call table.setCurrentPage(1) to update it correctly after removing and adding items.

About changing the page length. It works correctly in all my tests so far. Could you provide a isolated test case where setPageLength(10) doesn’t work as expected?

Hi! Thank you for your response!, I dont know if you see my last two post, but I think I put a lot of useless information, so I delete them, basically I summarize my problems with the paged table in this two points:


  1. First point
    , I test the new 0.6.2 pagedtable.jar, and was working fine :smiley: , but then I found some errors, some mines actually, but others I dont know what is going on, for some reason, the paged table is having problems calling some methods, telling me something inside is null, but dont says what, I trace it back to the page lenght, in this pieces of your code:

 itemsPerPageSelect.addListener(new ValueChangeListener() {
            private static final long serialVersionUID = -2255853716069800092L;

            public void valueChange(
                    com.vaadin.data.Property.ValueChangeEvent event) {
                setPageLength(Integer.valueOf(String.valueOf(event
                        .getProperty().getValue())));  // in here said this is null
            }
        });
        itemsPerPageSelect.select("25");  

I notice that this happen when I call setPageLenght(10) and when the controls of the table are being created(the code bellow show me the null problem):


		tableContainer = new VerticalLayout();
		itemList = new PagedTable("tabla paginada");
		dsevent = new EventosDataContainer();  // this is a indexed container
		dsevent.load((Date)startdate.getValue(), (Date)enddate.getValue());  //load the data
		dsevent.sort(new Object[] { "tfc" }, new boolean[]
 { false });  //sort the data 
		itemList.setContainerDataSource(dsevent);   //set the container to the pagedtable
		itemList.setPageLength(10); //when this is set, it gives me null when the itemList.createControls() is called.
		itemList.setImmediate(true);
		itemList.setSelectable(true);
		itemList.setAlwaysRecalculateColumnWidths(true);
		itemList.setNullSelectionAllowed(false);
		itemList.setWidth("100%");
		itemList.setVisibleColumns(new Object[] { "tfc", "modulo", "tipo", "mensaje" });
		itemList.setColumnHeaders(new String[] { "Hora", "Modulo", "Tipo", "Mensaje" });
		itemList.addGeneratedColumn("tipo", new Table.ColumnGenerator() {
			public Component generateCell(Table source, Object itemId,
					Object columnId) {
				
				EventoSistema  ev =  (EventoSistema) itemId;
				
			
				int idtipo = ev.getTipo();
				Embedded icono;
				switch (idtipo) {
				case 0:
					icono = getIcono(Evento.TIPO.AVISO);
					break;
				case 2:
					icono = getIcono(Evento.TIPO.ADVERTENCIA);
					break;
				case 1:
					icono = getIcono(Evento.TIPO.ERROR);
					break;
				case 3:
					icono = getIcono(Evento.TIPO.SISTEMA);
					break;
				default:
					icono = getIcono(Evento.TIPO.AVISO);
					break;
				}

				return icono;
			}
		});
		tableContainer.addComponent(itemList);
		tableContainer.addComponent(itemList.createControls());
		rootLayout.addComponent(tableContainer);

This code works, only if I remove the itemList.setPageLength(10) , this also happen if I call the same method after the controls are created, so Im very very confused.

pd. in my first attemp using the 0.6.2 version this didnt happend, the application was working just fine.

2.
the second point
is this, when the items on the page table are refreshed, the controls are not being updated, stays the same page results, you tell me to use the setCurrentPage(1), but I dont know If im using it right:


	        itemList.removeAllItems();
		dsevent.reload((Date) startdate.getValue(),(Date) enddate.getValue());	
		itemList.requestRepaintAll();
		itemList.setCurrentPage(1);

the only way to update the controls are to giving click manually on them…

Good Morning everyone!, I hope you all are ok!,

I have fixed some of the errors I describe above, but I dont know why the way I fix it works in that way, Lets go first to the 2nd point, (was the easiest):

to fix this, and to force the pagedtable to refresh the controls, I simple call the method ‘setContainerDataSource();’:


	public void refreshTable() { 			
			this.removeAllItems();  //remove the actual items on the pagedtable
			this.getDataContainer().reload((Date) startdate.getValue(),(Date) enddate.getValue());	  //reload the items on the datacontianer with new data.
			this.setContainerDataSource(this.getDataContainer());   //Force the refresh of the controls settings the datacontainer again
			this.setVisibleColumns(NATURAL_COL_ORDER);  //this apply to for the visible columns too, because the order of the columns are lost
			this.requestRepaintAll(); //request repaint
			this.setCurrentPage(1); // set the current page.
		}

For the first part of the errors I describe on my last post, well I still cant find how to fix it, but for some reason the error stop showing up, I just remade the code that initialize my pagedtable, but I still miss to find out whats the diference, between this code and the new one, there the same steps on the calling methods, so Im still confused, but now its working :wacko:


	public void initEventos() {
		simpleFormatDate = new SimpleDateFormat("dd-MMM-yyyy");
		startdate = new DateField("Fecha inicio:");
		enddate = new DateField("Fecha fin:");
		startdate.setDateFormat("yyyy-MM-dd");
		startdate.setValue(lastDay());
		enddate.setDateFormat("yyyy-MM-dd");
		enddate.setValue(this.getToday());
		tableContainer = new VerticalLayout();
		itemList = new EventList();	
		lblEventos = new Label();
		tableContainer.addComponent(itemList);
		tableContainer.addComponent(itemList.createControls());
		rootLayout.addComponent(lblEventos);
		rootLayout.setComponentAlignment(lblEventos, Alignment.MIDDLE_RIGHT);
		rootLayout.addComponent(tableContainer);
		lblEventos.setCaption("Eventos del dia "+ simpleFormatDate.format((Date)startdate.getValue())+" a "+ simpleFormatDate.format((Date)enddate.getValue()));
		filtrarWin = new FiltrarEventosWindow();
		itemList.setPageLength(10);  //here this works fine
	}

public class EventList extends PagedTable{
		EventosDataContainer dsevent;
		
		public EventList(){
			super();
			init();
		}
		
		public void init(){
			initDataContainer();
			this.getDataContainer().load((Date) startdate.getValue(),(Date) enddate.getValue());	
			this.getDataContainer().sort(new Object[] { "tfc" }, new boolean[]
 { false });
			this.setContainerDataSource(dsevent);
			this.setImmediate(true);
			this.setSelectable(true);
		//	this.setAlwaysRecalculateColumnWidths(true);
			this.setNullSelectionAllowed(false);
			this.setWidth("100%");
			this.setVisibleColumns(new Object[] { "tfc", "modulo", "tipo", "mensaje" });
			this.setColumnHeaders(new String[] { "Hora", "Modulo", "Tipo", "Mensaje" });
			this.addGeneratedColumn("tipo", new Table.ColumnGenerator() {
				public Component generateCell(Table source, Object itemId,
						Object columnId) {
					
					EventoSistema  ev =  (EventoSistema) itemId;
					Embedded icono = getIcono(Evento.TIPO.values()[ev.getTipo()]
);
					return icono;
				}
			});
		}
...
...
}

Hello,

I have a problem related to PagedTable.
The field which shows the current selected page is editable.
Why is this field editable?
If the number is just removed with backspace, I get NumberFormatException.
Also, if the if it is changed to some invalid number, I get NullPointerException.For example, there are 3 pages and some large number is entered.
How can we fix this at our end?
Is there a workaround for this?

Hi all!

I’ve been working my way through the Vaadin 7 Cookbook, but working it in Grails with the Vaadin plugin (for v. 2.5.0 of Grails, which is up to Vaadin 7.4.8).

So, I’m working in the PageTable, but so far I’m unable to compile it. Tried downloading the jar, also tried adding the dependency from maven and from your Ondrej’s github fork, as instructed in the book.

I always get:

Unable to find ‘com/jensjansson/pagedtable/PagedTable.gwt.xml’ on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

So I’m lost here, I followed the instructions as of “Widgetset compilation” in the Vaadin-on-Grails book, adding the widgetset.gwt.xml file to src/java/app/, it’s contents is

Any pointers are greatly appreciated.