struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gme...@fibertel.com.ar
Subject RE: JSP / ActionForm / Action design quesetion
Date Tue, 27 Jul 2004 11:21:44 GMT
I implemented the ESC key feature in a banking application used by thouthands
of users.
I use XkinsForms (xkisn.sourceforge.net) that have a buttonTag that lets
you to generate the needed javascript to handle this feature:

<forms:execute key="button.cancel" executeParameter="stepBack" cancel="true"/>

This tag generates a javascript simmilar as the following:

<script>
function doSubmit() {
//submition code
}

function doCancel() {
//Cancel code
}
function processKeypressesDefault(e) { 
	var whichASCDef = (document.all?e.keyCode:e.which); 
	if (whichASCDef==13) {//enter
  		doSubmit(); 
		return false; 
	} 
	return true; 
}

function processKeypressesCancel(e) { 
	var whichASCCan = (document.all?e.keyCode:e.which); 
	if (whichASCCan==27) {//escape
		doCancel(); 
		return false; 
	} 
	return true; 
}


function processKeypresses(e) {
	if(processKeypressesDefault(e))
		processKeypressesCancel(e);
	}
}

if (document.captureEvents) { 
	document.captureEvents(Event.KEYPRESS); 
	document.onkeypress = processKeypresses; 
} 

if(document.all) 
	document.attachEvent('onkeypress', processKeypresses);

</script>

You could extend Struts buttonTag and add this feature to your pages.

Cheers.
Guillermo.

________________________________________
FiberTel, el nombre de la banda ancha http://www.fibertel.com.ar



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message