- This topic has 4 replies, 2 voices, and was last updated 20 years ago by Richard Fisher.
-
AuthorPosts
-
Richard FisherMemberWhen creating the formbean “name” is added to the <form-bean
as <form-property name=”name” type….I am new to Struts and am just trying to follow the tutorial first.
When I try and do the same say for a login page with userId and password these lines do not appear in the struts-config.xml under form-bean. Does this have something to do with the being or not being a dynaactionform? I felt that I was missing something here in the demo that did not translate when trying it in the tools.
Eclipse
Version: 3.0.1
Build id: 200409161125MyEclipseIde
Version: 3.8.2
Build id: 200409171200-3.8.2
Riyad KallaMemberhofs,
Try and post some of your code so we can see what you are asking about. Have you tried to look at our newest tutorials for Struts?
http://www.myeclipseide.com/ContentExpress-display-ceid-67.html
Richard FisherMemberI will look at the new example.
As you can see the struts.cfg.xml created does not list the two form bean entries name, and password
below the <form-bean name=”loginForm” type=”com.yourcompany.struts.form.LoginForm” /> line
like the tutorial has. I was not sure if that is a wizard issue, or a tutorial issue, or some setting, or if
it is the diff between a bean for every form or dynaforms?<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE struts-config PUBLIC “-//Apache Software Foundation//DTD Struts Configuration 1.1//EN” “http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd”>
<struts-config>
<data-sources />
<form-beans >
<form-bean name=”loginForm” type=”com.yourcompany.struts.form.LoginForm” /></form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute=”loginForm”
input=”/form/login.jsp”
name=”loginForm”
path=”/login”
scope=”request”
type=”com.yourcompany.struts.action.LoginAction” /></action-mappings>
<controller bufferSize=”4096″ debug=”0″ />
<message-resources parameter=”com.yourcompany.struts.ApplicationResources” />
</struts-config>Here is the form bean created
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_3.8.2/xslt/JavaClass.xslpackage com.yourcompany.struts.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;/**
* MyEclipse Struts
* Creation date: 12-06-2004
*
* XDoclet definition:
* @struts:form name=”loginForm”
*/
public class LoginForm extends ActionForm {// ——————————————————— Instance Variables
/** password property */
private String password;/** name property */
private String name;// ——————————————————— Methods
/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {throw new UnsupportedOperationException(
“Generated method ‘validate(…)’ not implemented.”);
}/**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {throw new UnsupportedOperationException(
“Generated method ‘reset(…)’ not implemented.”);
}/**
* Returns the password.
* @return String
*/
public String getPassword() {
return password;
}/**
* Set the password.
* @param password The password to set
*/
public void setPassword(String password) {
this.password = password;
}/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
}/**
* Set the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}}
Riyad KallaMemberActionForm properties (name, password in this case) do not need to be enumerated in the struts-config.xml file unless you are using a DynaForm. If you are using a straight ActionForm subclass (in this case you are) the properties can be retrieved/matched using Java reflection.
Richard FisherMemberThanks, it was not clear to me in the tutorial, I appreciate your help.
Consider closed. -
AuthorPosts