Results 1 to 2 of 2

Thread: how to fire an event on self.close() in javaScript?

  1. #1
    Join Date
    Aug 2008
    Posts
    4

    Default how to fire an event on self.close() in javaScript?

    Hi,

    I have one requirement where in I have to fire an event on self.close() on a jsp page and capture that event in flow.xml.

    e.g. I am trying to do something like this.
    self.close("&_eventId=test"); This should fire a new event called test and then this event should be available in flow.xml.

    I tried to implement this but it didn't work. Does anyone have any idea how do I implement this?

    Thanks,

  2. #2
    Join Date
    Jul 2008
    Posts
    157

    Default

    The nice way, using spring.js (which must be added in your header)
    Code:
    my.spring.triggerEvent = function (formId, eventId) {
    	var params = {};
    	params["_eventId"] = eventId;
    	Spring.remoting.submitForm("_eventId", formId, params);
    };
    or
    Code:
    my.spring.triggerEvent = function (formId, eventId) {
    	var sourceId = "_eventId_" + eventId;
    	var params = {};
    	params[sourceId] = sourceId;
    	Spring.remoting.submitForm(sourceId, formId, params);
    };
    Or the other way is to trigger it yourself (without including Spring.js):
    Code:
    function triggerEvent(formId, event) {
    	var form = document.getElementById(formId);
    	if (form) {
    		var hidden = document.createElement('input');
    		hidden.type = 'hidden';
    		hidden.name = '_eventId';
    		hidden.value = event;
    		form.appendChild(hidden);
    		form.submit();
    	}
    }
    I have tried them when closing the page, but I guess it should work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •