Tech > StrutsHints

Struts Hints and Tips

This document relates to Version 1.0.2 of Jakarta Struts.

Logging

Logging is delegated to javax.servlet.GenericServlet. The documentation for this class states that this method writes the specified message to a servlet log file, prepended by the servlet's name. The servlet log file is usually an event log. The name and type of the servlet log file is specific to the servlet container.

See JbossHintsAndTips#debugging for informations specific to JBoss.

Validator

If your servlet container is going out to the Internet to fetch the DTD for validation.xml and validator-rules.xml it is most likely that there is an error in the public identifier in these files.

As at Struts 1.2.8 it should be:

<!DOCTYPE form-validation PUBLIC
       "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
       "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

Further information (in relation to web.xml, but the principals are the same) at http://article.gmane.org/gmane.comp.jakarta.struts.user/78202/

Note: Struts prior to 1.1 had a bug in the way that the validator was implemented that resulted in the DTD being fetched from the Internet. The fix is to upgrade to a later release.

  • -- Frank Dean - 02 Dec 2005

StrutsCatalogLazyList

http://wiki.apache.org/struts/StrutsCatalogLazyList

The key bit is:

import org.apache.commons.collections.Factory;
  import org.apache.commons.collections.ListUtils;

  public class SkillActionForm extends ActionForm, implements Factory {

    protected List skills = ListUtils.lazyList(new ArrayList(), this);

    public List getSkills() {
       return skills;
    }

    public void setSkills(final List newSkills) {
       skills = ListUtils.lazyList(newSkills, this);
    }

    // 'Factory' method for LazyList
    public Object create() {
       return new SkillBean();
    }

  }

Resource Keys

Add the following to your message resource bundle and modify to set the appropriate formatting of Struts tags:

org.apache.struts.taglib.bean.format.sql.timestamp=yyyy-MM-dd HH:mm:ss
org.apache.struts.taglib.bean.format.sql.date=yyyy-MM-dd HH:mm:ss
org.apache.struts.taglib.bean.format.sql.time=yyyy-MM-dd HH:mm:ss
org.apache.struts.taglib.bean.format.date=yyyy-MM-dd HH:mm:ss
org.apache.struts.taglib.bean.format.int=#
org.apache.struts.taglib.bean.format.float=0.0

See also JbossHintsAndTips, JbossLog4J

      • Frank Dean - 10 June 2003