Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-4413

Date format error in .page.xml params when having custom date pattern

    Details

    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      The workaround consists in doing manually what we can expect that Seam is doing automatically for us.

      Do the following steps:
      1) define a custom converter which converts Date to String using SimpleDateFormat("yyyyMMddHHmmssSSS")
      2) register the custom converter in faces-config.xml with a converterId property
      2) set the <param> tag 'converterId' property for all date parameters in all .page.xml files

      Show
      The workaround consists in doing manually what we can expect that Seam is doing automatically for us. Do the following steps: 1) define a custom converter which converts Date to String using SimpleDateFormat("yyyyMMddHHmmssSSS") 2) register the custom converter in faces-config.xml with a converterId property 2) set the <param> tag 'converterId' property for all date parameters in all .page.xml files
    • Estimated Difficulty:
      Low

      Description

      The java.util.Date passed by <param> tags in the .page.xml file are converted from Date to String for the GET request, using the date format defined in the last used rich:calendar. Then, the GET parameters are converted back from String to Date using the default date format which may not be the same as the one defined in the rich:calendar. This results in date conversion errors such as "value must be a date, eg. 10/13/2008".

      The issue is fully described with an example in http://seamframework.org/Community/DateFormatErrorInPagexmlParamsASeamIssue

      To correct this issue, the org.jboss.seam.navigation.Param should use its own date converter instead of sharing the converter with other JSF components (in other words, the Param class should use a technical date converter). This requires the following steps:
      1) define a org.jboss.seam.faces.DateParamConverter date converter with a selectable date format defaulted to "yyyyMMddHHmmssSSS"
      2) change the org.jboss.seam.navigation.Param class to use a the DateParamConverter converter if the param value is java.util.Date, else, use the converters registered in JSF. This is done by changing:

      Class<?> type = valueExpression.getType();
      if (type==null)

      { return null; }
      return FacesContext.getCurrentInstance().getApplication().createConverter(type);

      by

      Class<?> type = valueExpression.getType();
      if (type==null)
      { return null; }

      + if (type.equals(Date.class))

      { + return org.jboss.seam.faces.DateParamConverter.getInstance(); // return an instance of the technical converter, to be created + }

      else

      { return FacesContext.getCurrentInstance().getApplication().createConverter(type); + }

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  manaRH Marek Novotny
                  Reporter:
                  jkronegg Julien Kronegg
                • Votes:
                  2 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 1 day
                    1d
                    Remaining:
                    Remaining Estimate - 1 day
                    1d
                    Logged:
                    Time Spent - Not Specified
                    Not Specified