2 Replies Latest reply on Jan 24, 2008 4:26 PM by kenrod

    Possible to set Calendar Locale/DatePattern globally?

    kenrod Newbie

      Is it possible to set the Locale/DatePattern for the Calendar control globally (eg. in a web.xml context-param or something) so that I don't have to put...

      <rich:calendar locale="..." datePattern="..."/>


      ...every time I use the tag?

      Regards,

      Richard.

        • 1. Re: Possible to set Calendar Locale/DatePattern globally?
          Daniel Soneira Novice

          You could make a facelet-tag like the one I use:

          inputCalender.jspx

          See facelets documentation on how to use tag files (chapter 3.5.5)

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:t="http://myfaces.apache.org/tomahawk"
           xmlns:c="http://java.sun.com/jstl/core"
           xmlns:a4j="http://richfaces.org/a4j"
           xmlns:rich="http://richfaces.org/rich">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <!--
           Beschreibung:
           <label><label><inputCalendar>...</inputCalendar>
           Parameter [* - required]:
           id*
           value*
           displayName
           disabled
          -->
          
           <f:view>
           <ui:composition>
           <c:if test="${displayName != null}">
           <h:outputLabel for="${id}" value="${displayName}:"/>
           </c:if>
           <rich:calendar id="${id}"
           value="${value}"
           enableManualInput="true"
           popup="true"
           disabled="${disabled}"
           datePattern="dd.MM.yyyy"
           inputSize="10">
           <f:convertDateTime pattern="dd.MM.yyyy" timeZone="CET"/>
           <a4j:support event="oninputchange"
           reRender="${id}"
           ajaxSingle="true"/>
           <ui:insert/>
           </rich:calendar>
           </ui:composition>
           </f:view>
          
          </html>
          </jsp:root>
          


          • 2. Re: Possible to set Calendar Locale/DatePattern globally?
            kenrod Newbie

            Thanks Daniel, that's a great tip.

            I didn't know Facelets had a 'half way house' between putting the tags in the JSP file and extending your own UIComponent class.

            I'll take a look at it.