Search in sources :

Example 26 with ActionMessage

use of org.apache.struts.action.ActionMessage in project head by mifos.

the class ApplyAdjustmentActionForm method validate.

@Override
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
    if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
        request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
    }
    ActionErrors actionErrors = new ActionErrors();
    String method = request.getParameter("method");
    if (null != method && method.equals("previewAdjustment")) {
        /*            if (!adjustcheckbox) {
                request.setAttribute("method", "loadAdjustment");
                actionErrors.add("", new ActionMessage("errors.mandatorycheckbox"));
            }*/
        if (!adjustcheckbox) {
            validateAmount(actionErrors);
            validatePaymentType(actionErrors);
            validateTransactionDate(actionErrors);
        }
        if (adjustmentNote == null || adjustmentNote.trim() == "") {
            request.setAttribute("method", "loadAdjustment");
            actionErrors.add("", new ActionMessage("errors.mandatorytextarea"));
        } else if (adjustmentNote.length() > 300) {
            request.setAttribute("method", "loadAdjustment");
            actionErrors.add("", new ActionMessage("errors.adjustmentNoteTooBig"));
        }
        if (!actionErrors.isEmpty()) {
            request.setAttribute("method", "loadAdjustment");
            return actionErrors;
        }
    }
    return actionErrors;
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 27 with ActionMessage

use of org.apache.struts.action.ActionMessage in project head by mifos.

the class BaseAction method shutdown.

private ActionForward shutdown(ActionMapping mapping, HttpServletRequest request) {
    request.getSession(false).invalidate();
    ActionErrors error = new ActionErrors();
    error.add(LoginConstants.SHUTDOWN, new ActionMessage(messages.getMessage(LoginConstants.SHUTDOWN, "You have been logged out of the system because Mifos is shutting down.")));
    request.setAttribute(Globals.ERROR_KEY, error);
    return mapping.findForward(ActionForwards.load_main_page.toString());
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 28 with ActionMessage

use of org.apache.struts.action.ActionMessage in project head by mifos.

the class SessionUtils method addWarningMessage.

public static void addWarningMessage(HttpServletRequest request, String key, Object... values) throws PageExpiredException {
    ActionMessages warningMessages = null;
    if (request.getAttribute(MIFOS_WARNING_MESSAGES) == null) {
        warningMessages = new ActionMessages();
        request.setAttribute(MIFOS_WARNING_MESSAGES, warningMessages);
    } else {
        warningMessages = (ActionMessages) getAttribute(MIFOS_WARNING_MESSAGES, request);
    }
    warningMessages.add(key, new ActionMessage(key, values));
}
Also used : ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage)

Example 29 with ActionMessage

use of org.apache.struts.action.ActionMessage in project head by mifos.

the class BaseActionForm method checkForMandatoryFields.

protected 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());
        if (propertyName != null && !propertyName.equals("")) {
            String propertyValue = request.getParameter(propertyName);
            UserContext userContext = ((UserContext) request.getSession().getAttribute(LoginConstants.USERCONTEXT));
            if (propertyValue == null || propertyValue.equals("")) {
                errors.add(fieldConfigurationEntity.getLabel(), new ActionMessage(FieldConfigurationConstant.EXCEPTION_MANDATORY, FieldConfigurationHelper.getLocalSpecificFieldNames(fieldConfigurationEntity.getLabel(), userContext)));
            }
        }
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) ActionMessage(org.apache.struts.action.ActionMessage) FieldConfigurationEntity(org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity) List(java.util.List) Map(java.util.Map)

Example 30 with ActionMessage

use of org.apache.struts.action.ActionMessage in project head by mifos.

the class LoanAccountActionForm method validatePaymentDataHtmlBean.

private void validatePaymentDataHtmlBean(ActionErrors errors, MifosCurrency currency, Locale locale, CustomerBO customer, PaymentDataHtmlBean bean) throws MeetingException, InvalidDateException {
    validateTransactionDateOnPayment(errors, bean);
    if (bean.hasValidAmount() && bean.hasTransactionDate()) {
        if (customer.isValidMeetingDate(bean.getTransactionDate())) {
            validateTotalAmount(errors, locale, currency, bean);
            validateTransactionDate(errors, bean, getDisbursementDateValue(locale));
        } else {
            errors.add(LoanExceptionConstants.INVALIDTRANSACTIONDATE, new ActionMessage(LoanExceptionConstants.INVALIDTRANSACTIONDATE));
        }
    }
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage)

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