You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bruno Santos <bi...@gmail.com> on 2009/09/10 23:55:01 UTC

Exception handling + @CommitAfter

Good evening,

I have a form using a zone and i have @CommitAfter on the
onSubmitFromEntityForm()

<t:form t:id="entityForm" zone="entityZone">
<input type="text" t:type="textfield" t:id="name"
					t:value="entity.name" />
</t:form>

@CommitAfter
Object onSubmitFromEntityForm() {
 ....
try {
entityDao.persist(entity);
} catch (exception ex) {
 // handle exception
}
}

altough i'm handling the exception the @CommitAfter creates a new
exception since it tries to commit something that's not in transaction
due to catched exception.

How to deal with this? Is there a way to avoid the @CommitAfter to
execute ... a handler i can use? I think i can remove the @CommitAfter
but don't believe this should be first option.

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


Re: Exception handling + @CommitAfter

Posted by Kalle Korhonen <ka...@gmail.com>.
You should instead try storing it onValidate. If it fails, you should
record an error and if it succeeds you should commit only in onSuccess
(but the method body can be otherwise empty).

Kalle


On Thu, Sep 10, 2009 at 2:55 PM, Bruno Santos <bi...@gmail.com> wrote:
> Good evening,
>
> I have a form using a zone and i have @CommitAfter on the
> onSubmitFromEntityForm()
>
> <t:form t:id="entityForm" zone="entityZone">
> <input type="text" t:type="textfield" t:id="name"
>                                        t:value="entity.name" />
> </t:form>
>
> @CommitAfter
> Object onSubmitFromEntityForm() {
>  ....
> try {
> entityDao.persist(entity);
> } catch (exception ex) {
>  // handle exception
> }
> }
>
> altough i'm handling the exception the @CommitAfter creates a new
> exception since it tries to commit something that's not in transaction
> due to catched exception.
>
> How to deal with this? Is there a way to avoid the @CommitAfter to
> execute ... a handler i can use? I think i can remove the @CommitAfter
> but don't believe this should be first option.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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