Skip to main content

JSF 2.0: locale change only after page refresh

15 replies [Last post]
napu
Offline
Joined: 2003-07-30

Hi!

I'm upgrading a small (working) programme from JSF 1.2 and JSP to JSF 2.0 and Facelets.

My problem is that locale change which is referenced on the Facelet page as

works only after the page is manually refreshed (after the locale change form has been submitted).

I have tried various methods with no success yet:
- form button with immediate="true" and context.getViewRoot().setLocale(new Locale("xx", "YY")) in managed bean code
- normal form without immediate="true"
- an ajax button with

Googling for this turned up a couple of similar problems but no working solutions.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Lincoln Baxter, III

Or reload the entire page/data structure.

Lincoln Baxter III
http://ocpsoft.com
http://scrumshark.com
Keep it simple.

On Jan 13, 2010 1:10 PM, "Celinio Fernandes"
wrote:

Hi,
I found several posts dealing with my problem :
http://forums.java.net/jive/thread.jspa?messageID=332548
http://forums.java.net/jive/thread.jspa?messageID=373960

None gives answers unfortunately.

My problem is simple : I have a dataTable which contains a list of products,
the last column has a link to delete a product.



...

...






My delete method looks like this :
public void delete() {
FacesContext context = FacesContext.getCurrentInstance();
Map params =
context.getExternalContext().getRequestParameterMap();
String idNumber = params.get("id");
myEJB.delProduct(idNumber);
}

It deletes the product. However it does not re-render the dataTable. What am
i missing ?
What value should the render attribute be set to in that case ?

Thanks in advance for helping.
[att1.html]

Celinio Fernandes

Thanks for helping.
I understand that i need to reload the form or the page.
But i thought  the tag would take care of it.

How do you reload the form/page in that case ?

--- On Thu, 1/14/10, Lincoln Baxter, III
wrote:

From: Lincoln Baxter, III
Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
To: webtier@glassfish.dev.java.net
Date: Thursday, January 14, 2010, 12:18 AM

Or reload the entire page/data structure.
Lincoln Baxter III

http://ocpsoft.com

http://scrumshark.com

Keep it simple.
On Jan 13, 2010 1:10 PM, "Celinio Fernandes"
wrote:

Hi,
I found several posts dealing with my problem :
http://forums.java.net/jive/thread.jspa?messageID=332548

http://forums.java.net/jive/thread.jspa?messageID=373960

None gives answers unfortunately.

My problem is simple : I have a dataTable which contains a list of products, the last column has a link to delete a product.

 
  
 
 
  ...
 

 ...
   

 
                   />
               
 
            
  
   
   
 

My delete method looks like this :
 public void delete() {
        FacesContext context = FacesContext.getCurrentInstance();
        Map params = context.getExternalContext().getRequestParameterMap();

        String idNumber = params.get("id");
        myEJB.delProduct(idNumber);
    }

It deletes the product. However it does not re-render the dataTable. What am i missing ?
What value should
the render attribute be set to in that case ?

Thanks in advance for helping.

[att1.html]

Celinio Fernandes

I got it working with this :

Before that, I tried with the value of the render attribute set to the id of the form and it did not work. How come ?

--- On Thu, 1/14/10, Celinio Fernandes
wrote:

From: Celinio Fernandes
Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
To: webtier@glassfish.dev.java.net
Date: Thursday, January 14, 2010, 12:33 AM

Thanks for helping.
I understand that i need to reload the form or the page.
But i thought  the tag would take care of it.

How do you reload the form/page in that case ?

--- On Thu, 1/14/10, Lincoln Baxter, III
wrote:

From: Lincoln Baxter, III
Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
To: webtier@glassfish.dev.java.net
Date: Thursday, January 14, 2010, 12:18 AM

Or reload the entire page/data structure.
Lincoln Baxter III

http://ocpsoft.com

http://scrumshark.com

Keep it simple.
On Jan 13, 2010 1:10 PM, "Celinio Fernandes"
wrote:

