JDev

Code, javascriptFebruary 26, 2007 10:37 pm

You need to use a JavaScript Option object to dynamically add new options to a select box. 

For example, the following code will add a second option to a select box, or replace an existing one if it’s already there. 

document.forms[0].testselect.options[1]= new Option (’new text’, ‘new value’);

where new text is the text the user sees and new value is the VALUE of the new option.

From the excellent quirksmode site

 

phpFebruary 20, 2007 8:43 pm

This excellent script can be found at http://reallyshiny.com/scripts/table-extractor.txt

javaFebruary 15, 2007 5:22 pm

The following is a list of most frequent J2EE interview questions based on real interview experience :

Project development lifecycle
- Senior dev roles and responsibilities
- Using version control systems. Branching souce codes, ets

- OOP concepts
- Inheritance vs composition
- Design patterns. Almost everybody asked about two ways of implementing Singleton.

- Java interfaces vs abstract classes.
- Java collections framework. Differences between Hashtable and Hashmap, differences between ArrayList and LinkedList. Concurrent access and modification of the List.
- Java threads. Multi-treading. Differences between Runnable interface and Thread class.
- SAX vs DOM
- JDBC: Difference between Statement, PreparedStatement.
- Java Sockets
- RMI
- JMS
- EJB: Very high level questions: types of EJB, when to use
- Applicabilty of EJB
- Struts
- Applicability of Struts
- Spring framework and Hibernate.
- Ant

- What is a transaction?
- What is an outher join?
- What is normalization and why it may be helpful to denormalize?
- Using of Group clause in SQL SELECT statements

Visit http://www.ekcsoft.com/coding/java.php for more Java tips.

CodeFebruary 13, 2007 8:33 pm
You can change the default date format in Oracle SQL*Plus with the following command:
alter session set NLS_DATE_FORMAT=’<my_format>’; 
For example, 
alter session set NLS_DATE_FORMAT=’yyyy/mm/dd hh:mi:ssam’;

 

Oracle PL/SQL Programming, 4th Edition on Amazon.com

Code, javascriptFebruary 12, 2007 8:46 pm

The JavaScript escape() method takes any string or expression and returns a string in which all non-alphanumerical characters are converted to their numeric equivalent in the form %XX. The XX is a hexadecimal number representing the non-alphanumerical character.

For example, space is replaced with %20 and the & sign is replaced with %26.

However, according to this article,  the escape method will not encode: @*/+

To encode some of these characters, use the encodeURI() method.

However, to complicate matters further, the encodeURI() method will not encode the following characters: , / ? : @ & = + $ #.

Use the encodeURIComponent() method to encode these characters.

I created a test page that allows you test the behavior of these methods.

 

 

Code, phpFebruary 4, 2007 9:44 pm

First, the code: 

$dom = new DomDocument();

$dom->load($url);

$root = $dom->documentElement;

Now, you can do anything you want with the $root that represents the document - use getElementsByTagName or get children using $root->childNodes.

If you try using  DOMDocument->load() statically, you will get the following error:

Non-static method DOMDocument::load() should not be called statically.

To avoid the error, you need to create an instance of the DomDocument object using the example above. 

 

 

Code, javascriptFebruary 1, 2007 6:35 pm

Have a look at the function at http://www.ekcsoft.com/coding/js.php?page=js_format 

 
 
 
Code, javascript 4:10 pm

If you have existing functions on the onload event, you can add other functions without breaking the existing ones as follows:

var oldEvt = window.onload;
window.onload = function() { if (oldEvt) oldEvt(); doOtherStuffHere(); }

Lifted from one of the comments on http://simonwillison.net/2004/May/26/addLoadEvent/

The above method is useful if there are multiple external javascript files that may use the onload events. If you are sure there aren’t any external javascript files you could use a simpler version:

window.onload = function (firstFunction(); secondFunction();)