|
Hello, I've been thinking about how to set the locale in a central way and also we recently found an 'issue' with <f:view locale="xx_yy"> According to the JSF spec, there are two ways one can override view locale. (a) provide a custom ViewHandler (b) specify in each page <f:view locale="xx_yy"> (a) may not be a preferred approach, due to the fact that ViewHandler also controls a number of other behaviors of Faces, and Trinidad's ViewHandler is private. (b) This approach requires specification of locale/EL in each page. likely to conflict with the locale-related configuration properties in trinidad-config, e.g., formatting-locale, time-zone,etc. Also for (b) we have encountered an 'issue'. I won't call it a bug because it appears this is how it is spec'd to work. Our framework is trying to obey the page author's intended locale for servlet operations before render response. Unfortunately the locale on <f:view> does not get set until render response. The issue is that the JSF specification is confusing with regards to what the createView phase actually does. Logically you'd think after createView the entire component tree has been created and that renderResponse renders this component tree. However, the JSP ViewHandler doesn't work that way (presumably because JSP execution is designed only to render). Instead, the createView phase of the JSP ViewHandler only creates the UIViewRoot and creating the rest of the component tree is not executed until the RenderResponse phase. This is too late for our framework. WORKAROUNDS: 1. PhaseListener - the application developer can create a PhaseListener during RESTORE_VIEW and this can set the locale onto the UIView roow. The locale could come from a managed bean, for example. This requires the app developer to write clode. 2. Trinidad can add a <default-locale> element to trinidad-config.xml. This is a declarative approach. The logic can be: a. use <default-locale> in trinidad-config.xml if specified b. override with <f:view locale> if set (this won't be until render response) What do people think about this? Thanks, Jeanne |
