use of org.apache.struts.action.ActionMessage in project head by mifos.
the class QuestionnaireFlowAdapter method populateNumericError.
private void populateNumericError(BadNumericResponseException exception, ActionErrors actionErrors) {
String title = exception.getIdentifier();
Integer allowedMinValue = exception.getAllowedMinValue();
Integer allowedMaxValue = exception.getAllowedMaxValue();
if (exception.areMinMaxBoundsPresent()) {
ActionMessage actionMessage = new ActionMessage(ClientConstants.INVALID_NUMERIC_RANGE_RESPONSE, allowedMinValue, allowedMaxValue, title);
actionErrors.add(ClientConstants.INVALID_NUMERIC_RANGE_RESPONSE, actionMessage);
} else if (exception.isMinBoundPresent()) {
ActionMessage actionMessage = new ActionMessage(ClientConstants.INVALID_NUMERIC_MIN_RESPONSE, allowedMinValue, title);
actionErrors.add(ClientConstants.INVALID_NUMERIC_MIN_RESPONSE, actionMessage);
} else if (exception.isMaxBoundPresent()) {
ActionMessage actionMessage = new ActionMessage(ClientConstants.INVALID_NUMERIC_MAX_RESPONSE, allowedMaxValue, title);
actionErrors.add(ClientConstants.INVALID_NUMERIC_MAX_RESPONSE, actionMessage);
} else {
ActionMessage actionMessage = new ActionMessage(ClientConstants.INVALID_NUMERIC_RESPONSE, title);
actionErrors.add(ClientConstants.INVALID_NUMERIC_RESPONSE, actionMessage);
}
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class QuestionnaireFlowAdapter method validateResponses.
public ActionErrors validateResponses(HttpServletRequest request, QuestionResponseCapturer form) {
List<QuestionGroupDetail> groups = form.getQuestionGroups();
QuestionnaireServiceFacade questionnaireServiceFacade = serviceLocator.getService(request);
if ((groups == null) || (questionnaireServiceFacade == null)) {
return null;
}
ActionErrors errors = new ActionErrors();
try {
questionnaireServiceFacade.validateResponses(groups);
} catch (ValidationException e) {
if (e.hasChildExceptions()) {
for (ValidationException ve : e.getChildExceptions()) {
if (ve instanceof MandatoryAnswerNotFoundException) {
errors.add(ClientConstants.ERROR_REQUIRED, new ActionMessage(ClientConstants.ERROR_REQUIRED, ve.getIdentifier()));
} else if (ve instanceof BadNumericResponseException) {
populateNumericError((BadNumericResponseException) ve, errors);
}
}
}
}
setQuestionnaireAttributesToRequest(request, form);
return errors;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class CollectionSheetEntryAction method setErrorMessagesIfErrorsExist.
private void setErrorMessagesIfErrorsExist(final HttpServletRequest request, final CollectionSheetErrorsDto collectionSheetErrors) {
final String savingsWithdrawal = getLocalizedMessage(CollectionSheetEntryConstants.SAVING_WITHDRAWAL);
final String savingsDeposit = getLocalizedMessage(CollectionSheetEntryConstants.SAVING_DEPOSIT);
final String loanDisbursement = getLocalizedMessage(CollectionSheetEntryConstants.LOAN_DISBURSEMENT);
final String loanRepayment = getLocalizedMessage(CollectionSheetEntryConstants.LOAN_REPAYMENT);
final String acCollection = getLocalizedMessage(CollectionSheetEntryConstants.AC_COLLECTION);
final StringBuilder builder = new StringBuilder();
final ActionErrors actionErrors = new ActionErrors();
final boolean savingsOrCollectionsErrors = collectionSheetErrors.getSavingsDepNames().size() > 0 || collectionSheetErrors.getSavingsWithNames().size() > 0 || collectionSheetErrors.getLoanDisbursementAccountNumbers().size() > 0 || collectionSheetErrors.getLoanRepaymentAccountNumbers().size() > 0 || collectionSheetErrors.getCustomerAccountNumbers().size() > 0;
final boolean persistenceError = collectionSheetErrors.isDatabaseError();
if (savingsOrCollectionsErrors) {
getErrorString(builder, collectionSheetErrors.getSavingsDepNames(), savingsDeposit);
getErrorString(builder, collectionSheetErrors.getSavingsWithNames(), savingsWithdrawal);
getErrorString(builder, collectionSheetErrors.getLoanDisbursementAccountNumbers(), loanDisbursement);
getErrorString(builder, collectionSheetErrors.getLoanRepaymentAccountNumbers(), loanRepayment);
getErrorString(builder, collectionSheetErrors.getCustomerAccountNumbers(), acCollection);
builder.append("<br><br>");
actionErrors.add(CollectionSheetEntryConstants.ERRORSUPDATE, new ActionMessage(CollectionSheetEntryConstants.ERRORSUPDATE, builder.toString()));
}
if (persistenceError) {
actionErrors.add(CollectionSheetEntryConstants.DATABASE_ERROR, new ActionMessage(CollectionSheetEntryConstants.DATABASE_ERROR, collectionSheetErrors.getDatabaseError()));
}
if (savingsOrCollectionsErrors || persistenceError) {
request.setAttribute(Globals.ERROR_KEY, actionErrors);
}
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class ClientCustActionForm method addInvalidPictureError.
private void addInvalidPictureError(ActionErrors errors, String message) {
errors.add(ClientConstants.INVALID_PHOTO, new ActionMessage(ClientConstants.INVALID_PHOTO, message));
this.picture = null;
this.customerPicture = null;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class ClientCustActionForm method checkForMandatoryFields.
@SuppressWarnings("unchecked")
@Override
public void checkForMandatoryFields(Short entityId, ActionErrors errors, HttpServletRequest request) {
Map<Short, List<FieldConfigurationEntity>> entityMandatoryFieldMap = (Map<Short, List<FieldConfigurationEntity>>) request.getSession().getServletContext().getAttribute(Constants.FIELD_CONFIGURATION);
List<FieldConfigurationEntity> mandatoryfieldList = entityMandatoryFieldMap.get(entityId);
for (FieldConfigurationEntity fieldConfigurationEntity : mandatoryfieldList) {
String propertyName = request.getParameter(fieldConfigurationEntity.getLabel());
UserContext userContext = ((UserContext) request.getSession().getAttribute(LoginConstants.USERCONTEXT));
if (propertyName != null && !propertyName.equals("") && !propertyName.equalsIgnoreCase("picture")) {
String propertyValue = request.getParameter(propertyName);
if (propertyValue == null || propertyValue.equals("")) {
errors.add(fieldConfigurationEntity.getLabel(), new ActionMessage(FieldConfigurationConstant.EXCEPTION_MANDATORY, FieldConfigurationHelper.getLocalSpecificFieldNames(fieldConfigurationEntity.getLabel(), userContext)));
}
} else if (propertyName != null && !propertyName.equals("") && propertyName.equalsIgnoreCase("picture")) {
try {
if (getCustomerPicture() == null || getCustomerPicture().read() == -1) {
errors.add(fieldConfigurationEntity.getLabel(), new ActionMessage(FieldConfigurationConstant.EXCEPTION_MANDATORY, FieldConfigurationHelper.getLocalSpecificFieldNames(fieldConfigurationEntity.getLabel(), userContext)));
}
getCustomerPicture().reset();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
}
Aggregations