I find Struts [and I think JSF though I've only read about that in draft
reviews] quite slow to work with as there's a lot of programming for
things that ought to be easier to do and have a much faster feedback loop
in development.
Have you tried using XDoclet to generate Struts artifacts? Have a look at a domain object I'm currently using in one of my projects (at the end of this email). The XDoclet tags that start with @struts do these things (ignore the other @ tags, as I'm still monkeying around with the persistence layer that will be either hibernate/castor/OJB/EJB):
* @struts.form include-all="true"
- generates a UserForm.java (which extends ValidatorForm) that includes all the properties of this User.java
- creates the <form-bean> entry in struts-config.xml, maps it to the generated UserForm
* @struts.validator type="required" msgkey="errors.required"
- creates a <form> entry in validation.xml, as well as the necessary <field> entries for Stuts validation
There are also a number of tags that can be used in the *Action classes to automagically put in action mapping entries. In fact, the only files I wrote were the domain (User.java) and the Action (UserAction.java). I didn't have to touch the struts-config.xml *at all* for this. Some links:
http://www.ftponline.com/javapro/2003_07/online/ehatcher_07_18_03/
http://raibledesigns.com/training/index.jsp?topic=xdoclet
cheers, Pratik
--- User.java ---- package org.sourceforge.jwebforum.model; import java.util.Date;
* @ejb:bean name="User"
* @struts.form include-all="true"
* extends="org.appfusion.webapp.form.BaseForm"
* @castor.class name="user" table="user" id="id" key-generator="UUID"
* @hibernate.class table="user"
*/
public class User {
private String password;
private String email;
private Date signupdate;
private String firstname;
private String lastname;
private String username;
private long userid;public User(String password, String email, java.sql.Timestamp signupdate, String firstname, String lastname, String username, long userid) {
this.password = password;
this.email = email;
this.signupdate = signupdate;
this.firstname = firstname;
this.lastname = lastname;
this.username = username;
this.userid = userid;
}
public User() {
}
/** Password of the user.
* @struts.validator type="required" msgkey="errors.required"
* @castor.field set-method="setPassword"
* @castor.field-sql name="password" dirty="check" sql-dirty="check"
* @ejb:persistent-field
* @hibernate.property column="password" non-null="true" unique="true"
*/
public String getPassword() {
return password;
} /** E-mail address of the user.
* @struts.validator type="email" msgkey="errors.email"
* @castor.field set-method="setEmail"
* @castor.field-sql name="email" dirty="check" sql-dirty="check"
* @ejb:persistent-field
* @hibernate.property column="email" non-null="true" unique="true"
*/
public String getEmail() {
return email;
} public Date getSignupdate() {
return signupdate;
} /** Firstname name of the user.
* @struts.validator type="required" msgkey="errors.required"
* @castor.field set-method="setFirstname"
* @castor.field-sql name="firstname" dirty="check" sql-dirty="check"
* @ejb:persistent-field
* @hibernate.property column="firstname" non-null="true" unique="true"
*/
public String getFirstname() {
return firstname;
} /** Surname name of the user.
* @struts.validator type="required" msgkey="errors.required"
* @castor.field set-method="setLastname"
* @castor.field-sql name="lastname" dirty="check" sql-dirty="check"
* @ejb:persistent-field
* @hibernate.property column="lastname" non-null="true" unique="true"
*/
public String getLastname() {
return lastname;
}
/** User name of the user.
* @struts.validator type="required" msgkey="errors.required"
* @castor.field set-method="setUsername"
* @castor.field-sql name="username" dirty="check" sql-dirty="check"
* @ejb:persistent-field
* @hibernate.property column="username" non-null="true" unique="true"
*/
public String getUsername() {
return username;
} /** Id of the User.
* Not remote since primary key may be extracted by other means.
* @castor.field set-method="setUserid"
* @castor.field-sql name="userid" dirty="check" sql-dirty="check"
* @ejb:persistent-field
* @hibernate.id column="userid" type="long"
* generator-class="uuid.hex" unsaved-value="null"
*/
public long getUserid() {
return userid;
} /** @ejb:persistent-field */
public void setPassword(String password) {
this.password = password;
}
/** @ejb:persistent-field */
public void setEmail(String email) {
this.email = email;
}
/** @ejb:persistent-field */
public void setSignupdate(java.sql.Timestamp signupdate) {
this.signupdate = signupdate;
}
/** @ejb:persistent-field */
public void setFirstname(String firstname) {
this.firstname = firstname;
}
/** @ejb:persistent-field */
public void setLastname(String lastname) {
this.lastname = lastname;
}
/** @ejb:persistent-field */
public void setUsername(String username) {
this.username = username;
}
/** @ejb:persistent-field */
public void setUserid(long userid) {
this.userid = userid;
}
}
_______________________________________________ Juglist mailing list [EMAIL PROTECTED] http://trijug.org/mailman/listinfo/juglist_trijug.org
