You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Scott Ellsworth <sc...@alodar.com> on 2004/07/07 08:53:34 UTC
How to have a page go to itself?
Hi, all.
Is cycle.activate the way to have a page go to itself, with new data?
I have a page that shows a table full of Resources, called
ResourceListPage. When the user clicks on some of the items in the
page, they should get a new ResourceListPage full of Resources. I do
this via direct links:
<td>
<a href="resourceresults.html"
jwcid="@DirectLink"
class="select-resource-list"
listener="ognl:listeners.goToResourceList"
parameters="ognl:loopResource.plateId">
<span jwcid="@Insert" value="ognl:loopResource.plateId"/>
</a>
</td>
The code for goToResourceList in my Resource is
public void goToResourceList(IRequestCycle cycle) {
Object[] parameters = cycle.getServiceParameters();
Collection ids = new ArrayList();
if (parameters != null && parameters.length > 0) {
for (int i = 0; i < parameters.length; i++) {
ids.add(parameters[i]);
logger.info("Parameter "+i+" is
"+parameters[i].getClass().getName()+" = "+parameters[i]);
}
logger.info("Request for resource list " + ids);
}
ResourceListPage page = (ResourceListPage)
cycle.getPage("ResourceListPage");
page.setResourceList(ids);
page.doSearch();
cycle.activate(page);
clearVariables();
getEngine().setVisit(null);
logger.info("Leaving goToResourceList");
}
The log messages have shown me that the right data is getting set in
the page, but when I hit the link, I do not end up back at
ResourceListPage again with new data, but instead, I end up a blank
ResourceListPage.
The same code works great if I am going to a ProtocolListPage, or from
a ProtocolListPage to a ResourceListPage.
Should I be doing this another way?
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: How to have a page go to itself?
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jul 7, 2004, at 2:53 AM, Scott Ellsworth wrote:
> Is cycle.activate the way to have a page go to itself, with new data?
Tapestry automatically activates to the current page if you do not
specify - so you can simply remove the cycle.activate altogether.
>
> I have a page that shows a table full of Resources, called
> ResourceListPage. When the user clicks on some of the items in the
> page, they should get a new ResourceListPage full of Resources. I do
> this via direct links:
>
> <td>
> <a href="resourceresults.html"
> jwcid="@DirectLink"
> class="select-resource-list"
> listener="ognl:listeners.goToResourceList"
> parameters="ognl:loopResource.plateId">
> <span jwcid="@Insert" value="ognl:loopResource.plateId"/>
> </a>
> </td>
>
> The code for goToResourceList in my Resource is
>
> public void goToResourceList(IRequestCycle cycle) {
> Object[] parameters = cycle.getServiceParameters();
> Collection ids = new ArrayList();
> if (parameters != null && parameters.length > 0) {
> for (int i = 0; i < parameters.length; i++) {
> ids.add(parameters[i]);
> logger.info("Parameter "+i+" is
> "+parameters[i].getClass().getName()+" = "+parameters[i]);
> }
> logger.info("Request for resource list " + ids);
> }
>
> ResourceListPage page = (ResourceListPage)
> cycle.getPage("ResourceListPage");
> page.setResourceList(ids);
> page.doSearch();
>
> cycle.activate(page);
>
> clearVariables();
> getEngine().setVisit(null);
> logger.info("Leaving goToResourceList");
> }
>
> The log messages have shown me that the right data is getting set in
> the page, but when I hit the link, I do not end up back at
> ResourceListPage again with new data, but instead, I end up a blank
> ResourceListPage.
>
> The same code works great if I am going to a ProtocolListPage, or from
> a ProtocolListPage to a ResourceListPage.
>
> Should I be doing this another way?
>
> Scott
>
>
> ---------------------------------------------------------------------
> 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: How to have a page go to itself?
Posted by Richard Kirby <rb...@capdm.com>.
Hi,
Just drop off the end of your listener method. If you do not call
activate, then the cycle object will by default keep the current page,
which will then redisplay.
See below for a modified version of your listener:
On 7 Jul 2004, at 07:53, Scott Ellsworth wrote:
> Hi, all.
>
> Is cycle.activate the way to have a page go to itself, with new data?
>
> I have a page that shows a table full of Resources, called
> ResourceListPage. When the user clicks on some of the items in the
> page, they should get a new ResourceListPage full of Resources. I do
> this via direct links:
>
...
> public void goToResourceList(IRequestCycle cycle) {
> Object[] parameters = cycle.getServiceParameters();
> Collection ids = new ArrayList();
> if (parameters != null && parameters.length > 0) {
> for (int i = 0; i < parameters.length; i++) {
> ids.add(parameters[i]);
> logger.info("Parameter "+i+" is
> "+parameters[i].getClass().getName()+" = "+parameters[i]);
> }
> logger.info("Request for resource list " + ids);
> }
>
> // ResourceListPage page = (ResourceListPage)
> cycle.getPage("ResourceListPage");
> // page.setResourceList(ids);
> // page.doSearch();
>
> // cycle.activate(page);
>
> // clearVariables();
this.setResourceList(ids);
this.doSearch();
> getEngine().setVisit(null);
> logger.info("Leaving goToResourceList");
> }
>
Richard.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: How to have a page go to itself?
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
If you want to stay stateless, simply never call getVisit (or use
"ognl:visit...") and never use persistent page properties.
Erik
On Jul 7, 2004, at 11:16 PM, Scott Ellsworth wrote:
> Thank you, James, Erik, and David, Richard, Bryan.
>
> As suggested, skipping the activate did what I wanted.
>
> This does lead me to a question. In order to minimize resource usage
> and remain stateless, every time I leave a page, I clear all the
> variables and make sure the visit is set to null. (clearVariables is
> the method that does this to make sure that the page does not have new
> state next time.)
>
> Is this how you guys do this?
>
> Scott
>
>
> ---------------------------------------------------------------------
> 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: How to have a page go to itself?
Posted by Richard Kirby <rb...@capdm.com>.
On 8 Jul 2004, at 04:16, Scott Ellsworth wrote:
> Thank you, James, Erik, and David, Richard, Bryan.
>
> As suggested, skipping the activate did what I wanted.
>
> This does lead me to a question. In order to minimize resource usage
> and remain stateless, every time I leave a page, I clear all the
> variables and make sure the visit is set to null. (clearVariables is
> the method that does this to make sure that the page does not have new
> state next time.)
The org.apache.tapestry.AbstractPage.initialize method is the
recommended place to clear variables. Just override in your page class,
the default implementation is empty. As to setting visit to null -
visit is only created if somewhere you call
org.apache.tapestry.IEngine.getVisit(IRequestCycle), so if you don't do
that, there should never be a need to explicitly do it yourself.
Richard.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: How to have a page go to itself?
Posted by Scott Ellsworth <sc...@alodar.com>.
Thank you, James, Erik, and David, Richard, Bryan.
As suggested, skipping the activate did what I wanted.
This does lead me to a question. In order to minimize resource usage
and remain stateless, every time I leave a page, I clear all the
variables and make sure the visit is set to null. (clearVariables is
the method that does this to make sure that the page does not have new
state next time.)
Is this how you guys do this?
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: How to have a page go to itself?
Posted by James Sherwood <js...@romulin.com>.
These look like errors to me:
>ResourceListPage page = (ResourceListPage)
dunno how it would compile with that?
but more important it looks like you are clearing the page variables after
you set them?
> clearVariables();
I would just do this:
public void goToResourceList(IRequestCycle cycle) {
Object[] parameters = cycle.getServiceParameters();
Collection ids = new ArrayList();
if (parameters != null && parameters.length > 0) {
for (int i = 0; i < parameters.length; i++) {
ids.add(parameters[i]);
logger.info("Parameter "+i+" is
"+parameters[i].getClass().getName()+" = "+parameters[i]);
}
logger.info("Request for resource list " + ids);
}
clearVariables();
setResourceList(ids);
doSearch();
getEngine().setVisit(null);
logger.info("Leaving goToResourceList");
}
Something to that effect
Although I dont know the ins and outs of your variables on the page, if its
only the resource list, why would you have to clear them as you are
overwriting them anyway
James
----- Original Message -----
From: "Scott Ellsworth" <sc...@alodar.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Wednesday, July 07, 2004 3:53 AM
Subject: How to have a page go to itself?
> Hi, all.
>
> Is cycle.activate the way to have a page go to itself, with new data?
>
> I have a page that shows a table full of Resources, called
> ResourceListPage. When the user clicks on some of the items in the
> page, they should get a new ResourceListPage full of Resources. I do
> this via direct links:
>
> <td>
> <a href="resourceresults.html"
> jwcid="@DirectLink"
> class="select-resource-list"
> listener="ognl:listeners.goToResourceList"
> parameters="ognl:loopResource.plateId">
> <span jwcid="@Insert" value="ognl:loopResource.plateId"/>
> </a>
> </td>
>
> The code for goToResourceList in my Resource is
>
> public void goToResourceList(IRequestCycle cycle) {
> Object[] parameters = cycle.getServiceParameters();
> Collection ids = new ArrayList();
> if (parameters != null && parameters.length > 0) {
> for (int i = 0; i < parameters.length; i++) {
> ids.add(parameters[i]);
> logger.info("Parameter "+i+" is
> "+parameters[i].getClass().getName()+" = "+parameters[i]);
> }
> logger.info("Request for resource list " + ids);
> }
>
> ResourceListPage page = (ResourceListPage)
> cycle.getPage("ResourceListPage");
> page.setResourceList(ids);
> page.doSearch();
>
> cycle.activate(page);
>
> clearVariables();
> getEngine().setVisit(null);
> logger.info("Leaving goToResourceList");
> }
>
> The log messages have shown me that the right data is getting set in
> the page, but when I hit the link, I do not end up back at
> ResourceListPage again with new data, but instead, I end up a blank
> ResourceListPage.
>
> The same code works great if I am going to a ProtocolListPage, or from
> a ProtocolListPage to a ResourceListPage.
>
> Should I be doing this another way?
>
> Scott
>
>
> ---------------------------------------------------------------------
> 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: How to have a page go to itself?
Posted by Bryan Lewis <br...@maine.rr.com>.
What does clearVariables() do?
----- Original Message -----
From: "Scott Ellsworth" <sc...@alodar.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Wednesday, July 07, 2004 2:53 AM
Subject: How to have a page go to itself?
> Hi, all.
>
> Is cycle.activate the way to have a page go to itself, with new data?
>
> I have a page that shows a table full of Resources, called
> ResourceListPage. When the user clicks on some of the items in the
> page, they should get a new ResourceListPage full of Resources. I do
> this via direct links:
>
> <td>
> <a href="resourceresults.html"
> jwcid="@DirectLink"
> class="select-resource-list"
> listener="ognl:listeners.goToResourceList"
> parameters="ognl:loopResource.plateId">
> <span jwcid="@Insert" value="ognl:loopResource.plateId"/>
> </a>
> </td>
>
> The code for goToResourceList in my Resource is
>
> public void goToResourceList(IRequestCycle cycle) {
> Object[] parameters = cycle.getServiceParameters();
> Collection ids = new ArrayList();
> if (parameters != null && parameters.length > 0) {
> for (int i = 0; i < parameters.length; i++) {
> ids.add(parameters[i]);
> logger.info("Parameter "+i+" is
> "+parameters[i].getClass().getName()+" = "+parameters[i]);
> }
> logger.info("Request for resource list " + ids);
> }
>
> ResourceListPage page = (ResourceListPage)
> cycle.getPage("ResourceListPage");
> page.setResourceList(ids);
> page.doSearch();
>
> cycle.activate(page);
>
> clearVariables();
> getEngine().setVisit(null);
> logger.info("Leaving goToResourceList");
> }
>
> The log messages have shown me that the right data is getting set in
> the page, but when I hit the link, I do not end up back at
> ResourceListPage again with new data, but instead, I end up a blank
> ResourceListPage.
>
> The same code works great if I am going to a ProtocolListPage, or from
> a ProtocolListPage to a ResourceListPage.
>
> Should I be doing this another way?
>
> Scott
>
>
> ---------------------------------------------------------------------
> 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