PageRedirectException does not actually redirect. It simply activates
the specified page. Consequently, reloading the page reexecutes the
form submit causing a stale link exception since the number of form
elements has changed between rewind and render.
To actually redirect, try the following:
IEngineService service =
cycle.getEngine().getService(Tapestry.PAGE_SERVICE );
ILink link = service.getLink(cycle, cycle.getPage(), new String[] {
"Images" });
throw new RedirectException(link.getURL());
You should make it a habit to always redirect at the end of your form
listeners to avoid these problems.
Paul
Alberto Lepe wrote:
>The file is successfuly deleted, but the problem is when reloading the
>page (Manually).
>
>In my listener I redirected:
>
>throw new PageRedirectException(cycle.getPage("Images"));
>
>where Images is my current page.
>In this case, no error is displayed, but when reloading, the next
>image in list is also deleted.
>
>I found a way to prevent this, but I don't think is a very good way:
>
>I substitute StaleLink.page and StaleLink.html. At the StateLink.html I wrote:
><script type="text/javascript">;</script>
>It works, but only if I use externalLinks. But when I submit a new
>image, it clears my external refference. So I don't think this is a
>solution.
>
>I read at the Reference, about "Form" Component:
>
>Parameter: stateful
>If true (the default), then the component requires an active (i.e.,
>non-new) HttpSession when triggered. Failing that, it throws a
>StaleLinkException. If false, then no check is necessary. Generally,
>forms are stateful, but it is possible to put a stateless form onto
>the Home page of an application.
>
>I thought this could help me, but it didn't.
>
>I believe there is a simple solution to my problem. Here is some of my code:
>
>public void DeleteImg(IRequestCycle cycle){
>boolean exists = (new File(uploadPath+getSelectedName())).exists();
>if(exists){
>boolean success = (new File(uploadPath+getSelectedName())).delete();
> if (!success) {
// Error Handling
> }
>}
>}
>
>At my page:
<property-specification name="currImg" type="java.io.File" />
<property-specification name="selectedName"
>type="java.lang.String" initial-value="''"/>
>
<component id="feImage" type="Foreach">
<binding name="source" expression="fileList"/>
<binding name="value" expression="currImg" />
<binding name="index" expression="index"/>
<static-binding name="element" value="tr"/>
</component>
<component id="iFileName" type="Insert">
<binding name="value" expression="currImg.name"/>
</component>
<context-asset name="delete" path="images/error.png"/>
<component id="sbDel" type="ImageSubmit">
<binding name="image" expression="assets.delete" />
<binding name="selected" expression="selectedName"/>
<binding name="tag" expression="currImg.name"/>
<binding name="listener" expression="listeners.DeleteImg"/>
</component>
>
>Thanks.
>
>2005/5/3, Konstantin Iignatyev <kgignatyev (AT) yahoo (DOT) com>:
>
>>Try replacing ImageSubmit by DirectLink with a parameter(image name?)
>>that will allow deletion of chosen image;
>>
>>
>>Alberto Lepe wrote:
>>
>
>>
Here is the challenge:
I have a List of Image's File name, with an ImageSubmit to delete them, like:
image1.jpg [X]
image2.jpg [X]
Quite simple. I press on the [X] and the image is deleted succesfully.
If I reload the page, it display a "Stale link" error. This also
happens if other user is watching the same list and want to delete a
file that was deleleted seconds ago.
I tried to redirect the page on my listener, but with out success. I
don't want to override my Engine class. Any other option?
Thank you!
To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
>>Thanks,
>>
>>Konstantin Ignatyev
>>
>>http://www.kgionline.com
>>
>>PS: If this is a typical day on planet earth, humans will add fifteen million tons of carbon to the atmosphere, destroy 115 square miles of tropical rainforest, create seventy-two miles of desert, eliminate between forty to one hundred species, erode seventy-one million tons of topsoil, add 2.700 tons of CFCs to the stratosphere, and increase their population by 263.000
>>
>>Bowers, C.A. The Culture of Denial:
>>Why the Environmental Movement Needs a Strategy for Reforming Universities and Public Schools.
>>New York: State University of New York Press, 1997: (4) (5) (p.206)
>>
>>
>>
>>To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
>>For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
>>
>>
>
>>
>
>
>To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
>For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org
>
To unsubscribe, e-mail: tapestry-user-unsubscribe (AT) jakarta (DOT) apache.org
For additional commands, e-mail: tapestry-user-help (AT) jakarta (DOT) apache.org