3 Replies Latest reply on Oct 26, 2009 11:07 AM by Miguel Cohnen

    TimeZoneSelector... needs page refresh?

    Miguel Cohnen Newbie


      I'm trying to use timeZoneSelector to change the timeZone. This is what I do:

                     <h:selectOneMenu value="#{timeZoneSelector.timeZoneId}">
                         <f:selectItem itemLabel="Madrid" itemValue="Europe/Madrid"/>
                         <f:selectItem itemLabel="Dublin" itemValue="Europe/Dublin"/>
                     <h:commandButton action="#{timeZoneSelector.select}" value="Selecr"/>
                <h:outputText value="#{test.date}">
                     <s:convertDateTime type="time" /> 
                </h:outputText> - 

      I can see that the timeZone changes (Because of the first line where I print the timeZoneId) but the s:convertDateTime is not using the new selected TimeZone, unless I refresh the page! So clicking on the button launchs the form, changes the timezone, but s:convertDateTime is not aware until I refresh the page (f5).

      What am I doing wrong? IS this a bug? Is there a way I can make this workd?

      Thank you a lot!

        • 1. Re: TimeZoneSelector... needs page refresh?
          Miguel Cohnen Newbie

          I think the error is related to s:convertDateTime... and it also happens with f:convertDateTime! If i specify the timezone using a valueExpression, it looks like if it is being cached and not using the new value!

          Any help here?

          • 2. Re: TimeZoneSelector... needs page refresh?
            Tim Evers Master

            (Disclaimer: I have no idea if this is the reason, but it appears to be related to other problems I've had so this is worth a try :P)
            My guess is that you need to rebuild your page after selecting a timezone. If your action=#{timeZoneSelector.select} returns null/void then you are using the exact same component tree that you started with. It will not be rebuilt (I use " because there's a more technical way to describe this :P).

            Try making your action method return a value so that your page is rebuilt.

            Null/Void methods use the same UIViewRoot, non null/void returns from action methods cause a new UIViewRoot to be created. I hope this helps.

            As in timeZoneSelector.select should return timezoneSelection.xhtml or whatever your page is.

            • 3. Re: TimeZoneSelector... needs page refresh?
              Miguel Cohnen Newbie

              Hi, thank you very much for your answer. You are right, it is using the same component tree until I reload the site. But how can I force a new UIViewRoot to be created? I tried what you said, returning the xhtml, but it's not working...

              Howevery I found that Trinidad (Apache Myfaces) converter for dateTime works as expected. It is a shame I have to add the jars only for this purpouse...

              Let's see if I can get rid off a whole framework (Trinidad) that I'm using for a tag! Hehe

              Thank you!