Requires roll back of the current transaction.
<dsp:setTransactionRollbackOnlyvar-spec
>
...
</dsp:setTransactionRollbackOnly>
Attributes
var-spec
An EL variable or scripting variable that is defined with one of these attributes:
Attribute | Description |
---|---|
| Names an EL variable. When you use |
| Names a scripting variable that scriptlets and expressions can access at runtime. |
The variable has two properties:
success
: A Boolean property, specifies the status of thesetTransactionRollbackOnly
operation. A call toisSuccess
obtains the property’s setting.exception
: Identifies theThrowable
exception object produced when a transaction does not rollback properly. A call togetException
returns the exception object.
Usage Notes
dsp:setTransactionRollbackOnly
specifies that when the current transaction ends, it must fail and roll back. This tag does not cause a transaction to roll back now, but rather instructs the transaction to end in a rollback action when it is prompted to end.
The tag’s ability to set the current transaction to setTransactionRollbackOnly
is saved to the named EL variable. You can see tag’s success or failure through the success
property and exceptions through the exception
property.
Example
<dsp:beginTransaction var="beginAdvancedAlgebra"/> <dsp:tomap bean="/atg/samples/Student_01" var="student"/> <c:choose> <c:when test="${!student.passedBeginningAlgebra}"/> You can't take advanced because you did not pass Beginning Algebra. <dsp:setTransactionRollbackOnly var="rollbackOnlyXA"/> <c:if test="${rollbackOnlyXA.exception = !empty}"> The system is having trouble processing this information for the following reason: <c:out value="${rollbackOnlyXA.exception}"/> </c:if> </c:when> <c:otherwise> You may enroll in Advanced Algebra. </c:otherwise> </c:choose> <dsp:commitTransaction var="commitAdvancedAlgebra"/>
In this example, a transaction is used to manage the enrollment process for Advanced Algebra. After the transaction is created, the student’s record is checked for successful completion of the beginning level Algebra class. The beginning level class is a prerequisite for enrolling in the advanced class, so the transactions are set to roll back. If an error occurs and dsp:setTransactionRollbackOnly
does not set the transaction to end in a future rollback action, the exception is displayed. Otherwise, the dsp:commitTransaction
tag tries to end the transaction.