I faced now several times the issue that the Event Scope is to big and the Stateless Scope is to small. For example with methods like isManaged() from the EntityHome.
Let me explain this:
I have a page to create/update/view an entity. If i want to create one the rendered page will call isManaged() several times to evaluate the rendered attribute for which button to display.
- Not Managed - Persist button
- Managed - Update button
This happens in the jsf phase
Restore view and again in
Each method call does not consume alot of time, but since you can have several fields in the page which use that method it will increase the processing alot in total.
Now we know about Scopes and use a factory in the Event scope for this to speed up the processing.
And here the issue comes up.
Since the rendered attribute is evaluated already in the
Restore view phase, to check which fields to process, and the event scope spawns the complete request we will persist the object and in the
Render Response phase this attribute exists in the context and is not evaluated again. Because of that we will still see the Persist button and not the Update button yet.
If you choose now the Stateless scope it is just a beautifier for the xhtml page.
Here i think we could introduce a new kind of Scope. SubEvent or something like this. I think it should spawn for the first 5 jsf phases and spawn again for the Render Response phase.
isManaged is probably not the best example but what about an isEditMode which is used by each field on the page to evaluate if it should display a text or a textfield?
Or a select box which changes the content because of a change on the entity? There I think we could catch alot of speedup.
I tried to take a look at the seam source but honestly i have no clue where to start :D
Could this be solved by a
simple phase listener aside the Seam Framework? But then we cannot use the Factory annotation and need something else.
Does someone know if there is a possible way to introduce new context types in Seam or is able to point me in the right direction inside the seam code, i'm very willing to investigate there a little.
Please let me know what you think about it.