In an JSF 1.2 application I'd like to have some "global service" pages,
which which can be accessed from different parts of the application and
deliever their result back to that part where it came from.

This is a bit abstract, so here is an example: In different places of the
application, there is a need to search a user in a user database. The
process of selecting the user is the same each time, e.g. entering the
user's name and department in a search form. So on each of these pages,
there should be a "select user" button, which opens a new page where the
search data is read and the search is performed. Of course, the result of
the search needs to be returned to the calling page (i.e. its controller)
somehow. There might be different "select user" buttons on one single page
(for different roles, e.g. "select administrator", "select technical
writer" etc.)

This is problematic because the "select user" page does not know what to do
with the result, and how to return control to the calling page so that the
calling page can fetch the result and take appropriate action.

I have a solution which I consider quite a hack: The original page stores
an ELExpression in the session, which is to be evaluated by the "search
user page" controller after it has stored the selected users in the
session. The outcome of the ELExpression selects a navigation rule which
directs back to the original point. The ELExpression in the session stores
the user from the session in the appropriate place of the calling page's
controller.
What I do not like about this solution:
- Defining and calling an EL programatically is complicated and not easily
understandable. I'd be happy if I would not have to do this.
What I like about the solution:
-  The "search user" page does not need to know where to store the result.
It provides a "service" and does not care from where it is called.

So my question is: Can anyone think of an alternative approach to this,
which preserves the "service" idea ?

  Thanks in advance,

       Thomas

Reply via email to