facebook

Struts error handling

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #244104 Reply

    jposthum
    Member

    Hi everybody

    I dont see an error in my jsp when I dont fill in a textfield. I use struts 1.2

    Then next code checks for empty fields in my form class

    
    public ActionErrors validate(
            ActionMapping mapping,
            HttpServletRequest request) {
            ActionErrors errors = new ActionErrors();
            if (name == null || "".equalsIgnoreCase(name)) {
                errors.add("name", new ActionMessage("geen naam ingevuld"));
            }
            if (description == null || "".equalsIgnoreCase(description)){
                errors.add("description", new ActionMessage("geen omschrijving ingevuld"));
            }
            if (errors.size() != 0) {
                
                return errors;
            } 
            return null;
        }
    

    In my jsp I try to retrieve the error using the following code

    
    <td><html:errors property="description" /></td>
    

    I am using struts 1.2 and since 1.2 ActionError is deprecated, So I use ActionMessage instead as recommended. Does anybody know if this is the cause and what I have to add or change to make the error displaying work?

    Kind regards, Jarno

    #244137 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev

    Jarno, have you tried debugging the code and stepping through your validate method to make sure your input isn’t actually ” ” by mistake or something like that? My struts is a bit rusty though.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Struts error handling

You must be logged in to post in the forum log in