2

I have the following code logging out the user from app and "send" him back to the session based authentication page ( Thanks Paul Withers ):

 clearing_function(sessionScope); 

 var appUrl = facesContext.getExternalContext().getRequest().getContextPath();
 var url = appUrl + "?logout&redirectto=" + appUrl;
 facesContext.getExternalContext().redirect(url);

Is there any chance to have like a @prompt formula with yes/no and just in case if user selects yes the above code ( from ssjs ) to be executed? Or I must write the confirmation message in csjs. But, then, how can I transform the above code in csjs?

Florin M.
  • 2,159
  • 4
  • 39
  • 97

1 Answers1

2

You can use the Dialog component from extension library to build a confirmation box with two buttons where the positive button runs your logout code

    <xe:dialog id="dialog1">
            <xp:panel>
                <xp:button value="OK" id="button1">
                    <xp:eventHandler event="onclick" submit="true"
                        refreshMode="complete">
                        <xp:this.action><![CDATA[#{javascript:clearing_function(sessionScope); 

             var appUrl = facesContext.getExternalContext().getRequest().getContextPath();
             var url = appUrl + "?logout&redirectto=" + appUrl;
             facesContext.getExternalContext().redirect(url);}]]></xp:this.action>
                    </xp:eventHandler></xp:button>
                <xp:button value="Cancel" id="button2">
                    <xp:eventHandler event="onclick" submit="true"
                        refreshMode="partial" refreshId="dialog1">
                        <xp:this.action><![CDATA[#{javascript:getComponent("dialog1").hide();}]]>   </xp:this.action>
                    </xp:eventHandler></xp:button></xp:panel>
    </xe:dialog>

To hide the default x button just override the relevant css classes:

for oneui themes it's the "lotusBtnImg" class for webstandard it's the ".dijitDialogCloseIcon" class

PoisonedYouth
  • 548
  • 3
  • 16