8 Replies Latest reply on Jan 29, 2009 6:28 AM by Nick Belaevski

    DataTable, Converters and ReRender problem

    Allan Topp Newbie

      I have some code that uses a datatable to render a result set. Inside the result set I have multiple dates that use the f:convertDateTime to render the date correctly. The pattern comes from a backing bean property, which the user can change from a radio button on the UI. The radio button has a a:support tag on it to rerender the datatable when the selection changes, effectively changing the pattern to be used in the f:convertDateTime. The problem i am seeing is that the converter does not seem to be called. If I print the value outside the dataTable I can see that it is updated correctly and the outputText is rerender with the new value. But anything inside the dataTable that is using a converter does not appear to reapply the converter on rerendering. Is this a know issue or should I be doing something differently?

        • 1. Re: DataTable, Converters and ReRender problem
          Nick Belaevski Master


          Can you please post page code?

          • 2. Re: DataTable, Converters and ReRender problem
            Allan Topp Newbie

            I can't post the actual code, NDA and all. But I will give the jist of it.

            A radio button contains two values representing the different date patterns to use in the Converter

            <h:selectOneRadio value="#{maintainCatalogAction.selectedDateFormat.value}">
            <s:selectItems value="#{maintainCatalogAction.catalogDateFormatList}"
             <a:support event="onclick"

            On change of this value it rerenders the testDataTable, which contains the following

            <rich:dataTable id="testDataTable" value="#{maintainCatalogAction.testList}" width="100%" var="_cat" >
             <h:outputText value="_cat"/>
             <h:outputText value="#{maintainCatalogAction.testDate}">
             <f:convertDateTime pattern="#{maintainCatalogAction.selectedDateFormat.value}"/>
             <h:outputText value="#{maintainCatalogAction.selectedDateFormat.value}"/> </h:outputText>

            The testDate is just a Date object I instantiate at maintainCatalog creation time. The testList is just a list of String values. When the radio button is changed the value printed for selectedDateFormat is changed during the rerender but the outputText using the converter is not using the new pattern.

            • 3. Re: DataTable, Converters and ReRender problem
              Allan Topp Newbie

              Sorry to be a bumper, but this is kind of critical. I don't think I am asking a hard question. Basically I am trying to figure out if converters are rerun when on a a4j:support rerender. To me it looks like they are not. Not sure if this is something in the JSF spec and lifecycle or whether it is a problem with how a4j:support processes request.

              • 4. Re: DataTable, Converters and ReRender problem
                Mikhail Vitenkov Newbie

                For me, when date pattern is changed - it doesn't affect output date format displaying in case radio buttons and tested output placed on the same page.
                But when I use a4j:support action for navigation to another page with tested output - changed pattern is applied. Probably date converter doesn't became updated in dom on the same page.

                Following bug was posted in JIRA:

                Thanks for the participation.

                • 5. Re: DataTable, Converters and ReRender problem
                  Mikhail Vitenkov Newbie

                  It's not a richfaces bug. JSF feature. Verify the same code without rich and a4j tags.

                  • 6. Re: DataTable, Converters and ReRender problem
                    Allan Topp Newbie

                    Thanks, that is exactly what I was trying to figure out. Now that we have idenitified as a JSF issue and not a RichFaces problem, is there anything in RichFaces that could fix this? Is there anyway to force the JSF tree to reevaluate the EL for the pattern and reapply it to the text field? If not I guess I have to rethink how I am doing this.

                    • 7. Re: DataTable, Converters and ReRender problem
                      Christian Yttesen Newbie


                      I'm having similar issues - I have my pattern in a backing bean (MMM d, yyyy) and using the:
                      <f:convertDateTime pattern="#{i18nBean.datePattern}" />

                      various places throughout my project - I can have two properties next to each other:

                      <h:outputLabel for="startDate" value="#{msgs['account.start_date']}:" />
                      <h:outputText id="startDate" value="#{accountBean.dslAccount.startDate}">
                       <f:convertDateTime pattern="#{i18nBean.datePattern}" />
                      <h:outputLabel for="expiryDate" value="#{msgs['account.expiry_date']}:" />
                       <h:outputText id="expiryDate" value="#{accountBean.dslAccount.expiryDate} ">
                       <f:convertDateTime pattern="#{i18nBean.datePattern}" />
                       <h:commandLink id="lnkShowExtendExpiryDate" actionListener="#{accountPageBean.showExtendExpiryDateDialog}"
                       value="#{msgs['account.extend_expiry_date']}" immediate="true" />

                      Displayed as:

                      Start date: Jan 28, 2009
                      Expiry date: 2009-03-19

                      On other pages the conversion works on others again it fails. It is however consistent where it works and where is doesn't - I just can't figure out why.

                      Toppac - did you get around it?

                      Any known workarounds?

                      • 8. Re: DataTable, Converters and ReRender problem
                        Nick Belaevski Master


                        Workarounds are:


                        <h:outputText value="#{custom.testDate}">
                         <f:converter binding="#{custom.converter}"/>

                        public Converter getConverter() {
                         DateTimeConverter converter = new DateTimeConverter();
                         return converter;

                        <h:outputText value="#{custom.testDate}" binding="#{testBean.valueHolder}">
                         <h:commandButton action="#{testBean.setConverter}"/>

                        private UIOutput valueHolder;
                         public UIOutput getValueHolder() {
                         return valueHolder;
                         public void setValueHolder(UIOutput valueHolder) {
                         this.valueHolder = valueHolder;
                         public void setConverter() {
                         DateTimeConverter converter = new DateTimeConverter();

                        In the Java code "snippet" is session-scoped bean that contains pattern wired to request-scoped testBean containing binding to component.