public class BaseDS extends DataSource { ... public BaseDS(EntityInfo entityInfo) { setID(entityInfo.getName()); setDataFormat(DSDataFormat.JSON); // only controls data received with fetch setWillHandleAdvancedCriteria(true); setSendExtraFields(true); if (entityInfo.hasAnnotation("Title")) { AnnotationInfo a = entityInfo.getAnnotation("Title"); setTitle((String) a.getAttribute("title")); setPluralTitle((String) a.getAttribute("plural")); } else { setTitle(entityInfo.getName()); } entityFieldBegin(entityInfo); addFields(entityInfo, "", true); if (entityInfo.isEntity()) setupBindings(entityInfo); } ... protected void setupBindings(EntityInfo entityInfo) { setDataURL(getCrudUrl() + "/" + entityInfo.getName()); setDropExtraFields(false); setRecordXPath("data"); OperationBinding fetch = new OperationBinding(); fetch.setOperationType(DSOperationType.FETCH); fetch.setDataProtocol(DSProtocol.GETPARAMS); OperationBinding remove = new OperationBinding(); remove.setOperationType(DSOperationType.REMOVE); remove.setDataProtocol(DSProtocol.GETPARAMS); DSRequest removeRequest = new DSRequest(); removeRequest.setHttpMethod("DELETE"); remove.setRequestProperties(removeRequest); OperationBinding update = new OperationBinding(); update.setOperationType(DSOperationType.UPDATE); update.setDataProtocol(DSProtocol.POSTMESSAGE); DSRequest updateRequest = new DSRequest(); updateRequest.setContentType("application/json"); update.setRequestProperties(updateRequest); OperationBinding add = new OperationBinding(); add.setOperationType(DSOperationType.ADD); add.setDataProtocol(DSProtocol.POSTMESSAGE); DSRequest addRequest = new DSRequest(); addRequest.setHttpMethod("PUT"); addRequest.setContentType("application/json"); add.setRequestProperties(addRequest); setOperationBindings(fetch, remove, update, add); addHandleErrorHandler(new HandleErrorHandler() { @Override public void onHandleError(ErrorEvent event) { DSResponse response = event.getResponse(); String timeStamp = new Date().toString(); // Missing Datastore Index if (response.getStatus() == -9) SC.say("This view button or combination filter/sort is not an option for this form.
If this is needed to support your business processes, please open a ticket to the Email Application Support team to initiate a review."); // Dirty Write else if (response.getStatus() == -11) SC.say("Data Error", "An error occurred while processing this request. This form may have already been modified by another user. Please refresh your data to see the latest version, and then retry your action if necessary."); else if (response.getStatus() == -12) SC.say("Data Error", "An error occurred while attempting to save the data in this form. Please try again in a few moments."); else SC.say("Unexpected Error","An unexpected problem has occurred.
DateTime of error: " + timeStamp +"
(error:" + response.getAttribute("errorDetail") + " rpc:"+response.getStatus()+")
"); if (response.getHttpResponseCode() == 200) { log.log(Level.SEVERE,response.getAttribute("errorDetail")); } else { @SuppressWarnings("unchecked") Map headers = response.getHttpHeaders(); log.log(Level.SEVERE,headers.get("errorDetail")); } event.cancel(); } }); } ... }