[Solved] Need assistance with WebSessionContext...

The example in the following page SETS the ‘currentpage’ property of a websession:

http://documentation.xojo.com/index.php/WebSessionContext

However, the following page on the websession states the ‘currentpage’ property is read-only:

http://documentation.xojo.com/index.php/WebSession

Also… what I’m trying to do is use WebSessionContext to pull up a session, then show a dialog on that session. Anybody have any idea how this is possible? I tried creating a method within the session class called ‘showDialog’; however, when you declare that session through WebSessionContext as in the following example… the method doesn’t appear.

Session.showdialog (is valid)

dim sessionContext as new websessioncontext(app.sessionatindex(sessionIndex))
sessionContext.session.showdialog (is invalid… doesn’t even come up, and displays an ‘item not found’ error)

Basically, what I’m trying to do is if another session starts tied to the same username associated with a particular session, it displays a dialog informing of the multiple connection attempt and kicks them off.

It would be a lot easier to add a method to the App class that iterates through the sessions and then just calls a method on the offending session to show your dialog.

WebSessionContext is for creating a session object when one normally wouldn’t exist, not for accessing one session from within another.

Alright… thanks, and that makes sense. So, I’m going to use app.sessionWithIdentifier then, instead of WebSessionContext. I’m still unsure how I then use that session and open a dialog to it only, even if using a global app method. How can I reference a dialog class to only open on a particular active session? There’s no where (at least to my knowledge and searching) to reference it.

I use this in a method in the App class to call a method in all active sessions. Maybe that could get you in the right direction?

  For i = 0 to SessionCount-1
  SessionAtIndex(i).showMsg(title, message)
  next

You should be able to do something like that but with SessionWithIdentifier instead.

Thanks Albin, it’s helping. Am I understanding correctly though that getting an actual webdialog class to appear on the targeted session is not possible? I can display a msgbox using the sessions.msgbox property. What I’m wanting is to create a webdialog, and have that shown on command to a specific active session. I’ve been trying for hours to get something working. The closest I got was:

[code] totalSessions = app.sessioncount

      for sessionIndex = 0 to totalSessions - 1
        if app.sessionAtIndex(sessionIndex).identifier = sessionDictionary(loopIndex).lookUp("identifier", wapp.NULL_STRING) then
          
          dim targetSession as session
          dim dialogMultipleLogin as dialogML // - which is a webdialog class in my application
          
          targetSession = app.sessionAtIndex(sessionIndex)
          
          targetSession.showDialog(dialogMultipleLogin)
        end if
      next[/code]

The session.showDialog method (which is a method under the session class just consists of:

[code]function showDialog(referenceDialog as webdialog)

referencedialog.show

end function[/code]

This problem is, the dialog box is showing up not at the targeted session… but the current session that invoked it. (Hope that makes sense).

BTW… I had to dim the app.sessionAtIndex(sessionIndex) as a new session because app.sessionAtIndex(sessionIndex).showDialog was not valid and showed a “item not found” (the method wasn’t located this way). Dim it as a new session, and it locates it… where targetSession.showDialog is valid and the method is found just fine.

I’ve re-read my own posts, and am confusing even myself with how I’m trying to explain what I’m looking to do. Here’s what I need, basically, in a nutshell:

Have two web sessions opened, each in a separate browser. Each session has a simple button. When the button is clicked on one browser, it opens a webdialog on the other browser session (the webdialog being one that you’ve added to the project, and created with controls… not just a simple msgbox popup).

I don’t see why showing a WebDialog in the other session is any different than showing a MsgBox.

I just tried tweaking the PushExample (included in the Web folder) to show a WebDialog from another session instead of a MsgBox and it seemed to work fine. I just added the WebDialog to the page and called Show on it.

This is the difference. Eric is trying to pass a WebDialog to the session instead of using one that was put there at design time.

Eric, try creating the dialog in your showDialog method instead of passing it in.

Thanks guys for the advice… FINALLY got it working with the suggestions from Paul, with Jay’s follow-up. Ever in Dallas, PM me… beer on me! :slight_smile:

A yes, that would do it. Creating it ahead of time, the WebDialog was connected to the wrong WebSession.