public abstract class SearchForm {

.....

   protected abstract void onSearch(SearchInput input);

   ...

   add(new Button("searchButton")
>                         {
>                                 public void onSubmit()
>                                 {
>                                         try
>                                         {
>                                                 //save form values, redirect
>                                                 SearchInput input = 
> (SearchInput)getParent().getModelObject();
>                                                 redirectPage. //WHAT DO TO 
> HERE??
>                                                 onSearch(input);
>                                         }


then just

then just add(new SearchForm("form") { protected void
onSearch(SearchInput si) { setResponsePage(new MyWebPage(si)); }}

-igor


On Dec 21, 2007 7:53 AM, V. Jenks <[EMAIL PROTECTED]> wrote:
>
> Hello Wicketeers...
>
> I've got a series of pages that all have the same search form and use the
> same input class, the only thing different about them is where they redirect
> (since every page is different.)
>
> I need a second set of eyes...how do I make this form reusable?  The form
> captures the search input and redirects the page back to itself...so I need
> a way of parameterizing where it redirects (unless there's a better approach
> that I'm unaware of.)
>
> Here's the page that my search pages will derive from, which is already
> using markup inheritance (i.e. "BasePage", which derives from WebPage):
>
> public class SearchListPage extends BasePage
> {
>         private static class SearchForm extends Form
>         {
>                 public SearchForm(String name, SearchInput input, WebPage 
> redirectPage)
>                 {
>                         super(name, new CompoundPropertyModel(input));
>
>                         add(new TextField("searchText")
>                                         .setRequired(true)
>                                         .add(StringValidator.lengthBetween(2, 
> 100)));
>
>                         add(new Button("searchButton")
>                         {
>                                 public void onSubmit()
>                                 {
>                                         try
>                                         {
>                                                 //save form values, redirect
>                                                 SearchInput input = 
> (SearchInput)getParent().getModelObject();
>                                                 redirectPage. //WHAT DO TO 
> HERE??
>                                                 setResponsePage(new 
> WebPage(input.getSearchText())); //WRONG!
>                                         }
>                                         catch (Exception exp)
>                                         {
>                                                 info(exp.getMessage());
>                                         }
>                                 }
>                         });
>                 }
>         }
> }
>
> As you can see, I've gotten as far as trying to figure out what I can do w/
> the WebPage param, if anything...any ideas?
>
> Thanks!
> --
> View this message in context: 
> http://www.nabble.com/Reusable-search-form---help-w--detail...-tp14457665p14457665.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to