On 1/23/07, JS Portal Support <[EMAIL PROTECTED]> wrote:

Hi,

I have a ViewController which in it's prerender checks if the user in the
session is logged or not. If not, I want to start a subdialog logging the
user in.

On page http://shale.apache.org/shale-dialog/index.html at: "Starting A
DialogContext Programmatically" it is described how I can do this. I don't
understand it though. Do I need to build my own DialogContextManager and
DialogContext as they seem to be interfaces? Or are there implementations
I
can use, and if so, where can I find them? An example would be great!


The "shale-test-dialog-basic" and "shale-test-dialog-scxml" test webapps
(they are built nightly along with the framework) have an example of this
use case.  One nice feature is that the application coding is the same no
matter which implementation you use.

The DialogContextManager instance is created for you by the framework, so
all you will need to do is acquire a reference to it, and then ask it to
create you a DialogContext instance like this:

   FacesContext context = FacesContext.getCurrentInstance();
   DialogContextManager manager = (DialogContextManager)
     context.getApplication().getVariableResolver().
     resolveVariable(context, Constants.MANAGER_BEAN);
   DialogContext dcontext = manager.create(context, "myDialogName");
   dcontext.start(context);

You do not have to do anything else about storing the DialogContext
instance, because the manager will have taken care of that for you.

By the way, the reason for using the variable resolver, in the code example
above, is because the dialog framework defines the manager as a managed
bean.  Doing things this way (instead of just checking the write scoped
attributes) causes the manager to be created if it does not already exist.


By the way, is this a good architecture approach, checking the logged status
on prerender and preprocess? Or are there other better ways to do this?


The only thing I would be concerned about is navigation -- I haven't
personally tested whether you can successfully navigate (say, to a login
page) from the prerender() method.  If that works for you, then this seems
like a reasonable approach.

Thanks,
Joost Schouten



Craig

Reply via email to