class searchpage extends webpage {
  private string keywords;

  private class provider implements idataprovider {
     iterator(...) { return service.search(keywords).iterator(); }
  }

  public searchpage() {
     form f=new form(...);
     f.add(new textfield("keywords", new propertymodel(this, "keywords")));
   }
}

-igor

On Fri, Feb 11, 2011 at 2:23 PM, Joe Eckard <eckar...@redrocketcorp.com> wrote:
> Hi, I am new to wicket and I'm having trouble determining the correct way to 
> implement a generic search page.
>
> I created a page that contains a custom form panel for the search parameter 
> input, and a DataTable for displaying the results. The DataTable uses a 
> custom DataProvider which takes a condition object that is used to perform 
> the find. The condition is initially null, which causes the DataProvider to 
> return all objects - this works fine, and so does the navigation toolbar I 
> added to the table. (I'm attaching example code below.)
>
> My question is: what is the correct way to update the table's contents? I 
> have the form panel's onSubmit() call onFind(), which creates a new condition 
> object, but I'm not sure what to do with it.
>
> Should I have the onFind() method add a new DataTable with a new 
> DataProvider? Or keep a reference to the table and set a new provider? Am I 
> on the right track or way off base?
>
>
> SearchPage.java
> -------------
>
> private EntityCondition condition = null;
>
> SearchPage(String entityName) {
>
>    add(new SearchFormPanel("find", entityName) {
>
>        public void onSubmit(Map<String, Object> searchParameters) {
>            onFind(searchParameters);
>        }
>    });
>
>    IColumn[] columns = ...
>
>    EntityDataProvider entityDataProvider = new EntityDataProvider(entityName, 
> condition);
>
>    DataTable table = new DataTable<GenericValue>("results", columns, 
> entityDataProvider, 10);
>
>    table.addTopToolbar(new NavigationToolbar(table));
>    table.addTopToolbar(new HeadersToolbar(table, null));
>
>    add(table);
> }
>
> protected void onFind(Map<String, Object> searchParameters) {
>
>    condition = makeCondition(searchParameters);
> }
>
> ...
>
> SearchPage.html
> -------------
>
> <wicket:extend>
>
>    <div wicket:id="find"></div>
>
>    <table wicket:id="results" class="display"></table>
>
> </wicket:extend>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to