Question

I just am placing the outline of my problem here since it is very difficult to depict the real scenario. i have an application in jsf 1.2 and rich faces 3. It stores employees basic data and related data (family, employment record, qualification etc) in separate tables. when user clicks on its own name. details from several tables related to employee are shown on a page. like family, employment record, qualification record etc. primary key in employee basic table is emp_id (a number). this key is foreign key in all related child tables. Application is centrally deployed and used in different cities. the problem is, when a particular employee clicks its details....unknown records are shown in his account like family of any other employee...the interface is like

  ---------------------------------------------------------------------------
     Wellcome Mr. Campatrick,Sales Executive             <<View Details>>
  ---------------------------------------------------------------------------

when view details is clicked....emp_id of Mr.Campatrick is set in the employee_bean. where employee_bean is session scoped. If at all this make any sense....what could be the possible reason of mixing up of records when i categorically set the emp_id on "view details" link. It is something related to "Memory leak"? if yes, where to check it.

Was it helpful?

Solution

The problem looks to be an abuse of managed beans in session scope. Since you say you work with JSF 1.2 and RichFaces 3, I would recomend to change your managed beans from session scope to request scope and add the @KeepAlive annotation to those managed bean that must behave as view scope.

Your bean would look like

@KeepAlive
public class NoSessionScopeAnymore {
    //fields, constructor, getters and setters, methods...
}

More info about the KeepAlive annotation or as component: <a4j:keepAlive>

From JSF 2 you won't need this since you can use the @ViewScoped that solves the bridge between request and session. More info about managed bean scopes:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top