Hi,
I found several posts dealing with my problem :
http://forums.java.net/jive/thread.jspa?messageID=332548

http://forums.java.net/jive/thread.jspa?messageID=373960

None gives answers unfortunately.

My problem is simple : I have a dataTable which contains a list of products, the last column has a link to delete a product.

 
  
 
 
  ...
 

 ...
   

 
                   />
               
 
            
  
   
   
 

My delete method looks like this :
 public void delete() {
        FacesContext context = FacesContext.getCurrentInstance();
        Map params = context.getExternalContext().getRequestParameterMap();

        String idNumber = params.get("id");
        myEJB.delProduct(idNumber);
    }

It deletes the product. However it does not re-render the dataTable. What am i missing ?
What value should
the render attribute be set to in that case ?

Thanks in advance for helping.

[att1.html]

Jason Lee

You specified render=":Form1:dataTable1". I think the leading : in the
component ID was confusing things.

On 1/13/10 12:47 PM, Celinio Fernandes wrote:
> I got it working with this :
>
>
> Before that, I tried with the value of the render attribute set to the
> id of the form and it did not work. How come ?
>
>
> --- On *Thu, 1/14/10, Celinio Fernandes /
/* wrote:
>
>
> From: Celinio Fernandes
> Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
> To: webtier@glassfish.dev.java.net
> Date: Thursday, January 14, 2010, 12:33 AM
>
> Thanks for helping.
> I understand that i need to reload the form or the page.
> But i thought the tag would take care of it.
>
> How do you reload the form/page in that case ?
>
> --- On *Thu, 1/14/10, Lincoln Baxter, III
> /
/* wrote:
>
>
> From: Lincoln Baxter, III
> Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
> To: webtier@glassfish.dev.java.net
> Date: Thursday, January 14, 2010, 12:18 AM
>
> Or reload the entire page/data structure.
>
> Lincoln Baxter III
> http://ocpsoft.com
> http://scrumshark.com
> Keep it simple.
>
>> On Jan 13, 2010 1:10 PM, "Celinio Fernandes"
>>
wrote:
>>
>> Hi,
>> I found several posts dealing with my problem :
>> http://forums.java.net/jive/thread.jspa?messageID=332548
>> http://forums.java.net/jive/thread.jspa?messageID=373960
>>
>> None gives answers unfortunately.
>>
>> My problem is simple : I have a dataTable which contains a
>> list of products, the last column has a link to delete a product.
>>
>>
>>
>>
>>
>> ...
>>

>> ...
>>
>>
>>
>>
>>

>>

>>

>>
>>

>>
>> My delete method looks like this :
>> public void delete() {
>> FacesContext context = FacesContext.getCurrentInstance();
>> Map params =
>> context.getExternalContext().getRequestParameterMap();
>> String idNumber = params.get("id");
>> myEJB.delProduct(idNumber);
>> }
>>
>>
>> It deletes the product. However it does not re-render the
>> dataTable. What am i missing ?
>> What value should the render attribute be set to in that case ?
>>
>> Thanks in advance for helping.
>>
>>
>
>

--
Jason Lee
Senior Java Developer
GlassFish Administration Console

Sun Microsystems, Inc.
Phone x31197/+1 405-343-1964
Email jasondlee@sun.com
Blog http://blogs.sun.com/jasondlee
Blog http://blogs.steeplesoft.com

[att1.html]

Celinio Fernandes

Well, I tried "Form1" (without the colon), "Form1:dataTable1" before and it did not work.

--- On Thu, 1/14/10, Jason Lee wrote:

From: Jason Lee
Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
To: webtier@glassfish.dev.java.net
Date: Thursday, January 14, 2010, 12:49 AM

You specified

render=":Form1:dataTable1". 
I think the leading : in the component ID was confusing things.

On 1/13/10 12:47 PM, Celinio Fernandes wrote:

I got it working with this :

Before that, I tried with the value of the render attribute set to the
id of the form and it did not work. How come ?

--- On Thu, 1/14/10, Celinio Fernandes
wrote:

From: Celinio Fernandes

Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?

To: webtier@glassfish.dev.java.net

Date: Thursday, January 14, 2010, 12:33 AM

Thanks for helping.

I understand that i need to reload the form or the page.

But i thought  the tag would take care of it.

How do you reload the form/page in that case ?

--- On Thu, 1/14/10, Lincoln Baxter, III
wrote:

From: Lincoln Baxter, III

Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?

To: webtier@glassfish.dev.java.net

Date: Thursday, January 14, 2010, 12:18 AM

Or reload the entire page/data structure.
Lincoln Baxter III

http://ocpsoft.com

http://scrumshark.com

Keep it simple.
On Jan 13, 2010 1:10 PM,
"Celinio Fernandes"
wrote:

Hi,

I found several posts dealing with my problem :

http://forums.java.net/jive/thread.jspa?messageID=332548

http://forums.java.net/jive/thread.jspa?messageID=373960

None gives answers unfortunately.

My problem is simple : I have a dataTable which contains a list of
products, the last column has a link to delete a product.

 

  

 

 

  ...

 

 ...

   

 

                   render=":Form1:dataTable1"  />

               

             

  

   

   

 

My delete method looks like this :

 public void delete() {

        FacesContext context = FacesContext.getCurrentInstance();

        Map params =
context.getExternalContext().getRequestParameterMap();

        String idNumber = params.get("id");

        myEJB.delProduct(idNumber);

    }

It deletes the product. However it does not re-render the dataTable.
What am i missing ?

What value should the render attribute be set to in that case ?

Thanks in advance for helping.

--
Jason Lee
Senior Java Developer
GlassFish Administration Console

Sun Microsystems, Inc.
Phone x31197/+1 405-343-1964
Email jasondlee@sun.com
Blog http://blogs.sun.com/jasondlee
Blog http://blogs.steeplesoft.com

[att1.html]

Jim Driscoll

Out of curiosity, you do have the project stage set to development,
right? And does it give an error when it's not updating the form? Or
does it fail silently?

Jim

On 1/13/10 10:51 AM, Celinio Fernandes wrote:
> Well, I tried "Form1" (without the colon), "Form1:dataTable1" before and
> it did not work.
>
> --- On *Thu, 1/14/10, Jason Lee //* wrote:
>
>
> From: Jason Lee
> Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
> To: webtier@glassfish.dev.java.net
> Date: Thursday, January 14, 2010, 12:49 AM
>
> You specified render=":Form1:dataTable1". I think the leading : in
> the component ID was confusing things.
>
> On 1/13/10 12:47 PM, Celinio Fernandes wrote:
>> I got it working with this :
>>
>>
>> Before that, I tried with the value of the render attribute set to
>> the id of the form and it did not work. How come ?
>>
>>
>> --- On *Thu, 1/14/10, Celinio Fernandes /
/*
>> wrote:
>>
>>
>> From: Celinio Fernandes
>> Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
>> To: webtier@glassfish.dev.java.net
>> Date: Thursday, January 14, 2010, 12:33 AM
>>
>> Thanks for helping.
>> I understand that i need to reload the form or the page.
>> But i thought the tag would take care of it.
>>
>> How do you reload the form/page in that case ?
>>
>> --- On *Thu, 1/14/10, Lincoln Baxter, III
>> /
/* wrote:
>>
>>
>> From: Lincoln Baxter, III
>> Subject: Re: [webtier] JSF 2.0: re-render a dataTable with
>> Ajax ?
>> To: webtier@glassfish.dev.java.net
>> Date: Thursday, January 14, 2010, 12:18 AM
>>
>> Or reload the entire page/data structure.
>>
>> Lincoln Baxter III
>> http://ocpsoft.com
>> http://scrumshark.com
>> Keep it simple.
>>
>>> On Jan 13, 2010 1:10 PM, "Celinio Fernandes"
>>>
wrote:
>>>
>>> Hi,
>>> I found several posts dealing with my problem :
>>> http://forums.java.net/jive/thread.jspa?messageID=332548
>>> http://forums.java.net/jive/thread.jspa?messageID=373960
>>>
>>> None gives answers unfortunately.
>>>
>>> My problem is simple : I have a dataTable which contains
>>> a list of products, the last column has a link to delete
>>> a product.
>>>
>>>
>>>
>>>
>>>
>>> ...
>>>

>>> ...
>>>
>>>
>>>
>>>
>>>

>>>

>>>

>>>
>>>

>>>
>>> My delete method looks like this :
>>> public void delete() {
>>> FacesContext context = FacesContext.getCurrentInstance();
>>> Map params =
>>> context.getExternalContext().getRequestParameterMap();
>>> String idNumber = params.get("id");
>>> myEJB.delProduct(idNumber);
>>> }
>>>
>>>
>>> It deletes the product. However it does not re-render the
>>> dataTable. What am i missing ?
>>> What value should the render attribute be set to in that
>>> case ?
>>>
>>> Thanks in advance for helping.
>>>
>>>
>>
>>
>
>
> --
> Jason Lee
> Senior Java Developer
> GlassFish Administration Console
>
> Sun Microsystems, Inc.
> Phone x31197/+1 405-343-1964
> Emailjasondlee@sun.com
> Bloghttp://blogs.sun.com/jasondlee
> Bloghttp://blogs.steeplesoft.com
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

Celinio Fernandes

Well,

it does not go totally silent.

If i use then i get this error :

10:30:56,458 SEVERE [application] Error Rendering View[/blabla/myPage.xhtml]

javax.faces.FacesException: contains an unknown id
'Form1' - cannot locate it in the context of the component j_idt80

    at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.getResolvedId(AjaxBehaviorRenderer.java:282)

    at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.appendIds(AjaxBehaviorRenderer.java:269)

    at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.buildAjaxCommand(AjaxBehaviorRenderer.java:214)

    at com.sun.faces.renderkit.html_basic.AjaxBehaviorRenderer.getScript(AjaxBehaviorRenderer.java:86)

    at javax.faces.component.behavior.ClientBehaviorBase.getScript(ClientBehaviorBase.java:99)

    at com.sun.faces.renderkit.RenderKitUtils.appendBehaviorsToChain(RenderKitUtils.java:1393)

    at com.sun.faces.renderkit.RenderKitUtils.getChainedHandler(RenderKitUtils.java:1531)

    at com.sun.faces.renderkit.RenderKitUtils.renderHandler(RenderKitUtils.java:1703)

    at com.sun.faces.renderkit.RenderKitUtils.renderOnclick(RenderKitUtils.java:429)

    at com.sun.faces.renderkit.html_basic.CommandLinkRenderer.renderAsActive(CommandLinkRenderer.java:231)

    at com.sun.faces.renderkit.html_basic.CommandLinkRenderer.encodeBegin(CommandLinkRenderer.java:125)

    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:823)

    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:285)

    at com.sun.faces.renderkit.html_basic.TableRenderer.renderRow(TableRenderer.java:380)

    at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:161)

    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)

    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1610)

    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)

    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)

    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1610)

    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)

    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)

    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:379)

    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)

    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)

    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:183)

    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:95)

    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)

    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)

    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)

    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)

    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

    at java.lang.Thread.run(Unknown Source)

--- On Thu, 1/14/10, Jim Driscoll wrote:

From: Jim Driscoll
Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
To: webtier@glassfish.dev.java.net
Cc: "Celinio Fernandes"
Date: Thursday, January 14, 2010, 1:25 AM

Out of curiosity, you do have the project stage set to development,
right?  And does it give an error when it's not updating the form?  Or
does it fail silently?

Jim

On 1/13/10 10:51 AM, Celinio Fernandes wrote:
> Well, I tried "Form1" (without the colon), "Form1:dataTable1" before and
> it did not work.
>
> --- On *Thu, 1/14/10, Jason Lee //* wrote:
>
>
>     From: Jason Lee
>     Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
>     To: webtier@glassfish.dev.java.net
>     Date: Thursday, January 14, 2010, 12:49 AM
>
>     You specified render=":Form1:dataTable1". I think the leading : in
>     the component ID was confusing things.
>
>     On 1/13/10 12:47 PM, Celinio Fernandes wrote:
>>     I got it working with this :
>>     
>>
>>     Before that, I tried with the value of the render attribute set to
>>     the id of the form and it did not work. How come ?
>>
>>
>>     --- On *Thu, 1/14/10, Celinio Fernandes /
/*
>>     wrote:
>>
>>
>>         From: Celinio Fernandes
>>         Subject: Re: [webtier] JSF 2.0: re-render a dataTable with Ajax ?
>>         To: webtier@glassfish.dev.java.net
>>         Date: Thursday, January 14, 2010, 12:33 AM
>>
>>         Thanks for helping.
>>         I understand that i need to reload the form or the page.
>>         But i thought the tag would take care of it.
>>
>>         How do you reload the form/page in that case ?
>>
>>         --- On *Thu, 1/14/10, Lincoln Baxter, III
>>         /
/* wrote:
>>
>>
>>             From: Lincoln Baxter, III
>>             Subject: Re: [webtier] JSF 2.0: re-render a dataTable with
>>             Ajax ?
>>             To: webtier@glassfish.dev.java.net
>>             Date: Thursday, January 14, 2010, 12:18 AM
>>
>>             Or reload the entire page/data structure.
>>
>>             Lincoln Baxter III
>>             http://ocpsoft.com
>>             http://scrumshark.com
>>             Keep it simple.
>>
>>>             On Jan 13, 2010 1:10 PM, "Celinio Fernandes"
>>>             
wrote:
>>>
>>>             Hi,
>>>             I found several posts dealing with my problem :
>>>             http://forums.java.net/jive/thread.jspa?messageID=332548
>>>             http://forums.java.net/jive/thread.jspa?messageID=373960
>>>
>>>             None gives answers unfortunately.
>>>
>>>             My problem is simple : I have a dataTable which contains
>>>             a list of products, the last column has a link to delete
>>>             a product.
>>>
>>>             
>>>
>>>             
>>>             
>>>             ...
>>>             

>>>             ...
>>>             
>>>             
>>>             
>>>             
>>>             

>>>             

>>>             

>>>
>>>             

>>>
>>>             My delete method looks like this :
>>>             public void delete() {
>>>             FacesContext context = FacesContext.getCurrentInstance();
>>>             Map params =
>>>             context.getExternalContext().getRequestParameterMap();
>>>             String idNumber = params.get("id");
>>>             myEJB.delProduct(idNumber);
>>>             }
>>>
>>>
>>>             It deletes the product. However it does not re-render the
>>>             dataTable. What am i missing ?
>>>             What value should the render attribute be set to in that
>>>             case ?
>>>
>>>             Thanks in advance for helping.
>>>
>>>
>>
>>
>
>
>     --
>     Jason Lee
>     Senior Java Developer
>     GlassFish Administration Console
>
>     Sun Microsystems, Inc.
>     Phone x31197/+1 405-343-1964
>     Emailjasondlee@sun.com
>     Bloghttp://blogs.sun.com/jasondlee
>     Bloghttp://blogs.steeplesoft.com
>
>

[att1.html]

Celinio Fernandes

Hi,
I have this tag where the user can change the language.

              
                
              
     

      
Here is the method of the managed bean :
      
    public void changerLangueComboBox(ValueChangeEvent event) {
        FacesContext context = FacesContext.getCurrentInstance();
        if ("en".equals((String) event.getNewValue())){
             context.getViewRoot().setLocale(Locale.UK);
             this.locale = Locale.UK;    
        } else  if ("fr".equals((String) event.getNewValue())) {
             context.getViewRoot().setLocale(Locale.FRENCH);
             this.locale = Locale.FRENCH;    
        }
        log.info("context.getViewRoot().getLocale() is : " + context.getViewRoot().getLocale());
    }      
      
      
The method is called but the values of the current view are not updated. They are updated if i refresh the page.
Here are the sequence of phases calls :
1) User changes the language :
20:11:18,127 INFO  [STDOUT] Processing new  Request!
20:11:18,128 INFO  [STDOUT] before - RESTORE_VIEW 1
20:11:18,141 INFO  [STDOUT] after - RESTORE_VIEW 1
20:11:18,141 INFO  [STDOUT] before - APPLY_REQUEST_VALUES 2
20:11:18,141 INFO  [STDOUT] after - APPLY_REQUEST_VALUES 2
20:11:18,141 INFO  [STDOUT] before - PROCESS_VALIDATIONS 3
20:11:18,142 INFO  [LoginBean] context.getViewRoot().getLocale() is : fr
20:11:18,142 INFO  [STDOUT] after - PROCESS_VALIDATIONS 3
20:11:18,143 INFO  [STDOUT] before - RENDER_RESPONSE 6
20:11:18,150 INFO  [STDOUT] after - RENDER_RESPONSE 6
20:11:18,150 INFO  [STDOUT] Done with Request!
    
2) User refreshes the page :
20:11:37,402 INFO  [STDOUT] Processing new  Request!
20:11:37,402 INFO  [STDOUT] before - RESTORE_VIEW 1
20:11:37,417 INFO  [STDOUT] after - RESTORE_VIEW 1
20:11:37,417 INFO  [STDOUT] before - APPLY_REQUEST_VALUES 2
20:11:37,418 INFO  [STDOUT] after - APPLY_REQUEST_VALUES 2
20:11:37,418 INFO  [STDOUT] before - PROCESS_VALIDATIONS 3
20:11:37,419 INFO  [STDOUT] after - PROCESS_VALIDATIONS 3
20:11:37,419 INFO  [STDOUT] before - UPDATE_MODEL_VALUES 4
20:11:37,419 INFO  [STDOUT] after - UPDATE_MODEL_VALUES 4
20:11:37,419 INFO  [STDOUT] before - INVOKE_APPLICATION 5
20:11:37,420 INFO  [STDOUT] after - INVOKE_APPLICATION 5
20:11:37,420 INFO  [STDOUT] before - RENDER_RESPONSE 6
20:11:37,428 INFO  [STDOUT] after - RENDER_RESPONSE 6
20:11:37,428 INFO  [STDOUT] Done with Request!

Obviously, the  UPDATE_MODEL_VALUES et INVOKE_APPLICATION phases are skipped the first time.

Question : why are they skipped and how can i call them ?
Well I did manage to call these 2 phases the first time with these 2 lines :
    event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
            event.queue();
In that case all phases are called. Still, I need to refresh the page to get the chosen language.

Thanks in advance for helping.   

[att1.html]

napu
Offline
Joined: 2003-07-30

Sorry, you lost me there.

If I'd want a PhaseListener type listener method I'd create it with a signature like:

public void xxx(PhaseEvent e)

and reference to it with:

But as the page https://javaserverfaces.dev.java.net/nonav/docs/2.0/pdldocs/facelets/f/v... says, the method signature for a reference like:

should be like:

public String/Locale getXxx()

And the method signature should be no problem as it is called succesfully. (I tried the listener one too and the call worked but I did not succeed in changing the page language.)

Or did I miss something here?

napu
Offline
Joined: 2003-07-30

Replying to myself (and marking my question as answered):

In Mojarra 1.2_14 and Facelets I get the same erroneous behaviour when I add the following context parameter to web.xml:

[pre]

facelets.BUILD_BEFORE_RESTORE true [/pre]

(The parameter does not seem to affect Mojarra 2.0.2 and the behaviour cannot be remedied with it.)

I was able to bypass the problem in 2.0 by "forcing" a new view root build by changing the view root programmatically, e.g. (pay attention to the last 2 rows):

[pre]
if ("fi_FI".equals(newLanguage)) {
facesCtx.getViewRoot().setLocale(new Locale("fi", "FI"));
} else {
facesCtx.getViewRoot().setLocale(new Locale("en", "GB"));
}
[b]UIViewRoot view = facesCtx.getApplication().getViewHandler().
createView(facesCtx, "/pages/chooseproduct.xhtml");
facesCtx.setViewRoot(view);[/b][/pre]

Lincoln Baxter, III

What is the signature of bean.userLocale? It must match the signature
defined here:

https://javaserverfaces.dev.java.net/nonav/docs/2.0/pdldocs/facelets/f/v...

void afterPhase(javax.faces.event.PhaseEvent))

--Lincoln

On Tue, Jan 12, 2010 at 8:35 AM, wrote:

> Hi!
>
> I'm upgrading a small (working) programme from JSF 1.2 and JSP to JSF 2.0
> and Facelets.
>
> My problem is that locale change which is referenced on the Facelet page as
>
>
>
> works only after the page is manually refreshed (after the locale change
> form has been submitted).
>
> I have tried various methods with no success yet:
> - form button with immediate="true" and context.getViewRoot().setLocale(new
> Locale("xx", "YY")) in managed bean code
> - normal form without immediate="true"
> - an ajax button with
>
> Googling for this turned up a couple of similar problems but no working
> solutions.
> [Message sent by forum member 'napu' (panu.korpela@fcspartners.fi)]
>
> http://forums.java.net/jive/thread.jspa?messageID=380291
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
[att1.html]

napu
Offline
Joined: 2003-07-30

public String getUserLocale()

And the value is e.g. "en_GB" or "fi_FI".

I assume there should be no problem with that as the same code worked well with 1.2 and it still works after an extra page refresh.

Lincoln Baxter, III

Public void getUserLocale(javax.faces.event. PhaseEvent)) ?

Lincoln Baxter III
http://ocpsoft.com
http://scrumshark.com
Keep it simple.

On Jan 13, 2010 1:04 AM, wrote:

public String getUserLocale()

And the value is e.g. "en_GB" or "fi_FI".

I assume there should be no problem with that as the same code worked well
with 1.2 and it still works after an extra page refresh.
[Message sent by forum member 'napu' (panu.korpela@sovelto.fi)]

http://forums.java.net/jive/thread.jspa?messageID=380532

--------------------------------------------------------------------- To
unsubscribe, e-mail: webti...
[att1.html]

Celinio Fernandes

Hi,
I found several posts dealing with my problem :
http://forums.java.net/jive/thread.jspa?messageID=332548
http://forums.java.net/jive/thread.jspa?messageID=373960

None gives answers unfortunately.

My problem is simple : I have a dataTable which contains a list of products, the last column has a link to delete a product.

 
  
 
 
  ...
 

 ...
   
 
                  
               
 
            
 
 
   

   
 

My delete method looks like this :
 public void delete() {
        FacesContext context = FacesContext.getCurrentInstance();
        Map params = context.getExternalContext().getRequestParameterMap();
        String idNumber = params.get("id");
        myEJB.delProduct(idNumber);
    }

It deletes the product. However it does not re-render the dataTable. What am i missing ?
What value should the render attribute be set to in that case ?

Thanks in advance for helping.

[att1.html]

Lincoln Baxter, III

Remove the entity from the list...

Lincoln Baxter III
http://ocpsoft.com
http://scrumshark.com
Keep it simple.

On Jan 13, 2010 1:10 PM, "Celinio Fernandes"
wrote:

Hi,
I found several posts dealing with my problem :
http://forums.java.net/jive/thread.jspa?messageID=332548
http://forums.java.net/jive/thread.jspa?messageID=373960

None gives answers unfortunately.

My problem is simple : I have a dataTable which contains a list of products,
the last column has a link to delete a product.



...

...






My delete method looks like this :
public void delete() {
FacesContext context = FacesContext.getCurrentInstance();
Map params =
context.getExternalContext().getRequestParameterMap();
String idNumber = params.get("id");
myEJB.delProduct(idNumber);
}

It deletes the product. However it does not re-render the dataTable. What am
i missing ?
What value should the render attribute be set to in that case ?

Thanks in advance for helping.
[att1.html]