Hi,
Definitely AFTER PhaseId.RESTORE_VIEW, we used that with success in many
projects in the past here.
Regards,
~ Simon
On Thu, Jul 10, 2008 at 1:17 PM, Zigc Junk <[EMAIL PROTECTED]> wrote:
> Try restore view phase which is the first phase of the life cycle.
>
> regard
>
> Bill
>
> On Thu, Jul 10, 2008 at 12:31 AM, Julien Martin <[EMAIL PROTECTED]> wrote:
> > Hello,
> > I use restfaces an I have UrLs such as mydomain.com/fr/book/etc
> > where /fr/ is the desired locale. I have tried retrieving the locale
> string
> > from the URL and setting the locale from a PhaseListener before the
> > renderResponse phase but it does not work i.e. when I change the locale
> in
> > the address bar to /en/book/etc it will not change the locale. Any clue?
> > Thanks in advance,
> > JUlien.
> >
> > Here is the phase listener:
> >
> > code:
> > ________________________________
> >
> > public class DebugPhaseListener implements PhaseListener {
> >
> >
> > private static transient Logger log =
> > Logger.getLogger("com.jeanbaptistemartin.util");
> >
> > public DebugPhaseListener() {
> > log.debug("DebugPhaseListener constructor");
> > }
> >
> > public void afterPhase(PhaseEvent phaseEvent) {
> >
> > log.debug("after---> " + phaseEvent.getPhaseId());
> > }
> >
> > public void beforePhase(PhaseEvent phaseEvent) {
> > Locale locale =
> >
> extractLocale(FacesContext.getCurrentInstance().getExternalContext().getRequestServletPath());
> >
> > FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
> > }
> >
> > public PhaseId getPhaseId() {
> > return PhaseId.RENDER_RESPONSE;
> > }
> >
> > private Locale extractLocale(String servletPath) {
> > String[] array = servletPath.split("/");
> >
> > return new Locale(array[0]);
> >
> > }
> > }
> >
> >
> > ________________________________
> >
> > Here is the managed bean (I actually use spring):
> >
> > code:
> > ________________________________
> >
> > @Component("sculptureView")
> > @Scope("request")
> > public class SculptureView {
> >
> > private Logger log = Logger.getLogger("com.jeanbaptistemartin.view");
> > private JbmService service;
> >
> > private Sculpture sculpture;
> >
> > public SculptureView() {
> > log.info("Sculpture()");
> > }
> >
> > @Autowired
> > public SculptureView(JbmService service) {
> > log.info("Sculpture(JbmService service)");
> >
> > this.service = service;
> > }
> >
> > @Instance("#{sculptureView}")
> > @HttpAction(value = "sculptureAction", pattern =
> "{locale}/sculpture/{id}")
> > public String getBookById(@Param("id") int id, @Param("locale")String
> > locale) {
> >
> > this.sculpture = service.findByID(id);
> > log.debug("Locale: "+ locale);
> > return "/sculpture.jsp";
> > }
> >
> > public Sculpture getSculpture() {
> > return sculpture;
> > }
> >
> > public void setSculpture(Sculpture sculpture) {
> >
> > this.sculpture = sculpture;
> > }
> >
> > }
> >
> > ________________________________
> >
> > The problem I get is that the jsp page still display today's date in
> > french...
> > Julien.
>