JavaScript
From Kb
Contact Article Author | Blog of Article Author | FirstPartners.net Home | LinkedIn profile of Author
Contents |
See Also
- Main Blog - Technology and People
- Spring MVC
- Struts 2 Appfuse Dojo and Ajax
- Struts2Course Summary
- Struts 2 Web Framework
- Easy Ajax using Struts 2
- JavaScript
- Ajax - Javascript and Java - DWR , Dojo, Prototype and Scriptalicious
Behaviour JavaScript Libary
- Allows you to automatically attach events to HTML elements (elements are flagged using css attributes). Means that behavior is declarative, instead of having to add lots onClick or onBlur attached in page
- Behavior JavaScript library home page
- To use
- Include the behaviour.js on your web page
- Include the javascript that you wish to attach as a web page (contents of this file below)
- Mark the in the web page cssClass="applyBehaviour"
- Define and register the actions that we want to run
/*** * defines the rules describing when to trigger the validation */ var someAction= { /*** * run someAction on onblur method of all input elements, * where cssClass="applyBehaviour" (as part of input tag definition) * could have used 'input' to apply to *all* input tags */ 'input.applyBehaviour' : function(myElement) { //Standard Javascript way of apply myElement.onblur = function() { Window.alert(this.value); } } }; // Register the action via behaviour // Run Automatically when script is loaded Behaviour.register(someAction);
- Note: if you modify the Dom, call Behaviour.apply() to re-apply the rules to any new elements.
JavaScript Snippits
- Trigger Javascript event from clicking on URL
- return false from javascript event to kill following of link
- Similar (return false) to kill form submission
<a href="javascript:someFunctionToCall('someparam');">TextOfLink</a>
- Get the contents of an element (via the Dom)
var myValue= document.getElementById("name1.orjustname2").value;
JavaScript Strings
Dialog Boxes
- window.alert("message for alert box");
- wondow.confirm("Ok-Cancel Dialog box");

