Java

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Stale Link

    6 answers - 753 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    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
  • No.1 | | 1177 bytes | |

    How are you redirecting in your listener? I suspect that's where the
    problem is

    Paul

    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
    >


    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
  • No.2 | | 1017 bytes | |

    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
    >
    >
  • No.3 | | 3690 bytes | |

    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
    >
    >
    >
    >
  • No.4 | | 6165 bytes | |

    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
  • No.5 | | 5608 bytes | |

    In short words: this behavior seems to be caused by standard Tapestry
    gotcha:
    Form and Submit Listeners: Matters

    Do not do submit, use DirectLink
    or try using my trick for a postponed method execution ( see my today's
    post Re: SubmitButton Example ).

    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
    >
    >
  • No.6 | | 6020 bytes | |

    Yea it is a Gotcha

    I use the redirection code that Paul Ferraro wrote and it works :D thank you!!!!
    I think Konstantin aproach is also good, I will look at it later.

    If you have time, it would be great if you post some of this solutions at:
    www.tapestryforums.com
    it needs people as you :)
    If you don't have time, can I post your solutions at there?

    Thank you, have a nice day.

    2005/5/3, Konstantin Iignatyev <kgignatyev (AT) yahoo (DOT) com>:
    In short words: this behavior seems to be caused by standard Tapestry
    gotcha:
    Form and Submit Listeners: Matters

    Do not do submit, use DirectLink
    or try using my trick for a postponed method execution ( see my today's
    post Re: SubmitButton Example ).

    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
    >
    >
    >
    >

Re: Stale Link


max 4000 letters.
Your nickname that display:
In order to stop the spam: 1 + 0 =
QUESTION ON "Java"

EMSDN.COM