Search in sources :

Example 1 with ActionMessage

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);
    }
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage)

Example 2 with 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;
}
Also used : BadNumericResponseException(org.mifos.platform.questionnaire.exceptions.BadNumericResponseException) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) ValidationException(org.mifos.platform.validations.ValidationException) MandatoryAnswerNotFoundException(org.mifos.platform.questionnaire.exceptions.MandatoryAnswerNotFoundException) ActionMessage(org.apache.struts.action.ActionMessage) QuestionnaireServiceFacade(org.mifos.platform.questionnaire.service.QuestionnaireServiceFacade) ActionErrors(org.apache.struts.action.ActionErrors)

Example 3 with ActionMessage

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);
    }
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 4 with ActionMessage

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;
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage)

Example 5 with ActionMessage

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);
            }
        }
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) ActionMessage(org.apache.struts.action.ActionMessage) FieldConfigurationEntity(org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) Map(java.util.Map)

Aggregations

ActionMessage (org.apache.struts.action.ActionMessage)166 ActionErrors (org.apache.struts.action.ActionErrors)70 ActionMessages (org.apache.struts.action.ActionMessages)45 ResourceBundle (java.util.ResourceBundle)29 JspException (javax.servlet.jsp.JspException)22 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)22 Iterator (java.util.Iterator)21 Locale (java.util.Locale)19 List (java.util.List)9 ActionForward (org.apache.struts.action.ActionForward)9 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)8 ArrayList (java.util.ArrayList)8 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)7 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)7 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)6 IOException (java.io.IOException)6 Date (java.sql.Date)6 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)6 ApplicationException (org.mifos.framework.exceptions.ApplicationException)5 UserPersistence (cn.edu.zju.acm.onlinejudge.persistence.UserPersistence)4