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;
}
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());
}
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));
}
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)));
}
}
}
}
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));
}
}
}
Aggregations