use of org.apache.struts.action.ActionErrors 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.ActionErrors in project head by mifos.
the class LoanDisbursementAction method captureQuestionResponses.
@TransactionDemarcate(joinToken = true)
public ActionForward captureQuestionResponses(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
request.setAttribute(METHODCALLED, "captureQuestionResponses");
ActionErrors errors = createGroupQuestionnaire.validateResponses(request, (LoanDisbursementActionForm) form);
if (errors != null && !errors.isEmpty()) {
addErrors(request, errors);
return mapping.findForward(ActionForwards.captureQuestionResponses.toString());
}
return createGroupQuestionnaire.rejoinFlow(mapping);
}
use of org.apache.struts.action.ActionErrors in project head by mifos.
the class AccountStatusActionForm method validate.
@Override
public // TODO: use localized strings for error messages rather than hardcoded
ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
String method = request.getParameter("method");
if (method.equals(Methods.searchResults.toString())) {
String branch = this.getLocalizedMessage("loan.branch");
String loanOfficer = this.getLocalizedMessage("loan.loanOfficer");
String currentStatus = this.getLocalizedMessage("loan.currentStatus");
if (StringUtils.isBlank(getOfficeId())) {
addError(errors, "officeId", "errors.mandatoryselect", branch);
}
if (StringUtils.isBlank(getPersonnelId())) {
addError(errors, "loanOfficer", "errors.mandatoryselect", loanOfficer);
}
if (StringUtils.isBlank(getCurrentStatus())) {
addError(errors, "currentStatus", "errors.mandatoryselect", currentStatus);
}
}
if (method.equals(Methods.update.toString())) {
String account = this.getLocalizedMessage("loan.account");
String notes = this.getLocalizedMessage("loan.notes");
String note = this.getLocalizedMessage("loan.note");
if (getApplicableAccountRecords().size() == 0) {
addError(errors, "records", LoanExceptionConstants.SELECT_ATLEAST_ONE_RECORD, account);
}
if (StringUtils.isBlank(getComments())) {
addError(errors, "comments", "errors.mandatory", notes);
} else if (getComments().length() > 500) {
addError(errors, "comments", "errors.maximumlength", note, "500");
}
}
if (!method.equals(Methods.validate.toString())) {
request.setAttribute("methodCalled", method);
}
return errors;
}
use of org.apache.struts.action.ActionErrors in project head by mifos.
the class LoanAccountActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String method = request.getParameter(Methods.method.toString());
ActionErrors errors = new ActionErrors();
if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
}
try {
if (method.equals(Methods.getPrdOfferings.toString())) {
checkValidationForGetPrdOfferings(errors);
} else if (method.equals(Methods.load.toString())) {
checkValidationForLoad(errors);
} else if (method.equals(Methods.schedulePreview.toString())) {
checkValidationForSchedulePreview(errors, getCurrencyFromLoanOffering(request), request);
} else if (method.equals(Methods.managePreview.toString())) {
checkValidationForManagePreview(errors, getCurrencyFromLoanOffering(request), request);
} else if (method.equals(Methods.preview.toString())) {
checkValidationForPreview(errors, getCurrencyFromLoanOffering(request), request);
}
} catch (ApplicationException ae) {
// Discard other errors (is that right?)
ae.printStackTrace();
errors = new ActionErrors();
errors.add(ae.getKey(), new ActionMessage(ae.getKey(), ae.getValues()));
}
if (!errors.isEmpty()) {
request.setAttribute(LoanConstants.METHODCALLED, method);
}
return errors;
}
use of org.apache.struts.action.ActionErrors in project head by mifos.
the class FeeActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
Locale locale = getUserContext(request).getPreferredLocale();
ActionErrors errors = new ActionErrors();
String methodCalled = request.getParameter(Methods.method.toString());
if (!methodCalled.equals(Methods.validate.toString())) {
request.setAttribute("methodCalled", methodCalled);
} else {
request.setAttribute("methodCalled", request.getAttribute("methodCalled"));
}
if (methodCalled.equals(Methods.preview.toString())) {
// fee creation
errors.add(super.validate(mapping, request));
validateForPreview(errors, locale);
} else if (methodCalled.equalsIgnoreCase(Methods.editPreview.toString())) {
// editing fees
validateForEditPreview(errors, locale);
} else if (methodCalled.equalsIgnoreCase(Methods.update.toString())) {
validateForUpdaste(errors, locale);
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
}
return errors;
}
Aggregations