سؤال

I have a Button that in SSJS send and Email...

Now I would if is possibile show the status of sending of email in real-time to the user:

  1. sending process....
  2. sending Successful or sending error

How Can i call a JS client codice from SSJS routine? Have you any suggest?

هل كانت مفيدة؟

المحلول

8.5.3 introduced a very nice approach:

view.postScript

you may insert any CSJS code you like from the SSJS code.

نصائح أخرى

If you are using ExtLib then you can also use the @WarningMessage('messageText') method.

You will need to add a section to the XPage to display the messages. It can be as simple as

<xp:messages id="messages1"></xp:messages>

Once added each call to @WarningMessage will add a line to the messages pane.

This is quite straightforward. 1. Add a Hidden Input control on your page, noting the id. 2. In your SSJS use getComponent("inputHidden1").setValue("This is the message") 3. Ensure the Hidden Input control is in the area being refreshed (otherwise the value doesn't get passed back to the browser, so can't be accessed in CSJS) 4. Go to the Source pane and place the cursor on or in the eventHandler that is triggering your SSJS. You need to do this to get to the onComplete event 5. In All Properties panel go to onComplete, add your CSJS there. e.g. alert(dojo.byId("#{id:inputHidden1}").value)

This will run your SSJS and on completion alert the user with whatever code is in the field.

For a demo and demo code, check out my blog post: http://www.intec.co.uk/xpages-calling-client-side-javascript-from-server-side-javascript/

Another way to do it besides Pauls answer is to use a dialog from the extlib, and you can call it from ssjs, put a field in a dialog and set it to a scope value and show the dialog.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top