On Fri, May 1, 2009 at 9:16 AM, Angelo Chen <angelochen...@yahoo.com.hk>wrote:

>
> Hi,
>
> following code redirects to a results page under mysearch:
>
> Object onSuccessFromMySearchForm() {
>        return "mysearch/results";
> }
>
> now I need to append a query string after the page name:
>
> return "mysearch/results?12345";
>
> this will trigger an exception:
>
> Unable to resolve 'mysearch/results?12345' to a known page name.
>
> question: how to append a query string to a page name? Thanks,
>

Rather than query string, you'd tend to append to the path in Tapestry.  I
don't think you can do that with the "page name" string return, though, so
the simplest way is to return a configured page object that can passivate.

public class Results {
   Integer value;

   public void onActivate(EventContext context) {
      if( context.getCount() > 0 )
         value = context.get(String.class,0);
   }

   public Integer onPassivate() {
      return value;
   }

   public Results forValue( Integer value ) {
      this.value = value;
      return this;
   }
}

public class MySearch {
   @Inject
   private Results resultPage;

   public Object onSuccessFromMySearchForm() {
      return resultPage.forValue(12345);
   }
}

-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Reply via email to