I need help in implementing CRUD operations. My application contains a table of objects. Each object is described by a list of properties(values). One property is modified with a custom JSF editor, depending on the property type.
When the user adds a new account, the list of editors is determined from the object's type, and displayed in a form using custom:include
tags. This custom tag is used to dynamically include the editors <custom:include src="#{editor.component}">
. The component property points to the location of the JSF editor.
Every editor has a managed bean that implements a ValueHolder
interface and inherits a AbstractEditor
class. AbstractEditor contains a updateEditor method.
public interface ValueHolder {
String EDITOR_VALUES = "editorValues";
public Object getValue();
}
I use a session map, with the editor name as key and editor value as values. When the user modifies a property, the updateEditor method is called and the map is updated with the new value of the editor.
The problem is with the scope of the beans behind the editors. If I use @SessionScoped beans, the code that initializes the editor is not called again and I can't handle the add/edit actions. The @SessionScoped works only for adding. I have tried with @RequestScoped, but the beans are called very often and I don't know if that is really good.
I am using JSF2, PrimeFaces 3.0.M4 and Spring Web Flow for navigation.