You forgot to add the link controls to the Page class. You can use
addControl or Table.addControl(link).

Hth,

Gilberto

[1] 
http://click.apache.org/docs/click-api/org/apache/click/control/Column.html#Column%28java.lang.String,%20java.lang.String%29

On Tue, Mar 27, 2012 at 3:54 PM, Scott Gurney <[email protected]> wrote:
> Hi, all.
>
>
>
> I’m playing around with the Click Framework and have run into a problem that
> I can’t seem to solve, even though I’m sure it is entirely my fault.
>
> In a nutshell, I have a page with a form that contains a field set which in
> turn contains a table.  (It is similar to the AdvancedTable example but the
> table is in a FieldSet on a Form.)  The table has an associated data
> provider that gets data from a service that reads from a database.  When the
> database has data already, the table renders as I would expect.  However,
> when there is no data in the database, I get a
>  "java.lang.IllegalArgumentException: Null source parameter" instead of
> rendering "No records found."  (Full stack trace below.)
>
>
>
> The HTML is as follows:
>
> $form
>
>
>
> The Java code is as follows:
>
> @Component
>
> public class ScottAssociationListPage extends BorderPage {
>
>
>
>     private static final long serialVersionUID = 1L;
>
>
>
>     private Form form = new Form("form");
>
>
>
>     private FieldSet fieldSet = new FieldSet("association");
>
>     private Table table = new Table("table");
>
>
>
>     private PageLink viewLink = new PageLink("view",
> ScottAssociationViewPage.class);
>
>     private PageLink editLink = new PageLink("edit",
> ScottAssociationEditPage.class);
>
>     private ActionLink deleteLink = new ActionLink("delete", this,
> "onDeleteClick");
>
>
>
>     private PageButton pageButtonAdd = new PageButton("pageButtonAdd",
> ScottAssociationEditPage.class);
>
>
>
>       @Resource(name="associationService")
>
>       private IAssociationService associationService;
>
>
>
>
>
>       /**
>
>       *
>
>        */
>
>       public ScottAssociationListPage() {
>
>         addControl(form);
>
>
>
>         // Add controls
>
>         fieldSet.setLegend("LS_Associations");
>
>         form.add(fieldSet);
>
>
>
>         // Setup fieldset
>
>         fieldSet.add(table);
>
>
>
>         // Setup table
>
>         table.setClass(Table.CLASS_SIMPLE);
>
>         table.setPageSize(4);
>
>         table.setShowBanner(true);
>
>         table.setSortable(false);
>
>         table.setPaginator(new TableInlinePaginator(table));
>
>         table.setPaginatorAttachment(Table.PAGINATOR_INLINE);
>
>
>
>         table.addColumn(new Column("primaryKey", "LS_PrimaryKey"));
>
>
>
>         table.addColumn(new Column("name", "LS_Name"));
>
>
>
>         viewLink.setImageSrc("/assets/images/icon_view.png");
>
>         viewLink.setTitle("View");
>
>
>
>         editLink.setImageSrc("/assets/images/icon_edit.png");
>
>         editLink.setTitle("Edit");
>
>         editLink.setParameter("referrer",
> "/scott/scottAssociationList.htm");
>
>
>
>         deleteLink.setImageSrc("/assets/images/icon_delete.png");
>
>         deleteLink.setTitle("Delete");
>
>         deleteLink.setAttribute("onclick", "return window.confirm('Are you
> sure you want to delete this record?');");
>
>
>
>
>
>         Column column = new Column("action", "LS_Action");
>
>         column.setTextAlign("center");
>
>         AbstractLink[] links = new AbstractLink[] { viewLink, editLink,
> deleteLink };
>
>         column.setDecorator(new LinkDecorator(table, links, "primaryKey"));
>
>         column.setSortable(false);
>
>         table.addColumn(column);
>
>
>
>         // Setup add button
>
>         pageButtonAdd.setLabel("LS_Add");
>
>         pageButtonAdd.setDisabled(false);
>
>         fieldSet.add(pageButtonAdd);
>
>
>
>         // Below we setup the table to preserve it's state (sorting and
> paging)
>
>         // while editing customers
>
> //
>
> //        table.getControlLink().setActionListener(new ActionListener() {
>
> //
>
> //            public boolean onAction(Control source) {
>
> //                // Save Table sort and paging state between requests.
>
> //                // NOTE: we set the listener on the table's Link control
> which is invoked
>
> //                // when the Link is clicked, such as when paging or
> sorting.
>
> //                // This ensures the table state is only saved when the
> state changes, and
>
> //                // cuts down on unnecessary session replication in a
> cluster environment.
>
> //                table.saveState(getContext());
>
> //                return true;
>
> //            }
>
> //        });
>
> //
>
> //        // Restore the table sort and paging state from the session
> between requests
>
> //        table.restoreState(getContext());
>
>
>
>       }
>
>
>
>       @Override
>
>       public boolean onSecurityCheck() {
>
>             // TODO Auto-generated method stub
>
>             return super.onSecurityCheck();
>
>       }
>
>
>
>     @Override
>
>       public void onInit() {
>
>             // TODO Auto-generated method stub
>
>             super.onInit();
>
>       }
>
>
>
>       @Override
>
>       public void onGet() {
>
>             // TODO Auto-generated method stub
>
>             super.onGet();
>
>       }
>
>
>
>       @Override
>
>       public void onRender() {
>
>
>
>             table.setDataProvider(new DataProvider<Association>() {
>
>
>
>             private static final long serialVersionUID = 1L;
>
>
>
>             public List<Association> getData() {
>
>                   ArrayList<Association> associations = new
> ArrayList<Association>();
>
>
> associations.add(associationService.findAssociation(null));
>
>                 return associations;
>
>             }
>
>         });
>
>
>
>       }
>
>
>
>
>
> }
>
>
>
> Any thoughts on what I have done wrong here?
>
>
>
> Any help is enormously appreciated.
>
>
>
>
>
> Best regards,
>
>
>
> Scott Gurney
>
> [email protected]
>
>
>
>
>
>
>
> ps. Full stack Trace of error
>
>
>
> java.lang.IllegalArgumentException: Null source parameter
>
>        at
> org.apache.click.util.PropertyUtils$CacheKey.<init>(PropertyUtils.java:263)
>
>        at
> org.apache.click.util.PropertyUtils.getObjectPropertyValue(PropertyUtils.java:188)
>
>        at
> org.apache.click.util.PropertyUtils.getValue(PropertyUtils.java:113)
>
>        at org.apache.click.control.Column.getProperty(Column.java:1331)
>
>        at org.apache.click.control.Column.getProperty(Column.java:1282)
>
>        at
> org.apache.click.control.Column.renderTableDataContent(Column.java:1355)
>
>        at org.apache.click.control.Column.renderTableData(Column.java:1191)
>
>        at
> org.apache.click.control.Table.renderBodyRowColumns(Table.java:2001)
>
>        at org.apache.click.control.Table.renderBodyRows(Table.java:1878)
>
>        at org.apache.click.control.Table.render(Table.java:1631)
>
>        at org.apache.click.control.FieldSet.renderFields(FieldSet.java:1274)
>
>        at org.apache.click.control.FieldSet.render(FieldSet.java:981)
>
>        at org.apache.click.control.Form.renderControls(Form.java:2540)
>
>        at org.apache.click.control.Form.renderFields(Form.java:2474)
>
>        at org.apache.click.control.Form.render(Form.java:2288)
>
>        at
> org.apache.click.control.AbstractContainer.toString(AbstractContainer.java:364)
>
>        at
> org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:430)
>
>        at
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
>
>        at org.apache.velocity.runtime.directive.Parse.render(Parse.java:260)
>
>        at
> org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207)
>
>        at
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
>
>        at org.apache.velocity.Template.merge(Template.java:356)
>
>        at org.apache.velocity.Template.merge(Template.java:260)
>
>        at
> org.apache.click.service.VelocityTemplateService.internalRenderTemplate(VelocityTemplateService.java:537)
>
>        at
> org.apache.click.service.VelocityTemplateService.renderTemplate(VelocityTemplateService.java:330)
>
>        at
> org.apache.click.ClickServlet.renderTemplate(ClickServlet.java:948)
>
>        at org.apache.click.ClickServlet.performRender(ClickServlet.java:905)
>
>        at
> org.apache.click.ClickServlet.processPageEvents(ClickServlet.java:618)
>
>        at org.apache.click.ClickServlet.processPage(ClickServlet.java:561)
>
>        at org.apache.click.ClickServlet.handleRequest(ClickServlet.java:383)
>
>        at org.apache.click.ClickServlet.doGet(ClickServlet.java:276)
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>
>        at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>
>        at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
>        at
> org.apache.click.extras.filter.PerformanceFilter.doFilter(PerformanceFilter.java:354)
>
>        at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
>
>        at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
>        at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>
>        at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>
>        at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
>
>        at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>
>        at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>
>        at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>
>        at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
>
>        at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
>
>        at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
>
>        at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
>
>        at java.lang.Thread.run(Thread.java:636)
>
>

Reply via email to