Issue 301: Error adding rows to the table
Status:  Invalid
Owner: ----
Closed:  Mar 2011
Reported by mikel.ma...@gmail.com, Feb 3, 2011
-----What steps will reproduce the problem?-----

1. Trying to add the plus icon on the table
2. Adding in web xml:

     <context-param>
        <param-name>jmesaMessagesLocation</param-name>
        <param-value>org/jmesaweb/resource/jmesaResourceBundle</param-value>
     </context-param>

     <context-param>
	<param-name>jmesaPreferencesLocation</param-name>
	<param-value>WEB-INF/jmesa.properties</param-value>
     </context-param>
	
3. In the action:
        
        ForbesData Fb = new ForbesData();
        forbesList = Fb.loadData();
        TableModel tableModel = null;
        tableModel = new TableModel("tag", request, response);
        tableModel.setItems(forbesList);
        tableModel.setExportTypes(ExportType.EXCEL, ExportType.PDF);
        
        HtmlToolbar toolBar = new HtmlToolbar();
        toolBar.addToolbarItem(ToolbarItemType.ADD_WORKSHEET_ROW_ITEM);
        
        HtmlTable table = new HtmlTable().caption("TablaNoticias");
        HtmlRow row = new HtmlRow();
        table.setRow(row);
        HtmlColumn uno = new HtmlColumn("name").title("Noticia");
        row.addColumn(uno);
        HtmlColumn dos = new HtmlColumn("age").title("Link");
        row.addColumn(dos);
        
        tableModel.setTable(table);
        tableModel.setToolbar(toolBar);
        String htmlCode = tableModel.render();
        
        request.setAttribute("htmlCode", htmlCode);

4.  In the properties:

     html.table.component.theme=jmesa
     html.table.renderer.styleClass=table
 
     html.row.renderer.highlightClass=highlight
     html.row.renderer.evenClass=even
     html.row.renderer.oddClass=odd
 
     html.column.header.renderer.image.sortAsc=sortAsc.gif
     html.column.header.renderer.image.sortDesc=sortDesc.gif
     html.column.filter.renderer.image.droplistHandle=droplistHandle.gif

     html.tbodyClass=tbody
     html.titleClass=title
     html.filterClass=filter
     html.headerClass=header
     html.toolbarClass=toolbar
     html.statusBarClass=statusBar
     html.imagesPath=../images/png/
     html.imagesUrl=../images/png/
     html.rowcount.includePagination=false
     html.toolbar.addWorksheetRow.enabled=true
     html.toolbar.maxRowsDroplist.increments=15,50,100
 
     html.toolbar.image.csv=csv.png
     html.toolbar.image.pdf=pdf.gif
     html.toolbar.image.excel=excel.gif
     html.toolbar.image.clear=clear.png
     html.toolbar.image.firstPage=firstPage.png
     html.toolbar.image.firstPageDisabled=firstPageDisabled.png
     html.toolbar.image.lastPage=lastPage.png
     html.toolbar.image.lastPageDisabled=lastPageDisabled.png
     html.toolbar.image.nextPage=nextPage.png
     html.toolbar.image.nextPageDisabled=nextPageDisabled.png
     html.toolbar.image.prevPage=prevPage.png
     html.toolbar.image.prevPageDisabled=prevPageDisabled.png
     html.toolbar.image.filter=filter.png
     html.toolbar.image.separator=separator.gif
     html.toolbar.image.addWorksheetRow=addWorksheetRow.png
     html.toolbar.image.clearWorksheet=clearWorksheet.png
     html.worksheet.image.removeWorksheetRow=removeWorksheetRow.png
     html.worksheet.image.undoRemoveWorksheetRow=undoRemoveWorksheetRow.png

     pdf.cssLocation=/css/jmesa-pdf.css


-----What is the expected output? What do you see instead?-----

A table with the "plus" icon, to add rows.

-----What version of the product are you using? On what operating system?-----

jmesa-3.0.3.jar


-----Please provide any additional information below.-----

I´m using Struts2 Framework, in the action I do the following:
I have achieved to show a normal table, with export, but when I add these three lines for adding rows to the normal table, it does not work:

        .....
        HtmlToolbar toolBar = new HtmlToolbar();
        toolBar.addToolbarItem(ToolbarItemType.ADD_WORKSHEET_ROW_ITEM);
        .....
        tableModel.setToolbar(toolBar);

I got the following error:

java.lang.NullPointerException
	org.jmesa.view.html.HtmlUtils.imagesPath(HtmlUtils.java:112)
	org.jmesa.view.html.toolbar.ToolbarItemFactory.<init>(ToolbarItemFactory.java:36)
	org.jmesa.view.html.toolbar.Toolbar.getToolbarItemFactory(Toolbar.java:40)
	org.jmesa.view.html.toolbar.Toolbar.addToolbarItem(Toolbar.java:61)
	iso3.pt.jMesaAPI.execute(jMesaAPI.java:34)


I think the CoreContext is null, i dont know why!!! What am i doing wrong?

Thanks a lot!

Feb 3, 2011
Project Member #1 jeff.johnston.mn@gmail.com
There are a few things wrong in this example. Did you get a chance to read the tutorial on the worksheet? If not I would just ask that you start there.

https://code.google.com/p/jmesa/wiki/WorksheetTutorialV3
https://code.google.com/p/jmesa/wiki/WorksheetAddRemoveValidateRowsV3

Then aside from that, if you want to include your own preferences file you only have to have the properties in there that you want to overwrite. So in your case the only property that you need to have to enable the add row feature is this:

html.toolbar.addWorksheetRow.enabled=true

For your toolbar you need to extend the abstract toolbar and add the items you want. 

https://code.google.com/p/jmesa/wiki/CustomToolbarTutorial

But in your case you really only need to add that property unless you have some other reason for a custom toolbar.

So, see if this helps and let me know if you still have questions.

-Jeff Johnston





Mar 9, 2011
Project Member #2 jeff.johnston.mn@gmail.com
(No comment was entered for this change.)
Status: Invalid