Announcement Announcement Module
Collapse
No announcement yet.
fail to get message from errors.rejectValue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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:
    Code:
    public class UserCheckController extends AbstractWizardFormController {
    ....
    protected void onBind(HttpServletRequest request, Object command,
    BindException errors) {
    ....
    logger.info("> 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) {
    ...
    logger.info("> throw error reject!");
    errors.rejectValue("submitAccount","management.user.duplicate",
    "Account duplicated.");
    errors.reject("management.user.duplicate","Account duplicated.");
    }
    My jsp:
    Code:
    <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/>
        </c:forEach>
    </font>
    <br/>
    </spring:bind>
    
    <spring:hasBindErrors name="userPortfolio">
    <font color="red"><c:out value="${status.errorMessage}"/></font>
    </spring:hasBindErrors>
    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?

    HTH

    Mike

    Comment


    • #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.

      Comment

      Working...
      X