in tapestry-examples/Vlib/src/org/apache/tapestry/vlib/pages/EditBook.java [99:165]
public void formSubmit(IRequestCycle cycle)
{
Map attributes = getAttributes();
Integer publisherId = (Integer) attributes.get("publisherId");
String publisherName = getPublisherName();
if (publisherId == null && Tapestry.isBlank(publisherName))
{
setErrorField("inputPublisherName", getMessage("need-publisher-name"));
return;
}
if (publisherId != null && Tapestry.isNonBlank(publisherName))
{
setErrorField("inputPublisherName", getMessage("leave-publisher-name-empty"));
return;
}
// Check for an error from a validation field
if (isInError())
return;
// OK, do the update.
VirtualLibraryEngine vengine = (VirtualLibraryEngine)cycle.getEngine();
Integer bookId = getBookId();
int i = 0;
while (true)
{
IOperations bean = vengine.getOperations();
try
{
if (publisherId != null)
bean.updateBook(bookId, attributes);
else
{
bean.updateBook(bookId, attributes, publisherName);
vengine.clearCache();
}
break;
}
catch (FinderException ex)
{
throw new ApplicationRuntimeException(ex);
}
catch (CreateException ex)
{
throw new ApplicationRuntimeException(ex);
}
catch (RemoteException ex)
{
vengine.rmiFailure("Remote exception updating book #" + bookId + ".", ex, i++);
continue;
}
}
MyLibrary page = (MyLibrary) cycle.getPage("MyLibrary");
page.setMessage(format("updated-book", attributes.get("title")));
page.activate(cycle);
}