Code Snippets

Code Snippet: How to submit and reset a Form using JavaScript

The standard approach to submit a form is through the use of the submit button. However we may find that we may want to utilize an image, text link or other elements to submit a form. In these cases we can utilize JavaScript to submit the form for us through the use of the JavaScript

Code Snippets: How to set id property using Struts HTML Tag library

For those new to Struts and in particular the Struts HTML library it might come as a surprise that there is no id property on their tags. Don’t get frustrated the tag library document clearly states that the styleId property renders its assigned value as the element id. This means that instead of id use

Code Snippets: Parsing a String into a Java Date Object

If a beginner coder you may get confused by the fact that Date.parse function has been deprecated. Not to worry though, it was deprecated for good reason as the DateFormat classes gives you a better way to convert strings into JAVA Date objects. The DateFormat class contains a parse method that will convert a String

Code Snippets: Generating a Random Number for Flash ActionScript 3 (AS3)

Generating a random number for use in Flash is a common problem that many developers come across. Luckily the Math object provides static methods to help us perform this basic task.  Found below are two snippets of how to generate a random integer from 0 to a max number or for a range of values.

Code Snippets: How to duplicate an Array in ActionScript 3 (AS3)

Array duplication or copying is actually a very simple task with multiple methods of the Array class returning a new Array. The only drawback is that their is no clone, copy, or duplicate method that would make it obvious to first time users. Instead the Array class has the concat and slice function that can

Code Snippets: Enabling Alpha for Dynamic Text Fields in Flash

For those creating dynamic text fields in Flash it often comes as a surprise that dynamic text fields do not behave as expected when modifying the alpha parameter of it or it’s parent. Often even I forget that telling a movie clip to transition out based on a tween of its alpha property doesn’t modify

Code Snippets: How to obtain the next identity value from a Sybase Table

There are a few methods available to the Sybase Transact-SQL developer who needs to obtain the next primary key for the next row to be inserted. If the primary column is an identity column then the next_identity function can be used. The proper syntax is: SELECT next_identity( “TABLE_NAME” ) If however you have not used

Code Snippets: Commenting your JSP code

All web developers know that they can add comments to their HTML by use of the <!– –> tag. This causes the contents to not be rendered to the viewer but still displayed in the source of the page. This method of commenting can still be done in JSP but in addition there is the<%–

Code Snippets: How to get the web application context path from within JSP

Often in JSP we find ourselves creating links to other pages within our web application.  The below code allows us to easily get the web application context path from within a JSP file. ${pageContext.request.contextPath} Utilizing JSTL we could also set this value to a variable so that we have a short hand method for getting