Getting Started With Project jMaki for the GlassFish v3 Application Server

ProcedureWriting a Handler that Handles the Widget Event

After this task is complete, the plotCity application will be able to populate the thisCity combobox widget with new data when the user selects a state from the thisState widget.

  1. Open the glue.js file, located in plotCity/Web Pages, in the editor pane.

  2. At the end of the glue.js file, add the following subscribe function:

    jmaki.subscribe("/cb/getState/*", function(args) {
    	var message = args.value;
    	jmaki.doAjax({method: "POST",
    	url: "Service?message=" + encodeURIComponent(message),
    	callback: function(_req) {
    		var tmp = _req.responseText;
    		var obj = eval("(" + tmp + ")");
    		jmaki.publish('/cb/setValues', obj);
    		// handle any errors
    		}
    	});
    });