• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSF [1.2] Managed bean [request scoped] constructor called twice during same request

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

We are facing a strange scenario.

We have a jsf page and a request scoped bean. When we submit the page, if there are any validation errors then same page is displayed with errors.

On development machines only 1 instance of managed bean is created for above scenario.
[managed bean instance is created -> action method is called -> validation fails -> same page is rendered]

But on our test environment 2 instances are created for the same scenario,
[managed bean instance is created -> action method is called -> validation fails -> a new instance is created -> same page is rendered]

This issue is causing inconsistency in our application.

How do we control this behavior? Is there any configuration in faces-config.xml or web.xml?

*NOTE: We are using websphere portal 7.0 on test machines and 6.1 on local machines.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check pages are correctly ordered
 
Ajay Kamble
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by order?

Please note that in the given scenario there is only 1 page involved.
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Request scope is almost completely useless in JSF.

JSF uses a postback mechanism that results in multiple requests. Each request creates and destroys its own set of request-scope objects (if any were defined). A subsequent postback gets a whole new set of objects constructed.

Originally that meant that a lot of stuff that's traditionally Request scope had to be promoted to Session scope. JSF2 added View scope to get around that. Unfortunately, WAS 6.1 is quite ancient and doesn't support View Scope. Since it's a test environment, I recommend upgrading. Otherwise you'll have to use Session scope.
reply
    Bookmark Topic Watch Topic
  • New Topic