Hi All,
Is that true? I read a comment somewhere which was saying that any uncaught exception would cause Seam to close the opened connection (hence preventing the next phases from accessing it...?)
I noticed that when adding a validation method to the input tag that queries the database and afterwards throws an ValidationException if not valid. Then the selectItems (on the same rerendered page) would try to execute a entityquery.getResultList() which results in a transaction - closed exception...
Did I interpret this correctly? If so, is there any way around it?
Any help or hint appreciated,
Tino
my xhtml:
... <q:field helpText="Please enter an alpha-numerical value" fieldId="receipt_receiptId"> <h:inputText styleClass="editEntity" id="receipt_receiptId" validator="#{receiptHome.validateUniqueReceiptId}" value="#{receiptHome.instance.receiptId}" required="true" requiredMessage="Please enter a valid receipt ID" > </h:inputText> </q:field> <q:field fieldId="receipt_rep"> <h:selectOneMenu id="receipt_rep" value="#{receiptHome.instance.rep}"> <si:selectItems value="#{allUserList.resultList}" var="user" label="#{user.stringRep}" noSelectionLabel="Select one..."/> </h:selectOneMenu> </q:field> ...
public void validateUniqueReceiptId(FacesContext context, UIComponent component, Object value) throws ValidatorException { if(isManaged() && getInstance().getReceiptId().equals(value.toString())){ return; } List existing = fetchReceiptList(value); if (existing.size() > 0) { throwValidationError("Receipt with this ID already exists", component); } }
Fixed in recent versions of Seam (Seam 2)