Modal Prompts in JS

Paul Mulroney pmulroney at logicaldevelopments.com.au
Thu Nov 21 19:34:49 EST 2019


Hi Jim,

We use a subform set to show the dialog box. Subform sets are awesome! This is in Studio 10, but I'm sure it will work the same in Studio 8.

It's not modal, but it provides a way to have dialog boxes defined in the superclass/main form, and then just override as required.  This is how we set it up:

- In the main form we setup the subform set in the $construct.  The code is this:

> # Create a sub-form set for popups
> Do vlFormList.$define(vnUniqueID,vsClassName,vsParams,vsTitle,vnLeft,vnTop,vnWidth,vnHeight,vnModal)
> Do $cinst.$clientcommand('subformset_add',row(clsSetName,'',0,'',vlFormList))   ## Set Name, Parent, Flags, Tracking Var, Form List


- We have a remote form that contains a display field for our message, and Yes and No buttons. We pass the message using a task var (that's a bit nasty, but it works!).

- In the main form, we have a a method $showMultiLineMessage, that we display our multi-line message to the user.  We can call this from the subform that we're using.  The height is variable, based on the number of lines we want to display. The code is this:

> # - Display a custom (multi-line) yes/no message
> Calculate tvMessage as psMessage
> Calculate vnWidth as min(max(tnScreenWidth/2,320),768)
> Calculate vnHeight as 80+pnLines*16
> Calculate vsParams as ''                                                        ## comma separated list of literal parameters
> Calculate vRowParams as row($cinst.clsSetName,$cinst.clnMessageID,'jsMultiLineMessage',vsParams,psTitle,kSFScenter,kSFScenter,vnWidth,vnHeight,1)
> Do $cinst.$clientcommand('subformset_formadd',vRowParams)

- The Yes/No buttons that we have on the form we're using for the subform have code like the following:

> On evClick
>   Set reference vrMain to $cinst.$container
>   Do vrMain.$messageConfirm()   ## or vrMain.$messageCancel()
>   Quit event handler

- In the main form we have a method $messageConfirm() and $messageCancel(). They have code like this:

> # - Called when the user clicks the Yes button on the message sub-form
> Do $cinst.$clientcommand('subformset_formremove',row($cinst.clsSetName,$cinst.clnMessageID))
> Set reference vrSubForm to $cinst.$objs.objSubform[inCurrentPage].$subinst  ## paged pane showing different forms.  work out which one we're currently displaying.
> Do vrSubForm.$messageConfirm(psResponse)                                        ## process the message confirmationQuit method 

- In the subform we have $messageConfirm() and $messageCancel(), and we can override these to take action as required.

The subforms are all based on a superclass, so we define a number of standard functions and just override as required.  We have a couple of dialog boxes like this and they seem to work fairly well.

Hope that helps.

Regards,
Paul.



> On 22 Nov 2019, at 2:21 am, Jim Pistrang <jim at jpcr.com> wrote:
> 
> Hi all,
> 
> Similar to Will, I am working on a strategy for presenting a prompt in the js environment.  My prompt will need to appear on multiple forms, and it is more complex than a simple OK or Yes/No message.
> 
> My js forms all have a common superclass, so I was hoping to place a 'prompt box' on the superclass in the form of a paged pane that would be invisible by default but made visible to display a prompt.  This works, BUT the $order of the superclass paged pane is a lower number than the child form objects, so the paged pane appears behind other objects on the form.  Is there something I can do to get the paged pane in front of the other objects?
> 
> Jim
> 
> 
> 
>> 
>> Hi All,
>> 
>> I'm missing the Euromnis get-together this year, hope you're all doing
>> well though.
>> 
>> This is a question about prompts and the Omnis mechanism that runs the
>> JS remote forms. We have about 3000 Yes/No messages in our app as well
>> as a bunch or other prompts that require some form of user choice before
>> continuing - they all run from a single task level object variable that
>> builds and displays a suitable prompt then returns with the user
>> selection. The problem is that this is often in the middle of a method
>> i.e. halfway through processing an invoice, we might warn if the stock
>> is going to drop below a level and ask if they want to continue... for
>> example...
>> 
>> In the current system this is modal, so Omnis execution pauses at that
>> point in the method stack while we wait for a response. I had hoped to
>> do something similar with JS forms so that we do not have to spilt and
>> rewrite the majority of our core methods, however it does not appear to
>> be that easy.
>> 
>> I know that the browser on the client runs asynchronously to the Omnis
>> server but was hoping I could work around it by issuing the client
>> command to show a Yes/No prompt and then immediately entering a while
>> loop while we wait for a user response, (in order to keep Omnis
>> executing within our prompt method). When the browser responds with a
>> result it would change the condition of the while loop and then we would
>> then exit with the response. In this way the JS version works the same
>> as the thick client and if there are multiple remote tasks they can time
>> slice on the server and would still be responsive.
>> 
>> But it does not work. The browser does not display the Yes/No prompt
>> until the Omnis code stops executing on the server, which means we have
>> to exit the method and then start a new stack after the user response,
>> which means we need to rewrite any code that contains a Yes/No. Hmmm.
>> 
>> The above process may not be the best way to structure code, but it
>> would save us a hell of a lot of time. Is there are a way I can "flush"
>> the current method stack to force Omnis to update the client mid-stack?
>> Perhaps there is another way to simulate a modal response in the world
>> of JS remote forms?
>> 
>> Any thoughts? All Ideas welcome!
>> 
>> Best regards
>> 
>> Will
>> 
>> 
>> 
>> [Lineal Software Solutions]        <http://www.lineal.co.uk>
>> 
>> [Twitter]<https://twitter.com/linealsoftware>  [Facebook] <https://
>> www.facebook.com/linealsoftware?fref=ts&ref=br_tf>   [Google +] <https://
>> plus.google.com/112982815000763473226/about>   [LinkedIn] <https://
>> www.linkedin.com/company/1859834?trk=
>> tyah&trkInfo=clickedVertical%3Acompan
>> y%2Cidx%3A1-1-1%2CtarId%3A1437729256906%2Ctas%3Alineal%20s>
>> 
>> [https://s3.amazonaws.com/htmlsig-assets/spacer.gif]
>> 
>> Will Adkin  / Software Development Manager
>> will at lineal.co.uk<mailto:will at lineal.co.uk>
>> 
>> Lineal Software Solutions
>> 01271 375999
>> Commercial House, The StrandBarnstaple, Devon, EX31 1EU
>> www.lineal.co.uk<http://www.lineal.co.uk>
>> 
>> 
>> 
>> This e-mail message may contain confidential or legally privileged
>> information and is intended only for the use of the intended
>> recipient(s). Any unauthorized disclosure, dissemination, distribution,
>> copying or the taking of any action in reliance on the information
>> herein is prohibited. E-mails are not secure and cannot be guaranteed to
>> be error free as they can be intercepted, amended, or contain viruses.
>> Anyone who communicates with us by e-mail is deemed to have accepted
>> these risks. Lineal is not responsible for errors or omissions in this
>> message and denies any responsibility for any damage arising from the
>> use of e-mail. Any opinion and other statement contained in this message
>> and any attachment are solely those of the author and do not necessarily
>> represent those of the company.
>> 
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 
>> 
> 
> -- 
> Jim Pistrang
> JP Computer Resources
> 413-256-4569
> <https://jpcr.com>
> 
> 
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 
> 




  <https://www.logicaldevelopments.com.au/>	Paul W Mulroney
Logical Developments
Customised Software Solutions
Ph: 08 9458 3889
 	We Don't Do Simple Pty Ltd
trading as
Logical Developments
ACN 161 009 374
 	  <https://www.facebook.com/logicaldevelopmentswa/>   <https://www.linkedin.com/company/logicaldevelopments/>   <https://www.youtube.com/channel/UCPldVVgWR05WX3cVrR5WUQw>   <https://twitter.com/WeDontDoSimple>



More information about the omnisdev-en mailing list