You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Shark <bl...@gmail.com> on 2004/11/17 21:11:15 UTC

Page data forwarding

Hi All,

I have a Search.page for looking up a user from a db, the result is a
List of User Objects that I want to display in another page called
SearchResults,page.

After calling the search method on the Search page I forward to the
results page as:

        String nextPageName =
getNamespace().constructQualifiedName("SearchResult");
        IPage page = cycle.getPage(nextPageName);
        cycle.activate(page);

I cant seem to do this, I get a ClassCastException:
        SearchResult page = (SearchResult)cycle.getPage(nextPageName);
        page.setUsers(result);

So I set the List of users in the Visit object before forwarding. The
SearchResult.page specification calls a getUsers method that has to be
defined on the Search.page java page class.

Is this the correct way to achieve the goal of displaying a list of
users found during search?

Thanks

S

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Page data forwarding

Posted by Markus Wiederkehr <ma...@gmail.com>.
I don't see what's wrong with your code, but you definitely don't need
the Visit object to pass information between two pages.

What is the actual class returned by getPage()?

Try something like System.out.println(cycle.getPage(nextPageName).getClass());

Markus

On Wed, 17 Nov 2004 14:11:15 -0600, Shark <bl...@gmail.com> wrote:
> Hi All,
> 
> I have a Search.page for looking up a user from a db, the result is a
> List of User Objects that I want to display in another page called
> SearchResults,page.
> 
> After calling the search method on the Search page I forward to the
> results page as:
> 
>         String nextPageName =
> getNamespace().constructQualifiedName("SearchResult");
>         IPage page = cycle.getPage(nextPageName);
>         cycle.activate(page);
> 
> I cant seem to do this, I get a ClassCastException:
>         SearchResult page = (SearchResult)cycle.getPage(nextPageName);
>         page.setUsers(result);
> 
> So I set the List of users in the Visit object before forwarding. The
> SearchResult.page specification calls a getUsers method that has to be
> defined on the Search.page java page class.
> 
> Is this the correct way to achieve the goal of displaying a list of
> users found during search?
> 
> Thanks
> 
> S
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Page data forwarding

Posted by John Studarus <jo...@yahoo.com>.
 
  Say you have the following pages:
 
SimpleSearch.page  SimpleSearchPage.java
ComplexSearch.page  ComplexSearchPage.java
SearchResult.page  SearchResultPage.java
 
SimpleSearchPage would contain:
 
public void submitAction(IRequestCycle cycle) {
  // the next page we want to go to is the SearchResult page
  SearchResultPage next_page = (SearchResultPage)cycle.getPage("SearchResult");
  next_page.setResult(result);
  cycle.activate(next_page);
}
 
  Hope that clears it up.
 
        John
 


Shark <bl...@gmail.com> wrote:Thanks for your reply, 

Yes I am trying to use two pages one for entering the search criteria
and another for viewing the results.

I am confused with this section from your reply:

> SearchPage next_page = (SearchPage)cycle.getPage("Search");
> next_page.setUsers(result);
> cycle.activate(next_page);

So we call cycle.getPage("Search"); with the "SEARCH" page name where
the user entered his search criteria and not the "SEARCHRESULT" page
name?

And I dont need to use the Visit object to carry the data?

And you guessed correctly, I will have multiple search pages and a
single results page. But I was trying to call say a simpleSearch,
complexSearch method on the SearchPage class and forward the reusults
to the Results page.

S.

On Wed, 17 Nov 2004 12:27:40 -0800 (PST), John Studarus
wrote:
> 
> I tend to do my search and result functionality on one page. Then the user can keep on resubmitting and refining the search without page hopping. But if you want it on two pages you would need something like this:
> 
> // SearchPage is the Java Class and Search is the Tapestry Page Name
> SearchPage next_page = (SearchPage)cycle.getPage("Search");
> next_page.setUsers(result);
> cycle.activate(next_page);
> 
> You can also throw in a:
> 
> next_page.setCallback(new PageCallback(this));
> 
> before the activate. Then in the Result page add a cancel button that does something like:
> 
> protected void Cancel(IRequestCycle cycle) {
> getCallback().performCallback(cycle); // might want to check for a null here
> }
> 
> Then they would go back to the search page where they came from (i.e. if you had a bunch of search pages going to one result page).
> 
> John
> 
> Shark wrote:Hi All,
> 
> 
> 
> I have a Search.page for looking up a user from a db, the result is a
> List of User Objects that I want to display in another page called
> SearchResults,page.
> 
> After calling the search method on the Search page I forward to the
> results page as:
> 
> String nextPageName =
> getNamespace().constructQualifiedName("SearchResult");
> IPage page = cycle.getPage(nextPageName);
> cycle.activate(page);
> 
> I cant seem to do this, I get a ClassCastException:
> SearchResult page = (SearchResult)cycle.getPage(nextPageName);
> page.setUsers(result);
> 
> So I set the List of users in the Visit object before forwarding. The
> SearchResult.page specification calls a getUsers method that has to be
> defined on the Search.page java page class.
> 
> Is this the correct way to achieve the goal of displaying a list of
> users found during search?
> 
> Thanks
> 
> S
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Discover all that's new in My Yahoo!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org



			
---------------------------------
Do you Yahoo!?
 The all-new My Yahoo! � Get yours free!    

