use of org.apache.struts.action.ActionMessage in project head by mifos.
the class ClientCustActionForm method validateFamilyOneSpouseOrFather.
public void validateFamilyOneSpouseOrFather(ActionErrors errors) {
int spouseCount = 0;
int fatherCount = 0;
for (int row = 0; row < familyRelationship.size(); row++) {
if (familyRelationship.get(row) != null) {
if (familyRelationship.get(row) == 2) {
fatherCount++;
}
if (familyRelationship.get(row) == 1) {
spouseCount++;
}
}
}
if (spouseCount > 1) {
errors.add(ClientConstants.INVALID_NUMBER_OF_SPOUSES, new ActionMessage(ClientConstants.INVALID_NUMBER_OF_SPOUSES));
}
if (fatherCount > 1) {
errors.add(ClientConstants.INVALID_NUMBER_OF_FATHERS, new ActionMessage(ClientConstants.INVALID_NUMBER_OF_FATHERS));
}
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class ClientCustActionForm method validateTrained.
@Override
protected void validateTrained(HttpServletRequest request, ActionErrors errors) {
super.validateTrained(request, errors);
try {
Locale locale = getUserContext(request).getPreferredLocale();
Date trainedDate = getTrainedDateValue(locale);
Date dob = getDateFromString(getDateOfBirth(), locale);
if (trainedDate != null && dob != null && DateUtils.dateFallsBeforeDate(trainedDate, dob)) {
errors.add(CustomerConstants.TRAINED_DATE_BEFORE_DOB, new ActionMessage(CustomerConstants.TRAINED_DATE_BEFORE_DOB, getDateOfBirth()));
}
} catch (InvalidDateException ex) {
//already validated in super
}
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class CustSearchAction method mainSearch.
@TransactionDemarcate(joinToken = true)
public ActionForward mainSearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
CustSearchActionForm actionForm = (CustSearchActionForm) form;
Short officeId = getShortValue(actionForm.getOfficeId());
String searchString = actionForm.getSearchString();
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USERCONTEXT, request.getSession());
super.search(mapping, form, request, response);
if (searchString == null || searchString.equals("")) {
ActionErrors errors = new ActionErrors();
errors.add(CustomerSearchConstants.NAMEMANDATORYEXCEPTION, new ActionMessage(CustomerSearchConstants.NAMEMANDATORYEXCEPTION));
request.setAttribute(Globals.ERROR_KEY, errors);
return mapping.findForward(ActionForwards.mainSearch_success.toString());
}
if (officeId != null && officeId != 0) {
addSeachValues(searchString, officeId.toString(), new OfficePersistence().getOffice(officeId).getOfficeName(), request);
} else {
addSeachValues(searchString, officeId.toString(), new OfficePersistence().getOffice(userContext.getBranchId()).getOfficeName(), request);
}
searchString = SearchUtils.normalizeSearchString(searchString);
if (searchString.equals("")) {
throw new CustomerException(CustomerSearchConstants.NAMEMANDATORYEXCEPTION);
}
if (actionForm.getFilters() == null) {
actionForm.setFilters(new SearchFiltersDto());
}
QueryResult customerSearchResult = new CustomerPersistence().search(searchString, officeId, userContext.getId(), userContext.getBranchId(), actionForm.getFilters());
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, customerSearchResult, request);
return mapping.findForward(ActionForwards.mainSearch_success.toString());
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class GroupCustActionForm method validateFields.
@Override
protected ActionErrors validateFields(HttpServletRequest request, String method) throws ApplicationException {
ActionErrors errors = new ActionErrors();
try {
if (method.equals(Methods.previewManage.toString())) {
validateName(errors);
validateTrained(request, errors);
validateConfigurableMandatoryFields(request, errors, EntityType.GROUP);
validateCustomFieldsForCustomers(request, errors);
} else if (method.equals(Methods.preview.toString()) || method.equals(Methods.previewOnly.toString())) {
validateName(errors);
validateLO(errors);
validateFormedByPersonnel(errors);
validateTrained(request, errors);
validateConfigurableMandatoryFields(request, errors, EntityType.GROUP);
validateCustomFieldsForCustomers(request, errors);
validateFees(request, errors);
}
} 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(GroupConstants.METHODCALLED, method);
}
return errors;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class PersonActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
String method = request.getParameter("method");
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
request.getSession().setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
if (method.equals(Methods.preview.toString())) {
handleCreatePreviewValidations(errors, request);
}
if (method.equals(Methods.previewManage.toString())) {
handleManagePreviewValidations(errors, request);
}
if (method.equals(Methods.search.toString())) {
if (StringUtils.isBlank(searchString)) {
try {
cleanUpSearch(request);
} catch (PageExpiredException e) {
errors.add(ExceptionConstants.PAGEEXPIREDEXCEPTION, new ActionMessage(ExceptionConstants.PAGEEXPIREDEXCEPTION));
}
errors.add(PersonnelConstants.NO_SEARCH_STRING, new ActionMessage(PersonnelConstants.NO_SEARCH_STRING));
}
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
try {
updateRoleLists(request);
} catch (PageExpiredException e) {
errors.add(ExceptionConstants.PAGEEXPIREDEXCEPTION, new ActionMessage(ExceptionConstants.PAGEEXPIREDEXCEPTION));
}
}
return errors;
}
Aggregations