I am new to Struts and learning myself but from what I have read the input attribute is for validation if the form/Action fails it will send it back to the view. And know that you should never has .jsp pages located in your WEB-INF directory. Just an idea.

--Sloan

Marco,

 >       <action path="/postTest"
 >              input="/WEB-INF/jsp/postTest.jsp"
 >             name="postTestForm"
 >             scope="request"
 >             validate="true"
 >             type="com.mycompany.PostTestForm">
 >             <forward name="posttest.success"
 path="/execute/homePageSetup"/>
 >       </action>

 the input elemement should not contain the /WEB-INF specification (but I
 could be wrong).

I tried it already. You mean input="/postTest", right? I doesn't work too. I'm being send to the application entrypage anyway. Can you explain what the %20name= thing in the URL is? I have no idea where does it come from...

It seems to me also that as type you specified a class
 representing your Form more than the action to execute.

The class specified as type is the ActionForm for the HTML form. Here how it looks like:

package com.mycompany;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.util.MessageResources;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import java.lang.String;

public class PostTestForm extends ActionForm
{
   private String field1 = "";
   private String field2 = "";
   private String field3 = "";

   private void checkForEmpty(String fieldName, String fieldKey, String
value,
                              ActionErrors errors)
   {
    if (value.trim().length() == 0)
    {
  System.out.println("***checkForEmpty***");
     ActionError error = new ActionError("error.posttest.field.null",
fieldName);
     errors.add(fieldKey, error);
    }
   }

   private void checkForLength(String fieldName, String fieldKey, String
value,
                               int maxLength, ActionErrors errors)
   {
    if (value.length() > maxLength)
    {
     ActionError error =  new ActionError("error.posttest.field.length",
fieldName);
     errors.add(fieldKey, error);
    }
   }


public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors();

    checkForEmpty("field1", "error.field1.empty", getField1(), errors);
    checkForEmpty("field2", "error.field2.empty", getField2(), errors);
    checkForEmpty("field3", "error.field3.empty", getField3(), errors);
    System.out.println("***checkForEmpty zu Ende***");

    checkForLength("field1", "error.field1.lenght", getField1(), 5, errors);
    checkForLength("field2", "error.field2.lenght", getField2(), 5, errors);
    checkForLength("field3", "error.field3.lenght", getField3(), 5, errors);

    return errors;
   }

   public void reset(ActionMapping mapping, HttpServletRequest request)
   {
    field1 = "";
    field2 = "";
    field3 = "";
   }

   public String getField1()
   {
    return field1;
   }

   public void setField1(String feld1)
   {
    this.field1 = field1;
   }

   public String getField2()
   {
    return field2;
   }

   public void setField2(String field2)
   {
    this.field2 = field2;
   }

   public String getField3()
   {
    return field3;
   }

   public void setField3(String field3)
   {
    this.field3 = field3;
   }

}

I'm sitting on it since couple of hours already, but I'm no step further.
I using the Professional Struts Applicatons book. I wonder if there
are some many error in there or what else is going on?

Thanks
Tom


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] * 141 FETCH (FLAGS (\Seen))



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to