PerShing2014 / jmesa

Automatically exported from code.google.com/p/jmesa
0 stars 0 forks source link

Error adding rows to the table #301

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
-----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!

Original issue reported on code.google.com by mikel.ma...@gmail.com on 3 Feb 2011 at 11:29

GoogleCodeExporter commented 8 years ago
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.

http://code.google.com/p/jmesa/wiki/WorksheetTutorialV3
http://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. 

http://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

Original comment by jeff.johnston.mn@gmail.com on 3 Feb 2011 at 7:47

GoogleCodeExporter commented 8 years ago

Original comment by jeff.johnston.mn@gmail.com on 9 Mar 2011 at 7:26