Announcement Announcement Module
No announcement yet.
fail to get message from errors.rejectValue Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • fail to get message from errors.rejectValue

    I have searched thru this forum, but could get any solution~

    My controller:
    public class UserCheckController extends AbstractWizardFormController {
    protected void onBind(HttpServletRequest request, Object command,
    BindException errors) {
    ...."> throw on bind error reject!");
    errors.rejectValue("submitAccount","management.user.duplicate","Account duplicated.");
    errors.reject("management.user.account.duplicate","Account duplicated.");
    protected void validatePage(Object command, Errors errors, int page) {
    ..."> throw error reject!");
    "Account duplicated.");
    errors.reject("management.user.duplicate","Account duplicated.");
    My jsp:
    <form name="form" method="post" action="">
    <spring:bind path="userPortfolio.*">
    <font color="red">
        <c:forEach items="${status.errorMessages}" var="error">
        Error: <c:out value="${error}"/><br/>
    <spring:hasBindErrors name="userPortfolio">
    <font color="red"><c:out value="${status.errorMessage}"/></font>
    As you can see i have tried both onbind and validatepage; reject and rejectValue; spring:bind and also spring:hasBindErrors. And also I am sure it did find the error and execute errors.reject.

    The problem is the jsp just show nothing (didn't show the error message).

    Why? Please advise. Thank you very much.

  • #2
    Hi Jackson,

    I'm not sure how the system generates defaults but I guess someone had to ask the obvious question about under what name you're binding your form to the desired scope!

    If that's set and is "userPortfolio" and there's a property "userPortfolio.submitAccount", all should go well. Have you checked whether there are any String objects in "status.errorCodes"?

    Can you do a view-source on your browser and have a look at what's being generated?




    • #3
      thanks, kenevel:

      I bind by using the name 'userPortfolio.submitAccount' to the desired scope in my form . However, '<spring:bind path="userPortfolio.*">' should catch all error message no matter what name i use, right?

      Anyway, by trying "<spring:bind path="userPortfolio.submitAccount">" it makes me no difference. As well, no String objects in either "status.errorCodes" or "status.errorMessage" or "status.errorMessages".

      thank you.