In my Domino web applications, I like to use pop-up boxes to edit different groups of fields on a document. For example, I might have a tabbed form with 5 related fields on each tab. To edit each tab's fields, I use pop-up forms. This lets me enforce some security, show/hide different contextual menu choices, present only the editable form to those users who can access it, etc.

In doing this, I don't much care for the $$Return field since different things can happen when the user submits the form. (Besides, complex formulas can get pretty messy and difficult to read once the development cycle is complete.) For instance, if I'm using Domino to capture data and then sending that data off to a relational database, the update can succeed or fail. If it fails, I need a smooth way to inform the user. If it succeeds, I need to refresh the 'read only' form / frames to reflect the results.

Enter this tiered approach to keeping everything in sync. It is simple to implement and lets you pass Javascript back to your pop-up form based on an agent's run-time environment.

It's based on a couple of different elements:
1. Put a hidden field on your pop-up form called 'ReloadString'
2. Before the pop-up form is saved, store javascript in ReloadString that you want to happen if the save is successful e.g. "window.opener.location='/db.nsf/view/docid?Opendocument'"
3. For the pop-up form's WebQuerySave event, enter an agent to run against the saved data.
4. In the agent, do whatever you need to do to the saved data i.e. save it via ODBC to a relational database, update some other documents based on the saved data, etc.>
5. At the end of your agent, if all is well, send the javascript in the ReloadString field back to the pop-up form via print statements e.g.

Print "<html><body><script>(contents of ReloadString);window.close;</script></body></html>"

If all is not well, send back the error or other information via a Print statement e.g.

Print "<html><Head>Error</Head><Body>Could not update the data on datasource MyDatasource. Record not saved.</Body></Html>"

This will let your pop-up window manipulate other browser windows and then close itself. This is really handy if you have a form with embedded Layers or IFRAMES that invoke pop-up forms. The user can change data from one frame and, if the update succeeds, see those changes reflected in the other frames/layers.

This was first published in February 2001

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.