当前位置: 首页>>代码示例>>Java>>正文


Java BindException.getErrorCount方法代码示例

本文整理汇总了Java中org.springframework.validation.BindException.getErrorCount方法的典型用法代码示例。如果您正苦于以下问题:Java BindException.getErrorCount方法的具体用法?Java BindException.getErrorCount怎么用?Java BindException.getErrorCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.validation.BindException的用法示例。


在下文中一共展示了BindException.getErrorCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleOnSubmit

import org.springframework.validation.BindException; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleOnSubmit(HttpServletRequest request, HttpServletResponse response,
        Object command, BindException errors) throws Exception {
    Long userId = SecurityHelper.assertCurrentUserId();

    UserProfileChangeEmailForm form = (UserProfileChangeEmailForm) command;

    ModelAndView mav = null;

    if (userId != null) {
        mav = doConfigUser(request, response, form, userId, errors);
    }

    if (errors.getErrorCount() > 0 || mav == null) {
        mav = showForm(request, errors, getFormView());
    }

    return mav;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:23,代码来源:UserProfileChangeEmailController.java

示例2: doUpdateProfile

import org.springframework.validation.BindException; //导入方法依赖的package包/类
/**
 * Update a user profile
 *
 * @param request
 *            the request
 * @param response
 *            the response
 * @param userId
 *            the ID of the user whose profile will be updated
 * @param form
 *            the form backing object
 * @param errors
 *            object to bind errors
 * @return the new model and view or null in case of exception
 */
private ModelAndView doUpdateProfile(HttpServletRequest request, HttpServletResponse response,
        UserProfileForm form, BindException errors, Long userId) {

    try {
        if (errors.getErrorCount() == 0) {
            SaveInTransaction inTransaction = new SaveInTransaction(userId, form);

            ServiceLocator.findService(TransactionManagement.class).execute(inTransaction);

            ModelAndView modelAndView = new ModelAndView(getFormView(), getCommandName(), form);

            if (userId == SecurityHelper.getCurrentUserId()) {
                SessionHandler.instance().currentUserLocaleChanged(request);
            }

            ControllerHelper.setApplicationSuccess(response);
            MessageHelper.saveMessageFromKey(request,
                    "client.user.management.save.profile.success");

            return modelAndView;
        }
    } catch (Exception e) {
        errors.rejectValue("globalError", "user.profile.update.error", "Update error");

        ControllerHelper.setApplicationFailure(response);
        MessageHelper.saveErrorMessageFromKey(request,
                "client.user.management.save.profile.error");

        LOG.error("Error updating profile: " + e.getMessage(), e);
    }
    return null;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:48,代码来源:UserManagementUserProfileController.java

示例3: handleOnSubmit

import org.springframework.validation.BindException; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleOnSubmit(HttpServletRequest request, HttpServletResponse response,
        Object command, BindException errors) throws Exception {
    UserProfileForm form = (UserProfileForm) command;
    ModelAndView mav = null;
    Long userId = SecurityHelper.getCurrentUserId();
    if (userId != null) {
        mav = doUpdateProfile(request, response, form, errors, userId);
    }
    if (errors.getErrorCount() > 0 || mav == null) {
        mav = showForm(request, errors, getFormView());
    }
    return mav;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:18,代码来源:UserProfileDetailsController.java

示例4: handleOnSubmit

import org.springframework.validation.BindException; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleOnSubmit(HttpServletRequest request, HttpServletResponse response,
        Object command, BindException errors) throws Exception {

    ModelAndView mav = handelAction(request, response, errors, command);

    if (mav == null || errors.getErrorCount() > 0) {
        mav = showForm(request, errors, getFormView());
    }

    return mav;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:16,代码来源:ClientProfileController.java

示例5: getModelAndView

import org.springframework.validation.BindException; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView getModelAndView(HttpServletRequest request,
        HttpServletResponse response, Object command, BindException errors) throws Exception {
    if (errors.getErrorCount() > 0) {
        return showForm(request, errors, getFormView());
    }
    MessageHelper.saveMessage(request,
            ResourceBundleManager.instance().getText("client.invitation.email.send.succesful",
                    SessionHandler.instance().getCurrentLocale(request)));
    return ControllerHelper.replaceModuleInMAV(new ModelAndView(getSuccessView(), "command",
            formBackingObject(request)));
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:16,代码来源:InviteUserToClientController.java

示例6: handleOnSubmit

import org.springframework.validation.BindException; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @throws Exception
 * @see com.communote.server.web.commons.controller.BaseFormController#handleOnSubmit(javax.servlet
 *      .http.HttpServletRequest, javax.servlet.http.HttpServletResponse, Object,
 *      org.springframework.validation.BindException)
 */
@Override
protected ModelAndView handleOnSubmit(HttpServletRequest request, HttpServletResponse response,
        Object command, BindException errors) throws Exception {
    InviteUserForm form = (InviteUserForm) command;
    validateForm(form, errors);
    boolean success = false;
    if (errors.getErrorCount() == 0) {
        try {
            UserVO userToInvite = getUserToInvite(form);
            if (userToInvite != null) {
                userToInvite.setRoles(new UserRole[] { UserRole.ROLE_KENMEI_USER });
                if (userToInvite.getLanguage() == null) {
                    userToInvite.setLanguage(getUserLocaleWithFallback(form));
                }
                success = inviteUser(request, response, form, errors, userToInvite);
            } else {
                // well it only can be an external user
                String field = getExternalUsernameErrorField(getErrorFields(form
                        .getInvitationProvider()));
                if (field == null) {
                    field = getAliasErrorField(getErrorFields(form.getInvitationProvider()));
                }
                errors.rejectValue(field, "error.external.user.not.found",
                        "The external user does not exist!");
            }
        } catch (DataAccessException e) {
            LOG.warn(e.getMessage());
            MessageHelper.saveErrorMessageFromKey(request, "error.external.system.down");
            errors.reject("error.external.system.down");
        }
        if (success) {
            ControllerHelper.setApplicationSuccess(response);
        } else {
            ControllerHelper.setApplicationFailure(response);
        }
    }
    request.setAttribute("anErrorOccured", errors.getErrorCount() != 0);
    return getModelAndView(request, response, command, errors);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:48,代码来源:AbstractUserInviteController.java

示例7: handleOnSubmit

import org.springframework.validation.BindException; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleOnSubmit(HttpServletRequest request, HttpServletResponse response,
        Object command, BindException errors) throws Exception {
    ModelAndView mav;
    Long currentUserId = SecurityHelper.assertCurrentUserId();
    Blog blog;
    BlogManagementForm form = (BlogManagementForm) command;
    if (StringUtils.equals(form.getAction(), FormAction.CREATE) && form.getBlogId() == null) {
        blog = createTopic(createTopicTO(currentUserId, form), request, errors);
    } else if (StringUtils.equals(form.getAction(), FormAction.EDIT)
            && form.getBlogId() != null) {
        blog = updateTopic(form.getBlogId(), createTopicTO(currentUserId, form), request,
                errors);
    } else {
        throw new RuntimeException("invalid formular state");
    }
    if (blog != null) {
        updateForm(form, blog);
    }
    if (errors.getErrorCount() > 0 || blog == null) {
        ControllerHelper.setApplicationFailure(response);
        mav = showForm(request, errors, getFormView());
    } else {
        ControllerHelper.setApplicationSuccess(response);
        mav = new ModelAndView(this.getFormView(), getCommandName(), form);
    }
    return mav;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:32,代码来源:BlogManagementController.java

示例8: doUpdateProfile

import org.springframework.validation.BindException; //导入方法依赖的package包/类
/**
 * Update a user profile
 *
 * @param request
 *            the request
 * @param response
 *            the response
 * @param userId
 *            the ID of the user whose profile will be updated
 * @param form
 *            the form backing object
 * @param errors
 *            object to bind errors
 * @return the new model and view or null in case of exception
 */
private ModelAndView doUpdateProfile(final HttpServletRequest request,
        final HttpServletResponse response, final UserProfileForm form, BindException errors,
        final Long userId) {
    if (errors.getErrorCount() != 0) {
        return null;
    }
    try {
        ServiceLocator.instance().getService(TransactionManagement.class)
                .execute(new RunInTransaction() {
                    @Override
                    public void execute() throws TransactionException {
                        UserManagement userManagement = ServiceLocator.instance().getService(
                        UserManagement.class);
                        userManagement.updateLanguage(userId, form.getLanguageCode());
                        ServiceLocator.findService(UserProfileManagement.class)
                                .updateUserProfile(userId, form.getUserProfile());
                        String[] tagsAsStringArray = TagParserFactory.instance()
                                .getDefaultTagParser().parseTags(form.getTags());
                        Set<TagTO> tags = new HashSet<TagTO>();
                        for (String tag : tagsAsStringArray) {
                            tags.add(new TagTO(tag, Types.ENTITY.getDefaultTagStoreId()));
                        }
                        userManagement.updateUserTags(userId, tags);

                    }
                });

        // change the language
        SessionHandler.instance().currentUserLocaleChanged(request);

        String message = MessageHelper.getText(request, "user.profile.update.success");
        MessageHelper.saveMessage(request, message);
        ControllerHelper.setApplicationSuccess(response);

        return new ModelAndView(getFormView(), getCommandName(), form);
    } catch (Exception e) {
        // TODO error messages is not informative
        errors.reject("user.profile.update.error", "Update error");
        LOGGER.error("Error updating profile: {}", e.getMessage(), e);
        ControllerHelper.setApplicationFailure(response);
    }
    return null;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:59,代码来源:UserProfileDetailsController.java


注:本文中的org.springframework.validation.BindException.getErrorCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。