theapplicationbox.com's blog discussing JEE technologies and web related experiences
Friday, November 23, 2012
Using your Locale across requests and ignoring the Faces computed locale
if you want to use your Locale in a faces application, keep it in a session-scoped bean and use it like this
<f:view locale="#{myBean.myLocale}">
<f:loadBundle var="messages" basename="messages.Messages"></f:loadBundle>
You may wonder why not set your Locale (setLocale()) once on the viewHandler.
It is not enough because Faces computes its own locale on every request (or page refresh F5).
So you should do it and every request and this is exactly what <f:view locale="#{myBean.myLocale}"> ensures: that your locale is set as the view's locale on every request (and even if i wanted to set it explicitly on every request using viewHandler.setLocale() i didn't find any right event/timing to do it before the <f:loadBundle is processed. Even the preRenderView event i had learned about is not good)
This will ensure that even if you refresh the page, it is YOUR locale (from the bean propery) and not the Faces-computed locale (the browser locales filtered by <supported-locale>s or the <default-locale> if no <supported-locale> are specified) that will be used.
Subscribe to:
Posts (Atom)
Use "hibernate.hbm2ddl.auto=update" to update your schema (add remove columns, etc.) without losing data in tables.
Use <property name="hibernate.hbm2ddl.auto" value="update" /> to update your schema (add remove columns, etc...
-
In SVN and Eclipse, if you have problems with a folder, with a small red x, try right-click->Team->Revert and then right-click->Te...
-
Use <property name="hibernate.hbm2ddl.auto" value="update" /> to update your schema (add remove columns, etc...
-
Read this: Primary Keys through OneToOne and ManyToOne Relationships and this Derived Identifiers and this Derived Identi...