Click
  1. Click
  2. CLK-124

NPE Table - ActionLink pagination

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      If you define the Table control as public, Click will automatically add this Control. So it will call table.setContext() .

      The table.setContext() should set the Context in the "pageLink" control.

      But at this time, the page Link is null, because we don't called the table.setPageSize() method.

      So, this code throws a NPE. A possible fix for this, is change the setPageSize to also set the context in the ActionLink control.

      ---------------------------------------------------
      public class PersonTablePage extends BasePage {

      public Table table = new Table("table");

      public PersonTablePage()

      { table.setAttribute("class","simple"); table.addColumn(new Column("id")); table.addColumn(new Column("name")); table.addColumn(new Column("email")); table.addColumn(new Column("birthday")); //It works here // table.setPageSize(3); }

      public void onInit()

      { //This will throw a NPE table.setPageSize(3); }

      public void onGet()

      { table.setRowList(getPersonService().getAll()); }

      }

        Activity

        Hide
        Malcolm Edgar added a comment -

        Hi Richardo,

        I think this issue has been resolved in the RC1 or RC2 release. Would you be able to confirm this before I close this?

        regards Malcolm Edgar

        Show
        Malcolm Edgar added a comment - Hi Richardo, I think this issue has been resolved in the RC1 or RC2 release. Would you be able to confirm this before I close this? regards Malcolm Edgar
        Hide
        Ricardo Lecheta added a comment -

        Hi

        I tested it, and I think this issue is not resolved. "click-1.0-rc2"

        The getContext() is null for the ActionLink control.

        ------------------------------------------------
        java.lang.NullPointerException
        at net.sf.click.control.ActionLink.onProcess(ActionLink.java:435)
        at net.sf.click.control.Table.onProcess(Table.java:789)
        at net.sf.click.ClickServlet.processPage(ClickServlet.java:471)
        ------------------------------------------------

        regards,

        Ricardo

        Show
        Ricardo Lecheta added a comment - Hi I tested it, and I think this issue is not resolved. "click-1.0-rc2" The getContext() is null for the ActionLink control. ------------------------------------------------ java.lang.NullPointerException at net.sf.click.control.ActionLink.onProcess(ActionLink.java:435) at net.sf.click.control.Table.onProcess(Table.java:789) at net.sf.click.ClickServlet.processPage(ClickServlet.java:471) ------------------------------------------------ regards, Ricardo
        Hide
        Ricardo Lecheta added a comment -

        The Table.setPageSize method create a new ActionLink instance. But it doesn't set the context for the ActionLink.

        A simple solution for this could be:

        public void setPageSize(int pageSize) {
        this.pageSize = pageSize;

        if (pageSize > 0) {
        pagingLink = new ActionLink(PAGING);
        if (pageSize.getContext() == null)

        { pagingLink.setContext(getContext()); }

        pagingLink.setListener(this, "onPagingClick");
        }
        }

        Show
        Ricardo Lecheta added a comment - The Table.setPageSize method create a new ActionLink instance. But it doesn't set the context for the ActionLink. A simple solution for this could be: public void setPageSize(int pageSize) { this.pageSize = pageSize; if (pageSize > 0) { pagingLink = new ActionLink(PAGING); if (pageSize.getContext() == null) { pagingLink.setContext(getContext()); } pagingLink.setListener(this, "onPagingClick"); } }
        Hide
        Malcolm Edgar added a comment -

        Bug present in version 1.0 RC2

        Show
        Malcolm Edgar added a comment - Bug present in version 1.0 RC2
        Hide
        Malcolm Edgar added a comment -

        Fixed checked into SVN, will be available in version 1.0

        Show
        Malcolm Edgar added a comment - Fixed checked into SVN, will be available in version 1.0

          People

          • Assignee:
            Malcolm Edgar
            Reporter:
            Ricardo Lecheta
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development