you should be using the struts html tags if you want to use the form bean...or else
you would have to create the form bean object and explicitly set the values for each
input tag.
i suggest using the html tags...something like this:
YOUR EXAMPLE
input type=text name=UserName value= size=30
maxlength=20
STRUTS EXAMPLE
html:text property=userName size=30 maxlength=20 /
if you use the struts example for all your input fields the form bean will work
properly. go to the struts site for more documentation on these tags.
HTH
amir
[EMAIL PROTECTED] 9:00:06 AM 02/19/02
Hi,
I am quite new to Struts and have a problem with an Action and ActionForm. I
am running Struts 1.0.1 and Tomcat 4.0.1, my IDE is JBuilder 6 Enterprise.
I have the problem, that all the properties of a form are empty. When
running the program in the debugger I can see the following sequence of
operations being executed:
1. Constructor of my FormBean
2. Reset method
3. Validate method
All the setters are NOT called for whatever reason!
Here the simple Java Code of my Form:
public final class LogonForm extends ActionForm
{
private String mContainerName = ;
private String mUserName = ;
private String mPwd = ;
private String mAuthType = ;
public LogonForm()
{
System.out.println(Form created.);
}
public String getContainerName()
{
return mContainerName;
}
public void setContainerName(String ContName)
{
mContainerName = ContName;
}
public String getUserName()
{
return mUserName;
}
public void setUserName(String UserName)
{
mUserName = UserName;
}
public String getPassword()
{
return mPwd;
}
public void setPassword(String Password)
{
mPwd = Password;
}
public String getAuthType()
{
return mAuthType;
}
public void setAuthType(String AuthType)
{
mAuthType = AuthType;
}
public void reset(ActionMapping mapping, HttpServletRequest request)
{
mPwd = ;
mUserName = ;
mContainerName = ;
mAuthType = ;
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest
request)
{
System.out.println(mContainerName+ + mUserName);
ActionErrors errors = new ActionErrors();
if ((mUserName == null) || (mUserName.length() 1))
errors.add(username, new
ActionError(error.username.required));
if ((mPwd == null) || (mPwd.length() 1))
errors.add(password, new
ActionError(error.password.required));
if ((mContainerName == null) || (mContainerName.length() 1))
errors.add(containername, new
ActionError(error.containername.required));
return errors;
}
}
The HTML looks as follows:
form action=/Echnaton/authenticate.do METHOD=POST
input type=Hidden name=AuthType value=WindowsNT /
table align=center cellspacing=2 cellpadding=2 border=0
tr
td rowspan=4img src=../Images/Logon.gif width=192 height=146
border=0 alt=/td
td width=120 id=FormFontNT Domain:/td
td width=200 id=FormFontinput type=text name=ContainerName
value= size=30 maxlength=16/td
/tr
tr
td id=FormFontYour User ID:/td
td id=FormFontinput type=text name=UserName value= size=30
maxlength=20/td
/tr
tr
td id=FormFontPassword:/td
td id=FormFontinput type=password name=Password value=
size=30 maxlength=20/td
/tr
tr
td colspan=2 id=FormFont
input type=submit value=Logon
input type=Reset value=Clear
/td
/tr
/table
/form
Here I must add, that this code is from a velocity macro, since I use
Velocity instead of JSP as Template for my 'View' layer in the MVC
architecture.
The action is implemented as follows:
public class authenticate extends EWCAction
{
public authenticate()
{
}
public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse
response)
throws IOException, ServletException
{
// Extract attributes we will need
StringBuffer AuthError = new StringBuffer(256);
Locale locale = getLocale(request);
MessageResources messages = getResources();
// Validate the request parameters specified by the user
ActionErrors errors = new ActionErrors();
String container = ((LogonForm)form).getContainerName();
String username = ((LogonForm)form).getUserName();
String password = ((LogonForm)form).getPassword();
String authtype = ((LogonForm)form).getAuthType();
EWCInit ei =
(EWCInit)request.getSession().getServletContext().getAttribute(EWCInit);
String IOR = ei.getFactoryIOR();
//
// do authentication
//
// do some CORBA processing here
// Report any errors we have discovered back to the original form
if (!errors.empty())
{
saveErrors(request, errors);
return (new ActionForward(mapping.getInput()));
}
// Forward control to the specified success URI
return (new ActionForward(/startApp.jsp));
}
boolean doNTAuthentication(HttpSession session, String IOR, String
Container,
String UserName, String Pwd,