Abort render?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Abort render?

basilpilaf
Hi All,

Is there a way to abort a render in the middle of a form rewind?
I am using the  'For' component from T-deli and when the following
situation occurs, I want the render to abort and an error message
to be displayed:

User-A loads a page with a form list of books.
User-B loads the same list.

User-A buys a book, effectively removing it from the inventory.
After User-A checks the book out, but before User-B refreshes
his screen he tries to reserve the book (modifying the record)
but the record no longer exists.

Now the 'For' component prevents a stale link exception from
occurring, but when the Form is rendering itself again, it tries
to render the now-null record and retrieve it's primary key.  I
can catch the exception, but I want tapestry to abort the render
and reload the page from scratch while setting an error message:
"Another user has removed the record you were working with"

Is there any way to achieve this?
Filip

PS
I tried to throw a  pageRedirectException() but tapestry just
displays the exception instead of re-directing the page.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Abort render?

Geoff Longman
Why not just add a string property to the page and set it to your
message when this situation occurs?

ie.

(in page Spec)

<property-specification name="error" type="java.lang.String" persistent="no"/>

In java:

public abstract setError(String message);

Then just catch your exception and call setError("Another user has
removed the record you were working with");

In the page template

<span jwcid="@Conditional" condition="ognl:error">
   <span jwcid="@Insert" value="ognl:error"/>
</span>

On 5/12/05, Filip Balas <[hidden email]> wrote:

> Hi All,
>
> Is there a way to abort a render in the middle of a form rewind?
> I am using the  'For' component from T-deli and when the following
> situation occurs, I want the render to abort and an error message
> to be displayed:
>
> User-A loads a page with a form list of books.
> User-B loads the same list.
>
> User-A buys a book, effectively removing it from the inventory.
> After User-A checks the book out, but before User-B refreshes
> his screen he tries to reserve the book (modifying the record)
> but the record no longer exists.
>
> Now the 'For' component prevents a stale link exception from
> occurring, but when the Form is rendering itself again, it tries
> to render the now-null record and retrieve it's primary key.  I
> can catch the exception, but I want tapestry to abort the render
> and reload the page from scratch while setting an error message:
> "Another user has removed the record you were working with"
>
> Is there any way to achieve this?
> Filip
>
> PS
> I tried to throw a  pageRedirectException() but tapestry just
> displays the exception instead of re-directing the page.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]