DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28360>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28360

DateInputModule's getAttribute() does not fetch requested format

           Summary: DateInputModule's getAttribute() does not fetch
                    requested format
           Product: Cocoon 2
           Version: 2.1.4
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: general components
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


DateInputModule's getAttribute() method uses the final static string "format" 
as key when getting the format.
Instead, it should use the 'name' String argument of that method. This will 
enable specification of other date formats by adding elements within the 
<component-instance> element in cocoon.xconf.

The method 

public Object getAttribute( String name, Configuration modeConf, Map  
objectModel ) throws ConfigurationException {
        
  String format = (String) this.settings.get("format",null);
  if (modeConf != null) {
    format = modeConf.getAttribute("format", format);
    // this is preferred:
    format = modeConf.getChild("format").getValue(format);
  }

  if (format==null) {
    return new Date();
  } else {
    return new SimpleDateFormat(format).format(new Date());
  }
}

should be changed into

public Object getAttribute( String name, Configuration modeConf, Map 
objectModel ) throws ConfigurationException {
        
  String format = (String) this.settings.get(name,null);
  if (modeConf != null) {
    format = modeConf.getAttribute(name, format);
    // this is preferred:
    format = modeConf.getChild(name).getValue(format);
  }

  if (format==null) {
    return new Date();
  } else {
    return new SimpleDateFormat(format).format(new Date());
  }
}

Reply via email to