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

Hi,

A second question on dialog's. I have my logging working well with the
following dialogs:

<dialog name="Log On" start="Check Logged">
    <action name="Check Logged" method="#{logon.isLogged}">
      <transition outcome="not_logged" target="Authenticate"/>
      <transition outcome="logged" target="Exit"/>
    </action>
        <subdialog  name="Authenticate" dialogName="Authenticate User">
      <transition outcome="authenticated" target="Exit"/>
    </subdialog>
    <end name="Exit" viewId="/jsp/dashboard.jsp"/>
  </dialog>

  <!--this part is pulled from the logon process so that it can be called
as
a subdialog in any process
  started not logged-->

  <dialog name="Authenticate User" start="Logon Page">
        <view name="Logon Page" viewId="/logon.jsp">
                <transition outcome="authenticated" target="Exit"/>
        <transition outcome="unauthenticated" target="Logon Page"/>
                <transition outcome="discontinued_account" target="Logon
Page"/>
        </view>
    <end name="Exit"/>
  </dialog>

This works great if called from :

<h:form id="startLogon">
<h:commandLink action="dialog:Log On" value="test logon"/>
</h:form>

But when I access the /logon.jsf directly I would like this dialog to be
started automatically. How do I do this?


Conceptually, the simplest way to do this would be to see if there is
already an active dialog, and (if not) start the "Authenticate User" dialog
programmatically as discussed in the previous thread.  The way to check this
is not currently particularly elegant:

   FacesContext context = FacesContext.getCurrentInstance();
   DialogContext dcontext = (DialogContext)
     context.getExternalContext().getRequestMap().get(
Constants.CONTEXT_BEAN);
   if ((dcontext != null) && dcontext.isActive()) {
       ... there is already an active dialog, so keep using it ...
   } else {
       ... there is no active dialog, so start one ...
   }

It might be nice to offer a "return me the active DialogContext for this
request, if any" method on DialogContextManager to make this a little
easier.

That being said, I'm not sure I would like mixing the "start a dialog with
navigation" and "start a dialog programmatically if it is not started yet"
styles.  I would tend to go towards one or the other, if for no other reason
than to make it obvious what the next developer should do when the next
dialog is added to this application later on.


Thank you,
Joost


Craig

Reply via email to