Re: Page data forwarding

Posted by Shark <bl...@gmail.com>.
Thanks for your reply, 

Yes I am trying to use two pages one for entering the search criteria
and another for viewing the results.

I am confused with this section from your reply:

>   SearchPage next_page = (SearchPage)cycle.getPage("Search");
>   next_page.setUsers(result);
>   cycle.activate(next_page);

So we call cycle.getPage("Search"); with the "SEARCH" page name where
the user entered his search criteria and not the "SEARCHRESULT" page
name?

And I dont need to use the Visit object to carry the data?

And you guessed correctly, I will have multiple search pages and a
single results page. But I was trying to call say a simpleSearch,
complexSearch method on the SearchPage class and forward the reusults
to the Results page.

S.

On Wed, 17 Nov 2004 12:27:40 -0800 (PST), John Studarus
<jo...@yahoo.com> wrote:
> 
>   I tend to do my search and result functionality on one page.  Then the user can keep on resubmitting and refining the search without page hopping.  But if you want it on two pages you would need something like this:
> 
>   // SearchPage is the Java Class and Search is the Tapestry Page Name
>   SearchPage next_page = (SearchPage)cycle.getPage("Search");
>   next_page.setUsers(result);
>   cycle.activate(next_page);
> 
>   You can also throw in a:
> 
>   next_page.setCallback(new PageCallback(this));
> 
>   before the activate.  Then in the Result page add a cancel button that does something like:
> 
>   protected void Cancel(IRequestCycle cycle) {
>     getCallback().performCallback(cycle);  // might want to check for a null here
>   }
> 
>   Then they would go back to the search page where they came from (i.e. if you had a bunch of search pages going to one result page).
> 
>         John
> 
> Shark <bl...@gmail.com> wrote:Hi All,
> 
> 
> 
> I have a Search.page for looking up a user from a db, the result is a
> List of User Objects that I want to display in another page called
> SearchResults,page.
> 
> After calling the search method on the Search page I forward to the
> results page as:
> 
> String nextPageName =
> getNamespace().constructQualifiedName("SearchResult");
> IPage page = cycle.getPage(nextPageName);
> cycle.activate(page);
> 
> I cant seem to do this, I get a ClassCastException:
> SearchResult page = (SearchResult)cycle.getPage(nextPageName);
> page.setUsers(result);
> 
> So I set the List of users in the Visit object before forwarding. The
> SearchResult.page specification calls a getUsers method that has to be
> defined on the Search.page java page class.
> 
> Is this the correct way to achieve the goal of displaying a list of
> users found during search?
> 
> Thanks
> 
> S
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> ---------------------------------
> Do you Yahoo!?
>  Discover all that's new in My Yahoo!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Page data forwarding

Posted by John Studarus <jo...@yahoo.com>.
 
  I tend to do my search and result functionality on one page.  Then the user can keep on resubmitting and refining the search without page hopping.  But if you want it on two pages you would need something like this:
 
  // SearchPage is the Java Class and Search is the Tapestry Page Name
  SearchPage next_page = (SearchPage)cycle.getPage("Search");
  next_page.setUsers(result);
  cycle.activate(next_page);
 
  You can also throw in a:
 
  next_page.setCallback(new PageCallback(this));
 
  before the activate.  Then in the Result page add a cancel button that does something like:
 
  protected void Cancel(IRequestCycle cycle) {
    getCallback().performCallback(cycle);  // might want to check for a null here
  }
 
  Then they would go back to the search page where they came from (i.e. if you had a bunch of search pages going to one result page).
 
        John
  
 


Shark <bl...@gmail.com> wrote:Hi All,

I have a Search.page for looking up a user from a db, the result is a
List of User Objects that I want to display in another page called
SearchResults,page.

After calling the search method on the Search page I forward to the
results page as:

String nextPageName =
getNamespace().constructQualifiedName("SearchResult");
IPage page = cycle.getPage(nextPageName);
cycle.activate(page);

I cant seem to do this, I get a ClassCastException:
SearchResult page = (SearchResult)cycle.getPage(nextPageName);
page.setUsers(result);

So I set the List of users in the Visit object before forwarding. The
SearchResult.page specification calls a getUsers method that has to be
defined on the Search.page java page class.

Is this the correct way to achieve the goal of displaying a list of
users found during search?

Thanks

S

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org



		
---------------------------------
Do you Yahoo!?
 Discover all that�s new in My Yahoo!