Newest Webmonkey ArticlesNewest articles in the tutorial Webmonkey namespacehttp://www.webmonkey.com/rss/tutorialThu, 04 Dec 2008 21:08:13 -0500 (EST)http://www.webmonkey.com/tutorial/Enjoy_video_with_Eye-catching_Sony_XPERIA_X1Tutorial:Enjoy video with Eye-catching Sony XPERIA X1http://www.webmonkey.com/tutorial/Enjoy_video_with_Eye-catching_Sony_XPERIA_X1Thu, 04 Dec 2008 21:08:13 -0500 (EST)<![CDATA[<p><br /> </p> <a name="Steps"></a><h2> <span class="mw-headline"> Steps </span></h2> <p>The world of our consumers and customers is changing. To meet the growing need for mobile Web communication and multimedia entertainment, Sony Ericsson introduces Xperia X1. The Xperia X1 is the first product under Sony Ericsson’s new premium sub-brand Xperia With a striking arc-slider design, supported by a powerful multimedia ecosystem, the Xperia X1 is convergence of Multimedia entertainment and Mobile Web Communication. <a href="/special?title=Special:Upload&amp;wpDestFile=Http://www.nidesoft.com//image/guide/pro_xperia_product.jpg" class="new" title="Image:Http://www.nidesoft.com//image/guide/pro xperia product.jpg">Image:Http://www.nidesoft.com//image/guide/pro xperia product.jpg</a> </p><p>With the Windows Mobile 6.1 operating system, the XPERIA X1 supports Microsoft System Center Mobile Device Manager, which provides single-point access to line of business and corporate data such as applications, files and other information located on the corporate network. It also provides push email for immediate send and receive on Corporate Microsoft Exchange servers as well as editing of Microsoft Office documents. Additionally, it can handle personal email from POP3, IMAP4, and SMTP accounts. </p><p>The Sony Ericsson XPERIA X1 has a 3.0 inches TFT touchscreen with shades of 65K internal screen colours and gives a resolution of 800 x 480 pixels. This let the users to play games and watch video clips on its wide screen easily. The video resolution support 640x480 pixels and video format support MPEG-4. The music format support: MP3, AAC, AAC+, eACC+, WMA (including protected WMA). With its 400 MB of internal storage, users may store abundant videos and music in the phone. Multimedia entertainment with this phone become more convenient. </p> <a name="Alternate_methods"></a><h2> <span class="mw-headline"> Alternate methods </span></h2> <p>At the same time another equally important software launched. Nidesoft Sony XPeria Video Converter is excellent Movie Converter tool for the new released XPERIA X1. It is designed to convert video files to be played on the wonderful X1 mobile phone. The source files could be converted include almost all the video formats: MPEG, VOB, MP4, MOV, ASF, AVI, 3GP, WMV, RM, FLV, YouTube, WAV, AAC, etc.. You may free download it here to have a try: <a href="http://www.nidesoft.com/downloads/sony-xperia-video-converter.exe" class="external free" title="http://www.nidesoft.com/downloads/sony-xperia-video-converter.exe" rel="nofollow">http://www.nidesoft.com/downloads/sony-xperia-video-converter.exe</a> </p> <pre>And you may get more information about this powerful software on </pre> <p><a href="http://www.nidesoft.com/sony-xperia-video-converter.html" class="external free" title="http://www.nidesoft.com/sony-xperia-video-converter.html" rel="nofollow">http://www.nidesoft.com/sony-xperia-video-converter.html</a> <a href="/special?title=Special:Upload&amp;wpDestFile=Http://www.nidesoft.com/image/screen/sony-xperia-video-converter-screen-large.jpg" class="new" title="Image:Http://www.nidesoft.com/image/screen/sony-xperia-video-converter-screen-large.jpg">Image:Http://www.nidesoft.com/image/screen/sony-xperia-video-converter-screen-large.jpg</a> </p> <a name="Suggested_readings"></a><h2> <span class="mw-headline"> Suggested readings </span></h2> <p>This video converter is easy to use. Only three steps are needed when you convert videos into your Sony Ericsson XPERIA X1. Step 1: Install and run Nidesoft Sony Xperia Video Converter. Click “add” button to import your video from your computer. Nidesoft Sony Xperia Video Converter supports batch conversion, so you can import multiple files at one time. Step 2: click the “Format” drop-down list to select the format you prefer. Here you just need to select the format “Sony Xperis X1 Video MPEG-4 (*.mp4)”. Step 3: click the “convert” button and start the conversion. The conversion will be finished in a short time and then you may enjoy videos with your Sony Ericsson XPERIA X1. Notes: you can customize the output video according to your will by a few clicks on the right. You can set the video size, choose the crop mode to cut off the black edges, set the video and audio quality. </p><p>The launch of Sony Ericsson XPERIA X1 shocked the mobile phone world, especially for its Web communicate and multimedia entertainment function. On the other hand, in the software world the Nidesoft Sony XPeria Video Converter which enable you fully enjoy multimedia entertainment of Sony Ericsson XPERIA X1 attract most attention. Their publishment will bring more convenience for the people all over the world. </p>]]>http://www.webmonkey.com/tutorial/Free_Yourself_from_Conditions_in_JavaScriptTutorial:Free Yourself from Conditions in JavaScripthttp://www.webmonkey.com/tutorial/Free_Yourself_from_Conditions_in_JavaScriptThu, 04 Dec 2008 21:08:13 -0500 (EST)<![CDATA[<a name="Introduction"></a><h2> <span class="mw-headline"> Introduction </span></h2> <p>Now I love an <code>if()</code> or a <code>switch()</code> as much as the next monkey, but in these days where we push JavaScript (and browsers) to their limits in the name of Web 2.0 perhaps there's a better way to handle complex conditions. Maintaining big <code>if()</code> and <code>switch()</code> trees can be tricky and time consuming, and heaven help you if you need to hand it off to someone else not as familiar with your code. One also has to keep in mind that conditional evaluations take time, and processor horsepower, and that that time adds up if you have a lot of code executing client-side. </p><p>This tutorial will show you how to harness the power of function pointers and arrays in JavaScript to make conditional statements faster and easier to maintain. </p> <a name="What_you.27ll_need"></a><h2> <span class="mw-headline"> What you'll need </span></h2> <p>text editor and a browser </p> <a name="Steps"></a><h2> <span class="mw-headline"> Steps </span></h2> <p>Let's take the classic code test that everyone is given when interviewing: write some code that handles an incoming variable. If that variable's value is "red," alert "Ruby Slippers" and if the value is "blue," alert "Ice Cubes." </p><p>The typical solution would be: </p> <pre>function doColorDetect(s_val_fp) { switch(s_val_fp) { case 'red': alert('Ruby Slippers'); break; case 'blue': alert('Ice Cubes'); break; } }</pre> <p>But there's a whole other way to deal with this problem using arrays and function pointers. Function pointers, for the uninitiated, are a powerful and underused aspect of JavaScript. They work like this... </p> <pre>function doSomething() { //referenced function alert('foo'); } var f_pointer = doSomething; //assign the function to another variable f_pointer(); //alert &quot;foo&quot;</pre> <p>In the above example, we created a function called doSomething();. Then we created a variable called f_pointer and assigned it the value of doSomething. Notice that the line wasn't var f_pointer = doSomething();. By omitting the () after the function name, it is assigned as a reference and not executed. This finally allows us to invoke the variable f_pointer(); with the parentheses after it, causing it to execute the function it references. </p><p>And now a note about arrays in JavaScript. As we know, arrays can have numerical keys (e.g. a_foo[0], a_foo[1], etc.). JavaScript, like PHP, will also allow for named keys (e.g. a_foo['one'], a_foo['two'], etc.). </p><p>Now let's refactor our earlier solution to something a little more exotic. </p> <pre> function doColorDetect(s_val_fp) { a_function = new Array(); a_function['blue'] = doBlue; a_function['red'] = doRed; a_function[s_val_fp](); } function doBlue() { alert('Ice Cubes'); } function doRed() { alert('Ruby Slippers'); }</pre> <p>The above example will perform as the original did by assigning the individual handling functions to named keys in the array a_function. When the value is passed in the line a_function[s_val_fp](); it then executes the referenced function based on the value of the string acting as a named key in the array. </p><p>No, this is not a solution for all purposes and will not replace conditional statements where you need to evaluate a range of values as you wouldn't want to write an array with all possible permutations. It WILL get you over a boolean true/false hump if you can be clever with type casting. Just take your boolean, say b_val = true; and cast it to a number i_val = Number(b_val) and you can catch the 1/0 in array indices. </p>]]>http://www.webmonkey.com/tutorial/Make_OOP_Classes_in_JavaScriptTutorial:Make OOP Classes in JavaScripthttp://www.webmonkey.com/tutorial/Make_OOP_Classes_in_JavaScriptThu, 04 Dec 2008 21:08:13 -0500 (EST)<![CDATA[<table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1"><a href="#Introduction"><span class="tocnumber">1</span> <span class="toctext">Introduction</span></a></li> <li class="toclevel-1"><a href="#What_you.27ll_need"><span class="tocnumber">2</span> <span class="toctext">What you'll need</span></a></li> <li class="toclevel-1"><a href="#Steps"><span class="tocnumber">3</span> <span class="toctext">Steps</span></a></li> <li class="toclevel-1"><a href="#Alternate_methods"><span class="tocnumber">4</span> <span class="toctext">Alternate methods</span></a></li> </ul> </td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script> <a name="Introduction"></a><h2> <span class="mw-headline"> Introduction </span></h2> <p>Anyone who has tinkered with the prototype model in JavaScript to produce classes as we know them in other languages has generally left web programming all together and taken up a career as a bus driver. There are a coterie of frameworks designed specifically to address this problem. But what if you're not wild about frameworks, preferring instead to build tools specifically suited to your needs and style? For you, there is some black magic that can revolutionize the way you interact with the current JavaScript standard (someone please thaw me out when the 2.0 standard is implemented in June 2134, or whatever the projected date is). </p> <a name="What_you.27ll_need"></a><h2> <span class="mw-headline"> What you'll need </span></h2> <p>a text editor and a web browser </p> <a name="Steps"></a><h2> <span class="mw-headline"> Steps </span></h2> <p>Meet the encapsulated JavaScript function! More than a function, less than a traditional OOP class, but super useful and a cinch to make. All you really need is: </p> <pre>function someObj() { function someMethod() { alert('boo'); } } o_obj = new someObj();</pre> <p>As the name suggests, and encapsulated JavaScript function is just that - one function encapsulated within another. If you dropped this into a page and ran it in the browser, you'd have a big load of nothing. But whip out the "this." keyword, and things get interesting. In JavaScript "this." refers to the owner of an object, be it variable, function, or DOM element. For our purposes, "this." refers to an instance of an encapsulated function. </p><p>Let's change the previous code a bit. </p> <pre>function someObj() { this.someMethod = someMethod; function someMethod() { alert('boo'); } } o_obj = new someObj();</pre> <p>Now we've added the line this.someMethod = someMethod, which makes an individual and public reference to someMethod(). We might also make this neater by combining this.someMethod with the function declaration, as follows: </p> <pre>function someObj() { this.someMethod = function() { alert('boo'); } } o_obj = new someObj(); o_obj.someMethod(); //alerts &quot;boo&quot;</pre> <p>If I execute the above script in a browser, I'll get an alert message with "boo" in it. Of course, what's good for the function is good for the variable, as shown in the following example. </p> <pre>function someObj() { this.publicVar = 'public'; var privateVar = 'private'; this.someMethod = function() { alert('boo'); } } o_obj = new someObj(); alert(o_obj.publicVar); //alerts &quot;public&quot; o_obj.publicVar = 'new'; alert(o_obj.publicVar); //alerts &quot;new&quot; alert(o_obj.privateVar); //alerts nothing or an error, depending on the browser</pre> <p>Execute this in the browser, and you might get chills. Holy crap, we have public and private variables. You just have to remember that all references to a public variable within encapsulated functions must be preceeded by "this." or you'll end up accidentally creating a totally separate variable. And to bring it full circle, private methods are made possible like this... </p> <pre>function someObj() { this.publicVar = 'public'; var privateVar = 'private'; this.someMethod = function() { alert('boo'); someOtherMethod(); } // Private method. (Due to closure, this need not be declared before // someMethod although someMethod uses it.) var someOtherMethod = function() { alert('indirect reference'); } } o_obj = new someObj(); o_obj.someOtherMethod(); //will throw an undefined function error o_obj.someMethod(); //alerts &quot;boo&quot; followed by &quot;indirect reference&quot;</pre> <p>the above example shoud that function not given a "this." pointer is a defacto private method. </p><p>Here you will probably pause to realize that this particular black magic seems too good to be true. "Show me ye olde classical inheritance!" you cry. Here's where the limits to this sorcery are exposed. Classical inheritance doesn't come naturally to JavaScript. With a little coaxing you can get something equally useful, especially if you wish to build interrelated but independent libraries of encapsulated code following all of the other OOP rules we know and love. Consider the following: </p> <pre>function someObj() { this.o_otherobj; this.doOtherObj = function() { this.o_otherobj = new otherObj(); } } function otherObj() { this.otherMethod = function() { alert('over the rainbow'); } } o_obj = new someObj(); o_obj.doOtherObj(); o_obj.o_otherobj.otherMethod(); //alerts &quot;over the rainbow&quot;</pre> <p>This time, we have two independent and encapsulated functions, one essentially encapsulating another and providing a public interface. Those wondering if they can have a constructor function should note that in the above example that, </p> <pre>function someObj() { this.o_otherobj; this.doOtherObj = function() { this.o_otherobj = new otherObj(); } }</pre> <p>could just as easily have been, </p> <pre>function someObj() { this.o_otherobj = new otherObj(); }</pre> <p>and gotten the same result. Any code not encapsulated within that second-tier of functions is executed when the object is instantiated, mimicking constructor behavior. </p><p>Remember that standard variable scoping rules apply within encapsulated functions. Any variable declared in a second-tier function will become global to the whole class, so you have to be as careful with your namespace as you would be otherwise. </p><p>As a caveat, this method comes with more overhead than the typical usage of Javascript prototype to declare classes as each methods are duplicated across objects. </p> <a name="Alternate_methods"></a><h2> <span class="mw-headline"> Alternate methods </span></h2> <p>For a more direct approach, you can copy the following into an .html file and play with it live in your browser. </p> <pre> &lt;html&gt; &lt;head&gt; &lt;script type=&quot;text/javascript&quot;&gt; function jsObj() { this.m_public; //public variable this.o_griffins; //public variable this.doGriffins = doGriffins; // public method this.doSayItOutLoud = doSayItOutLoud; // public method this.getPrivateVariable = getPrivateVariable; // public method var m_private; // private variable alert('It\'s alive!'); //&quot;constructor&quot; function doSayItOutLoud(m_var_fp) { // this method is public because it has a &quot;this.&quot; pointer this.m_public = m_var_fp; if (confirm(m_var_fp + ' is public knowledge. Do you wish to save it?')) { setPrivateVariable(m_var_fp); } } function doGriffins() { this.o_griffins = new familyObj(); } function getPrivateVariable() { //this method is public because it has a &quot;this.&quot; pointer alert('The private variable is ' + m_private); } function setPrivateVariable(m_var_fp) { //this method is private because it has no &quot;this.&quot; pointer m_private = m_var_fp; } } function familyObj() { this.doMeg = doMeg; this.doPeter = doPeter; this.doStewie = doStewie; function doMeg(m_var_fp) { alert(m_var_fp + '. Is that what you want me to say?'); } function doPeter() { alert('Bird, bird, bird, bird is the word!'); } function doStewie() { alert('Thoughtless heathen programmer only gave me an alert().'); } } var o_jsobj = new jsObj(); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; For a good time, paste these snippets into your address bar! &lt;ul&gt; &lt;li&gt;javascript:o_jsobj.doSayItOutLoud('Yo!');&lt;/li&gt; &lt;li&gt;javascript:alert(o_jsobj.m_public);&lt;/li&gt; &lt;li&gt;javascript:alert(o_jsobj.m_public);&lt;/li&gt; &lt;li&gt;(if you saved a variable) javascript:o_jsobj.getPrivateVariable();&lt;/li&gt; &lt;li&gt;javascript:o_jsobj.getPrivateVariable();&lt;/li&gt; &lt;li&gt;javascript:o_jsobj.doGriffins();&lt;/li&gt; &lt;li&gt;javascript:o_jsobj.o_griffins.doMeg('Booger');&lt;/li&gt; &lt;li&gt;javascript:o_jsobj.o_griffins.doPeter();&lt;/li&gt; &lt;li&gt;javascript:o_jsobj.o_griffins.doStewie();&lt;/li&gt; &lt;/ul&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</pre> ]]>http://www.webmonkey.com/tutorial/High-_light_a_rowTutorial:High- light a rowhttp://www.webmonkey.com/tutorial/High-_light_a_rowThu, 04 Dec 2008 21:08:13 -0500 (EST)<![CDATA[<div style="width:400px;background-color:#FF9900;border-style:solid double;border-width:4px;border-color:#FF0000;padding:5px"> <p><b>EDITORS NOTE</b>: This page contains questionable material. The user-generated content included in this page may need your help. It may contain errors, inappropriate links and methods have not not been verified to work. </p><p>Comments on the future of this page belong under the <b>Discussion</b> tab. Press <b>Edit</b> to modify this page to add and remove content or correct for grammar and/or code errors. </p> </div> <a name="Introduction"></a><h2> <span class="mw-headline"> Introduction </span></h2> <p>you want to high - light a row in you table on a web site with use mouse over and mouse out </p> <a name="Steps"></a><h2> <span class="mw-headline"> Steps </span></h2> <p>open your CSS file or in the style section of your web page </p><p>TR.High-light { background-color: #FFFFD0; } </p><p><br /> now the add the class to the TR </p><p>&lt;TR onMouseOver="this.className='High-light'" onMouseOut="this.className='clear'"&gt; </p>]]>http://www.webmonkey.com/tutorial/The_Java_Database_Connectivity_and_Jdeveloper_Used_for_J2EE_DevelopmentTutorial:The Java Database Connectivity and Jdeveloper Used for J2EE Developmenthttp://www.webmonkey.com/tutorial/The_Java_Database_Connectivity_and_Jdeveloper_Used_for_J2EE_DevelopmentThu, 04 Dec 2008 21:08:13 -0500 (EST)<![CDATA[<div style="width:400px;background-color:#FF9900;border-style:solid double;border-width:4px;border-color:#FF0000;padding:5px"> <p><b>EDITORS NOTE</b>: This page contains questionable material. The user-generated content included in this page may need your help. It may contain errors, inappropriate links and methods have not not been verified to work. </p><p>Comments on the future of this page belong under the <b>Discussion</b> tab. Press <b>Edit</b> to modify this page to add and remove content or correct for grammar and/or code errors. </p> </div> <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1"><a href="#Introduction"><span class="tocnumber">1</span> <span class="toctext">Introduction</span></a></li> <li class="toclevel-1"><a href="#What_you.27ll_need"><span class="tocnumber">2</span> <span class="toctext">What you'll need</span></a></li> <li class="toclevel-1"><a href="#Steps"><span class="tocnumber">3</span> <span class="toctext">Steps</span></a></li> <li class="toclevel-1"><a href="#Alternate_methods"><span class="tocnumber">4</span> <span class="toctext">Alternate methods</span></a></li> <li class="toclevel-1"><a href="#Suggested_readings"><span class="tocnumber">5</span> <span class="toctext">Suggested readings</span></a></li> </ul> </td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script> <a name="Introduction"></a><h2> <span class="mw-headline"> Introduction </span></h2> <p>Unlike Eclipse IDE, which requires a plug-in, JDeveloper has a built-in provision to establish a JDBC connection with a database. JDeveloper is the only Java IDE with an embedded application server, the Oracle Containers for J2EE (OC4J). This database-based web application may run in JDeveloper without requiring a third-party application server. However, JDeveloper also supports third-party application servers. Starting with JDeveloper 11, application developers may point the IDE to an application server instance (or OC4J instance), including third-party application servers that they want to use for testing during development. JDeveloper provides connection pooling for the efficient use of database connections. A database connection may be used in an ADF BC application, or in a JavaEE application. A database connection in JDeveloper may be configured in the Connections Navigator. A Connections Navigator connection is available as a DataSource registered with a JNDI naming service. The database connection in JDeveloper is a reusable named connection that developers configure once and then use in as many of their projects as they want. Depending on the nature of the project and the database connection, the connection is configured in the bc4j.xcfg file or a JavaEE data source. Here, it is necessary to distinguish between data source and DataSource. A data source is a source of data; for example an RDBMS database is a data source. A DataSource is an interface that represents a factory for JDBC Connection objects. JDeveloper uses the term Data Source or data source to refer to a factory for connections. We will also use the term Data Source or data source to refer to a factory for connections, which in the javax.sql package is represented by the DataSource interface. A DataSource object may be created from a data source registered with the JNDI (Java Naming and Directory) naming service using JNDI lookup. A JDBC Connection object may be obtained from a DataSource object using the getConnection method. As an alternative to configuring a connection in the Connections Navigator a data source may also be specified directly in the data source configuration file data-sources.xml. In this article we will discuss the procedure to configure a JDBC connection and a JDBC data source in JDeveloper 10g IDE. We will use the MySQL 5.0 database server and MySQL Connector/J 5.1 JDBC driver, which support the JDBC 4.0 specification. In this article you will learn the following: • Creating a database connection in JDeveloper Connections Navigator. • Configuring the Data Source and Connection Pool associated with the connection configured in the Connections Navigator. • The common JDBC Connection Errors. Before we create a JDBC connection and a data source we will discuss connection pooling and DataSource. </p> <a name="What_you.27ll_need"></a><h2> <span class="mw-headline"> What you'll need </span></h2> <p>Connection Pooling and DataSource The javax.sql package provides the API for server-side database access. The main interfaces in the javax.sql package are DataSource, ConnectionPoolDataSource, and PooledConnection. The DataSource interface represents a factory for connections to a database. DataSource is a preferred method of obtaining a JDBC connection. An object that implements the DataSource interface is typically registered with a Java Naming and Directory API-based naming service. DataSource interface implementation is driver-vendor specific. The DataSource interface has three types of implementations: • Basic implementation: In basic implementation there is 1:1 correspondence between a client's Connection object and the connection with the database. This implies that for every Connection object, there is a connection with the database. With the basic implementation, the overhead of opening, initiating, and closing a connection is incurred for each client session. • Connection pooling implementation: A pool of Connection objects is available, from which connections are assigned to the different client sessions. A connection pooling manager implements the connection pooling. When a client session does not require a connection, the connection is returned to the connection pool and becomes available to other clients. Thus, the overheads of opening, initiating, and closing connections are reduced. • Distributed transaction implementation: Distributed transaction implementation produces a Connection object that is mostly used for distributed transactions and is always connection pooled. A transaction manager implements the distributed transactions. An advantage of using a data source is that code accessing a data source does not have to be modified when an application is migrated to a different application server. Only the data source properties need to be modified. A JDBC driver that is accessed with a DataSource does not register itself with a DriverManager. A DataSource object is created using a JNDI lookup and subsequently a Connection object is created from the DataSource object. For example, if a data source JNDI name is jdbc/OracleDS a DataSource object may be created using JNDI lookup. First, create an InitialContext object and subsequently create a DataSource object using the InitialContext lookup method. From the DataSource object create a Connection object using the getConnection() method: </p> <pre> InitialContext ctx=new InitialContext(); DataSource ds=ctx.lookup("jdbc/OracleDS"); Connection conn=ds.getConnection(); </pre> <p>The JNDI naming service, which we used to create a DataSource object is provided by J2EE application servers such as the Oracle Application Server Containers for J2EE (OC4J) embedded in the JDeveloper IDE. A connection in a pool of connections is represented by the PooledConnection interface, not the Connection interface. The connection pool manager, typically the application server, maintains a pool of PooledConnection objects. When an application requests a connection using the DataSource.getConnection() method, as we did using the jdbc/OracleDS data source example, the connection pool manager returns a Connection object, which is actually a handle to an object that implements the PooledConnection interface. A ConnectionPoolDataSource object, which is typically registered with a JNDI naming service, represents a collection of PooledConnection objects. The JDBC driver provides an implementation of the ConnectionPoolDataSource, which is used by the application server to build and manage a connection pool. When an application requests a connection, if a suitable PooledConnection object is available in the connection pool, the connection pool manager returns a handle to the PooledConnection object as a Connection object. If a suitable PooledConnection object is not available, the connection pool manager invokes the getPooledConnection() method of the ConnectionPoolDataSource to create a new PooledConnection object. For example, if connectionPoolDataSource is a ConnectionPoolDataSource object a new PooledConnection gets created as follows: </p> <pre> PooledConnection pooledConnection=connectionPoolDataSource.getPooledConnection(); </pre> <p>The application does not have to invoke the getPooledConnection() method though; the connection pool manager invokes the getPooledConnection() method and the JDBC driver implementing the ConnectionPoolDataSource creates a new PooledConnection, and returns a handle to it. The connection pool manager returns a Connection object, which is a handle to a PooledConnection object, to the application requesting a connection. When an application closes a Connection object using the close() method, as follows, the connection does not actually get closed. </p> <pre> conn.close(); </pre> <p>The connection handle gets deactivated when an application closes a Connection object with the close() method. The connection pool manager does the deactivation. When an application closes a Connection object with the close () method any client info properties that were set using the setClientInfo method are cleared. The connection pool manager is registered with a PooledConnection object using the addConnectionEventListener() method. When a connection is closed, the connection pool manager is notified and the connection pool manager deactivates the handle to the PooledConnection object, and returns the PooledConnection object to the connection pool to be used by another application. The connection pool manager is also notified if a connection has an error. A PooledConnection object is not closed until the connection pool is being reinitialized, the server is shutdown, or a connection becomes unusable. In addition to connections being pooled, PreparedStatement objects are also pooled by default if the database supports statement pooling. It can be discovered if a database supports statement pooling using the supportsStatementPooling() method of the DatabaseMetaData interface. The PeparedStatement pooling is also managed by the connection pool manager. To be notified of PreparedStatement events such as a PreparedStatement getting closed or a PreparedStatement becoming unusable, a connection pool manager is registered with a PooledConnection manager using the addStatementEventListener() method. A connection pool manager deregisters a PooledConnection object using the removeStatementEventListener() method. Methods addStatementEventListener and removeStatementEventListener are new methods in the PooledConnection interface in JDBC 4.0. Pooling of Statement objects is another new feature in JDBC 4.0. The Statement interface has two new methods in JDBC 4.0 for Statement pooling: isPoolable() and setPoolable(). The isPoolable method checks if a Statement object is poolable and the setPoolable method sets the Statement object to poolable. When an application closes a PreparedStatement object using the close() method the PreparedStatement object is not actually closed. The PreparedStatement object is returned to the pool of PreparedStatements. When the connection pool manager closes a PooledConnection object by invoking the close() method of PooledConnection all the associated statements also get closed. Pooling of PreparedStatements provides significant optimization, but if a large number of statements are left open, it may not be an optimal use of resources. Thus, the following procedure is followed to obtain a connection in an application server using a data source: 1. Create a data source with a JNDI name binding to the JNDI naming service. 2. Create an InitialContext object and look up the JNDI name of the data source using the lookup method to create a DataSource object. If the JDBC driver implements the DataSource as a connection pool, a connection pool becomes available. 3. Request a connection from the connection pool. The connection pool manager checks if a suitable PooledConnection object is available. If a suitable PooledConnection object is available, the connection pool manager returns a handle to the PooledConnection object as a Connection object to the application requesting a connection. 4. If a PooledConnection object is not available the connection pool manager invokes the getPooledConnection() method of the ConnectionPoolDataSource, which is implemented by the JDBC driver. 5. The JDBC driver implementing the ConnectionPoolDataSource creates a PooledConnection object and returns a handle to it. 6. The connection pool manager returns a handle to the PooledConnection object as a Connection object to the application requesting a connection. 7. When an application closes a connection, the connection pool manager deactivates the handle to the PooledConnection object and returns the PooledConnection object to the connection pool. ConnectionPoolDataSource provides some configuration properties to configure a connection pool. The configuration pool properties are not set by the JDBC client, but are implemented or augmented by the connection pool. The properties can be set in a data source configuration. Therefore, it is not for the application itself to change the settings, but for the administrator of the pool, who also happens to be the developer sometimes, to do so. </p> <a name="Steps"></a><h2> <span class="mw-headline"> Steps </span></h2> <p>Setting the Environment Before getting started, we have to install the JDeveloper 10.1.3 IDE and the MySQL 5.0 database. Download JDeveloper from: <a href="http://www.oracle.com/technology/software/products/jdev/index.html" class="external free" title="http://www.oracle.com/technology/software/products/jdev/index.html" rel="nofollow">http://www.oracle.com/technology/software/products/jdev/index.html</a>. Download the MySQL Connector/J 5.1, the MySQL JDBC driver that supports JDBC 4.0 specification. To install JDeveloper extract the JDeveloper ZIP file to a directory. Log in to the MySQL database and set the database to test. Create a database table, Catalog, which we will use in a web application. The SQL script to create the database table is listed below: CREATE TABLE Catalog(CatalogId VARCHAR(25) PRIMARY KEY, Journal VARCHAR(25), Publisher VARCHAR(25), Edition VARCHAR(25), Title Varchar(45), Author Varchar(25)); INSERT INTO Catalog VALUES('catalog1', 'Oracle Magazine', </p> <pre> 'Oracle Publishing', 'Nov-Dec 2004', 'Database Resource Manager', 'Kimberly Floss'); </pre> <p>INSERT INTO Catalog VALUES('catalog2', 'Oracle Magazine', 'Oracle Publishing', </p> <pre> 'Nov-Dec 2004', 'From ADF UIX to JSF', 'Jonas Jacobi'); </pre> <p>MySQL does not support ROWID, for which support has been added in JDBC 4.0. Having installed the JDeveloper IDE, next we will configure a JDBC connection in the Connections Navigator. Select the Connections tab and right-click on the Database node to select New Database Connection. </p><p>Click on Next in Create Database Connection Wizard. In the Create Database Connection Type window, specify a Connection Name—MySQLConnection for example—and set Connection Type to Third Party JDBC Driver, because we will be using MySQL database, which is a third-party database for Oracle JDeveloper and click on Next. If a connection is to be configured with Oracle database select Oracle (JDBC) as the Connection Type and click on Next. </p><p>In the Authentication window specify Username as root (Password is not required to be specified for a root user by default), and click on Next. In the Connection window, we will specify the connection parameters, such as the driver name and connection URL; click on New to specify a Driver Class. In the Register JDBC Driver window, specify Driver Class as com.mysql.jdbc.Driver and click on Browse to select a Library for the Driver Class. In the Select Library window, click on New to create a new library for the MySQL Connector/J 5.1 JAR file. In the Create Library window, specify Library Name as MySQL and click on Add Entry to add a JAR file entry for the MySQL library. In the Select Path Entry window select mysql-connector-java-5.1.3-rcmysql-connector-java-5.1.3-rc-bin.jar and click on Select. In the Create Library window, after a Class Path entry gets added to the MySQL library, click on OK. In the Select Library window, select the MySQL library and click on OK. In the Register JDBC Driver window, the MySQL library gets specified in the Library field and the mysql-connector-java-5.1.3-rcmysql-connector-java-5.1.3-rc-bin.jar gets specified in the Classpath field. Now, click on OK. The Driver Class, Library, and Classpath fields get specified in the Connection window. Specify URL as jdbc:mysql://localhost:3306/test, and click on Next. </p><p>In the Test window click on Test Connection to test the connection that we have configured. A connection is established and a success message gets output in the Status text area. Click on Finish in the Test window. A connection configuration, MySQLConnection, gets added to the Connections navigator. </p><p>The connection parameters are displayed in the structure view. To modify any of the connection settings, double-click on the Connection node. The Edit Database Connection window gets displayed. The connection Username, Password, Driver Class, and URL may be modified in the Edit window. A database connection configured in the Connections navigator has a JNDI name binding in the JNDI naming service provided by OC4J. Using the JNDI name binding, a DataSource object may be created in a J2EE application. To view, or modify the configuration settings of the JDBC connection select Tools | Embedded OC4J Server Preferences in JDeveloper. In the window displayed, select Global | Data Sources node, and to update the data-sources.xml file with the connection defined in the Connections navigator, click on the Refresh Now button. Checkboxes may be selected to Create data-source elements where not defined, and to Update existing data-source elements. </p><p>The connection pool and data source associated with the connection configured in the Connections navigator get listed. Select the jdev-connection-pool-MySQLConnection node to list the connection pool properties as Property Set A and Property Set B. </p><p>The tuning properties of the JDBC connection pool may be set in the Connection Pool window. The different tuning attributes are listed in following table: </p><p>Tuning Attribute Attribute Description Default Value Abandoned Connection Timeout Interval (seconds) after which a connection acquired by a user that has been inactive is returned to the cache. -1 implies that the feature is not in effect. Retry Interval Interval (seconds) after which a failed connection attempt is retried. Used with Max Connect Attempts. 1 Disable Connection Pooling Specifies if application server's connection pooling is to be disabled. This attribute is available because some drivers provide connection pooling inside the driver. False Inactivity Timeout The number of seconds of inactivity after which an unused connection is removed from the pool. Inactivity Timeout Initial Limit The initial number of connections in the connection pool. If value is greater than 0, the specified number of connections are pre-created and available in the connection cache, thus reducing the time required to build the cache to its optimal size. 0 Login Timeout The number of seconds after which a login attempt is timed out. 0 implies that the system timeout value is used. If a system timeout is not defined, a login attempt is not timed out. 0 Max Connect Attempts The maximum number of connection attempts to a database. Used in conjunction with retry interval. 3 Max Connections The maximum number of available database connections in the connection pool. A value of 0 or less implies that there is no maximum limit. 0 Min Connections The minimum number of database connections in the connection pool. 0 Select Property Set B to specify additional connection pool properties. </p> <a name="Alternate_methods"></a><h2> <span class="mw-headline"> Alternate methods </span></h2> <p>This is just an extract from the JDBC 4.0 and Oracle JDeveloper for J2EE Development book. </p> <pre>Data retrieval and storage is one of the most common components of J2EE applications. JDBC (Java Database Connectivity) is the Java API for accessing a SQL relational database and adding, retrieving, and updating data in the database. </pre> <p>Oracle JDeveloper is a developer-friendly integrated development environment (IDE) for building service-oriented applications using the latest industry standards for Java, XML, web services, and SQL. It supports the complete development lifecycle with integrated features for modeling, coding, debugging, testing, profiling, tuning, and deploying applications. </p><p>This book is about developing Java/J2EE applications with a database component in Oracle JDeveloper (version 10.1.3). It covers the practical aspects of JDBC (version 4.0); it will teach application developers about setting the environment for developing various JDBC-based J2EE applications and the procedure to develop JDBC-based J2EE applications. It will also explore the new features added in JDBC 4.0. <br /> </p><p>Read the full Table of Contents for JDBC 4.0 and Oracle JDeveloper for J2EE Development here: <a href="http://www.packtpub.com/j2ee-development-with-oracle-jdeveloper-jdbc-4.0/book" class="external free" title="http://www.packtpub.com/j2ee-development-with-oracle-jdeveloper-jdbc-4.0/book" rel="nofollow">http://www.packtpub.com/j2ee-development-with-oracle-jdeveloper-jdbc-4.0/book</a> </p> <a name="Suggested_readings"></a><h2> <span class="mw-headline"> Suggested readings </span></h2> <p>The book is suitable for Java/J2EE and Oracle JDeveloper beginners. If you are a J2EE developer and want to use the JDeveloper IDE for J2EE development, this book is for you. JDeveloper developers who are new to J2EE will also benefit from the book. Most J2EE applications have a database component and the book is specially suited for database-based J2EE development in Oracle JDeveloper. You can also use this book if you are interested in learning how to utilize the new features offered in JDBC 4.0 for Java/J2EE development. </p><p>For more Information visit: <a href="http://www.packtpub.com/j2ee-development-with-oracle-jdeveloper-jdbc-4.0/book" class="external free" title="http://www.packtpub.com/j2ee-development-with-oracle-jdeveloper-jdbc-4.0/book" rel="nofollow">http://www.packtpub.com/j2ee-development-with-oracle-jdeveloper-jdbc-4.0/book</a> </p>]]>http://www.webmonkey.com/tutorial/Social_Networking_on_Elgg_PlatformTutorial:Social Networking on Elgg Platformhttp://www.webmonkey.com/tutorial/Social_Networking_on_Elgg_PlatformThu, 04 Dec 2008 21:08:13 -0500 (EST)<![CDATA[<div style="width:400px;background-color:#FF9900;border-style:solid double;border-width:4px;border-color:#FF0000;padding:5px"> <p><b>EDITORS NOTE</b>: This page contains questionable material. The user-generated content included in this page may need your help. It may contain errors, inappropriate links and methods have not not been verified to work. </p><p>Comments on the future of this page belong under the <b>Discussion</b> tab. Press <b>Edit</b> to modify this page to add and remove content or correct for grammar and/or code errors. </p> </div> <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1"><a href="#Introduction"><span class="tocnumber">1</span> <span class="toctext">Introduction</span></a></li> <li class="toclevel-1"><a href="#What_you.27ll_need"><span class="tocnumber">2</span> <span class="toctext">What you'll need</span></a></li> <li class="toclevel-1"><a href="#Steps"><span class="tocnumber">3</span> <span class="toctext">Steps</span></a></li> <li class="toclevel-1"><a href="#Alternate_methods"><span class="tocnumber">4</span> <span class="toctext">Alternate methods</span></a></li> <li class="toclevel-1"><a href="#Suggested_readings"><span class="tocnumber">5</span> <span class="toctext">Suggested readings</span></a></li> </ul> </td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script> <a name="Introduction"></a><h2> <span class="mw-headline"> Introduction </span></h2> <p>Covers the basics of social networking, runs over some popular social networks and goes through some of the features that are essential to online social networking. It introduces Elgg, and highlights some of the benefits of deploying one's own social network.Ever been to a night club on a Monday morning? There's you, there are the chairs,and the potential to host a party on the weekend. If you've been through Appendix A, your Elgg installation looks pretty much like an empty night club. There are lots of buttons, lots of potential, but no member except you. </p><p>But unlike a night club, you don't have to wait for the weekend to host your friends on Elgg. Invite them as soon as you're done setting up the software. Elgg is designed to make it easier for you to invite people. If you've ever setup a blog or rolled your own website, how long did it take before you could invite your friends over? You had to put up all sorts of content to indulge them, and also fiddle around decorating the portal so that it doesn't look dull. </p><p>That's where a social network is different from a regular website. The websites follow a two-way, one-to-many style of interaction, where the owner of the website, or blog, talks to all his visitors who respond with their comments, either on the website, or via e-mail. On the other hand, social networking software follows a many-to-many style of interaction. Members interact with each other, and create their own content, which is then shared with all. This is then discussed and commented on by everyone. </p><p>The owner of the site is like the perfect host. They mingle, discuss with everyone, but don't stamp their authority, unless you're naughty. They're like every other member, except for the fact that they own the place. Sounds familiar? </p><p>So, you don't have to worry about content before inviting your friends. Your friends bring their own content. </p> <a name="What_you.27ll_need"></a><h2> <span class="mw-headline"> What you'll need </span></h2> <p>Connecting to Friends and Users I hope you're convinced how important friends are to a social network. Initially, you'll have to manually invite your friends over to join. I say initially, because membership on a social network is viral. Once your friends are registered members of your network, they can also bring in their own friends. This means that soon your friends would have invited their own friends as well. Chances are that you might not know these friends of your friends. So, Elgg not only allows you to invite friends from outside, but also connect with users already on the network. Let's understand these situations in real-life terms. You invite your friends over to a party with you at your new Star Trek theme club. That's what you'll do with Elgg, initially. So your friends like the place and next time around they bring in more friends from work. These friends of friends from work, talk about your place with their friends and so on, until you're hosting a bunch of people in the club that you haven't ever met in your life. You overhear some people discussing Geordi La Forge, your favorite character from the show. You invite them over for drinks. That's connecting with users already on the network. </p><p>So let's head on over to Elgg and invite some friends! Inviting Friends to Join There are two ways of inviting users to join your network. Either send them an email with a link to join the website, or let Elgg handle sending them emails. </p><p>If you send them emails, you can include a direct link to the registration page. This link is also on the front page of your network, which every visitor will see. It asks visitors to register an account if they like what's on the network. The procedure for registering using this mechanism has already been covered in Chapter 2. </p><p>Let Elgg Handle Registration This is the most popular method of inviting users to join the network. It's accessible not only to you, but also to your friends once they've registered with the network. To allow Elgg to send emails on your behalf, you'll have to be logged into Elgg. This is covered as part of installation in Appendix A. Once you login, click on the Your Network button on the top navigation bar. This will take you to a page, which links to tools that'll help you connect with others. The last link in this bar (Invite a Friend) does exactly what it says.When you click on this link, it'll explain to you some benefits of inviting friends over.The page has three fields: Their name: Enter the name of the friend you're sending the invitation to. </p><p>Their email address: Very important. This is the address to where the invitation is sent. An optional message: Elgg sends an email composed using a template. If you want to add a personal message to Elgg's email, you can do so here. In the email, which Elgg sends on behalf of the network's administrator, that means you, it displays the optional message (if you've sent one), along with a link to the registration page. The invitation is valid for seven days, after which the registration link in the email isn't valid. </p> <a name="Steps"></a><h2> <span class="mw-headline"> Steps </span></h2> <p>Each tab has a Save your profile button at the end. When you press this button, Elgg updates your profile instantaneously. You can fill in as much detail as you want, and keep coming back to edit your profile and append new information. Let's look at the various tabs: Basic details: Although filling information in any tab is optional, I'd advise you to fill in all details in this tab. This will make it easy, for you to find others, and for others to find you. The tab basically asks you to introduce yourself, list your interests, your likes, your dislikes, your goals in life, and your main skills. Location: This tab requests information that'll help members reach you physically. Fill in your street address, town, state, postal code, and country. Contact: Do you want members to contact you outside your Elgg network? This tab requests both physical as well as electronic means which members can use to get in touch with you. Physical details include your work, home, and mobile telephone number. Electronic details include your email address, your personal and official websites. Elgg can also list information to help users connect to you on instant messenger. It supports ICQ, MSN, AIM, Skype, and Jabber. </p><p>Employment: List your occupation, the industry and company you work in, your job title and description. Elgg also lets you list your career goals and suggests you do so to "let colleagues and potential employers know what you'd like to get out of your career.". Education: Here you can specify your level of education, and which high school, university or college you attended, and the degree you hold. A s you can clearly see, Elgg's profiling options are very diverse and detailed. Rather than serve the sole purpose of describing you to the visitors, the profile also helps you find new friends as well, as we'll see later in this chapter. </p> <a name="Alternate_methods"></a><h2> <span class="mw-headline"> Alternate methods </span></h2> <p>No Alternate methods Yet... What is FOAF? While filling the profile, you must have noticed an Upload a FOAF file area down at the bottom of all tabs. FOAF or Friend of a Friend is a project (<a href="http://www.foaf-project.org/" class="external free" title="http://www.foaf-project.org/" rel="nofollow">http://www.foaf-project.org/</a>) to help create "machine-readable pages that describe people, the links between them and the things they create and do". The FOAF file includes lots of details about you, and if you have already created a FOAF profile, Elgg can use that to pick out information describing you from in there. You can modify the information once it's imported into Elgg, if you feel the need to do so. The FOAF-a-Matic tool (<a href="http://www.ldodds.com/foaf/foaf-a-matic.en.html" class="external free" title="http://www.ldodds.com/foaf/foaf-a-matic.en.html" rel="nofollow">http://www.ldodds.com/foaf/foaf-a-matic.en.html</a>) is a simple Web-based program you can use to create a FOAF profile. </p> <a name="Suggested_readings"></a><h2> <span class="mw-headline"> Suggested readings </span></h2> <p>As the profi le lists several vital and sensitive pieces of information, privacy concerns have been addressed in this chapter. We've seen the various built-in options that Elgg provides, as well as the mechanism to create our own custom groups. Then, we've covered how one can connect with other users on the network. Again, privacy concerns have been addressed, followed by a discussion about moderating friendship requests. We also ran through Elgg's built-in mechanisms for attracting visitors to join the network, and various account settings that a user can alter. After reading this chapter, you should have no trouble adding, managing or connecting to members in your Elgg network.Where to buy this book You can buy Elgg Social Networking from the Packt Publishing website: <a href="http://www.packtpub.com/elgg-social-networking/book" class="external free" title="http://www.packtpub.com/elgg-social-networking/book" rel="nofollow">http://www.packtpub.com/elgg-social-networking/book</a>. you could download the full chapter here: <a href="http://www.packtpub.com/files/Elgg-Social-Networking-Sample-Chapter-Chapter-3-Users-Profiles-and-Connections.pdf" class="external free" title="http://www.packtpub.com/files/Elgg-Social-Networking-Sample-Chapter-Chapter-3-Users-Profiles-and-Connections.pdf" rel="nofollow">http://www.packtpub.com/files/Elgg-Social-Networking-Sample-Chapter-Chapter-3-Users-Profiles-and-Connections.pdf</a> Free shipping to the US, UK, Europe and selected Asian countries. For more information, please read our shipping policy. </p>]]>http://www.webmonkey.com/tutorial/Create_Rich_Interfaces_With_the_YUI_LibraryTutorial:Create Rich Interfaces With the YUI Libraryhttp://www.webmonkey.com/tutorial/Create_Rich_Interfaces_With_the_YUI_LibraryThu, 04 Dec 2008 21:08:13 -0500 (EST)<![CDATA[<p>The line between web and desktop applications is fading. Users now expect a richer experience. JavaScript can help provide interfaces and interactions that mimic the desktop. In this tutorial, I'll introduce you to the JavaScript-based Yahoo User Interface Library. We'll use it to convert normal HTML into more interactive controls. </p><p>Best of all, Yahoo's library is open-source and has been released under a BSD license, so it's free for all users. </p> <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1"><a href="#What_You.27ll_Need"><span class="tocnumber">1</span> <span class="toctext">What You'll Need</span></a></li> <li class="toclevel-1"><a href="#Add_YUI_to_Your_Page"><span class="tocnumber">2</span> <span class="toctext">Add YUI to Your Page</span></a></li> <li class="toclevel-1"><a href="#Go_.27Round_With_The_Carousel_Control"><span class="tocnumber">3</span> <span class="toctext">Go 'Round With The Carousel Control</span></a> <ul> <li class="toclevel-2"><a href="#Start_With_an_Ordered_List"><span class="tocnumber">3.1</span> <span class="toctext">Start With an Ordered List</span></a></li> <li class="toclevel-2"><a href="#Transform_List_Into_a_Carousel"><span class="tocnumber">3.2</span> <span class="toctext">Transform List Into a Carousel</span></a></li> <li class="toclevel-2"><a href="#Make_it_Loop_Infitely"><span class="tocnumber">3.3</span> <span class="toctext">Make it Loop Infitely</span></a></li> </ul> </li> <li class="toclevel-1"><a href="#Get_a_Date_With_The_Calendar_Control"><span class="tocnumber">4</span> <span class="toctext">Get a Date With The Calendar Control</span></a> <ul> <li class="toclevel-2"><a href="#Start_With_an_Input_Field"><span class="tocnumber">4.1</span> <span class="toctext">Start With an Input Field</span></a></li> <li class="toclevel-2"><a href="#Attach_a_Calendar"><span class="tocnumber">4.2</span> <span class="toctext">Attach a Calendar</span></a></li> <li class="toclevel-2"><a href="#Add_Some_Events"><span class="tocnumber">4.3</span> <span class="toctext">Add Some Events</span></a></li> </ul> </li> <li class="toclevel-1"><a href="#Where_to_go_From_Here"><span class="tocnumber">5</span> <span class="toctext">Where to go From Here</span></a></li> </ul> </li> </ul> </td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script> <a name="What_You.27ll_Need"></a><h2> <span class="mw-headline">What You'll Need</span></h2> <ul><li> Basic knowledge of HTML and CSS </li><li> Some experience with JavaScript </li></ul> <a name="Add_YUI_to_Your_Page"></a><h2> <span class="mw-headline">Add YUI to Your Page</span></h2> <p>Like other JavaScript frameworks and toolkits, you can <a href="http://developer.yahoo.com/yui/" class="external text" title="http://developer.yahoo.com/yui/" rel="nofollow">download YUI</a> so that you'll have all the files. The examples in this tutorial will instead use special versions containing only the code you'll need. </p><p>Yahoo also has a <a href="http://developer.yahoo.com/yui/articles/hosting/" class="external text" title="http://developer.yahoo.com/yui/articles/hosting/" rel="nofollow">file configurator</a> to determine the YUI JavaScript and CSS files you need to access. </p><p>There are a couple upsides to going the hosted route: </p><p>1. Yahoo hosts the files for you. Save your bandwidth.<br /> 2. The files are minimized and combined into a single file. That means faster load times for your users. </p><p><br /> If you want one a single call to YUI that will work for all the examples in this tutorial, select the following in the <a href="http://developer.yahoo.com/yui/articles/hosting/" class="external text" title="http://developer.yahoo.com/yui/articles/hosting/" rel="nofollow">configurator</a>: </p> <ul><li> Filter: -min </li><li> Options: Combine Files, Allow Rollup </li><li> YUI CSS Packages: Fonts CSS Package </li><li> YUI User Interface Widgets: Calendar Control, Carousel Control </li></ul> <p>The tool produces a single JavaScript reference and one CSS reference. Add these two lines, output from the tool, to the <code>&lt;head&gt;</code> section of your HTML file: </p> <pre> &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;http://yui.yahooapis.com/combo?2.6.0/build/fonts/fonts-min.css&amp;2.6.0/build/calendar/assets/skins/sam/calendar.css&amp;2.6.0/build/carousel/assets/skins/sam/carousel.css&quot;&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;http://yui.yahooapis.com/combo?2.6.0/build/yahoo-dom-event/yahoo-dom-event.js&amp;2.6.0/build/calendar/calendar-min.js&amp;2.6.0/build/element/element-beta-min.js&amp;2.6.0/build/carousel/carousel-beta-min.js&quot;&gt;&lt;/script&gt; </pre> <p><br /> </p><p>Before we move on to using YUI, you need to do one more thing to make Yahoo's CSS works for styling the controls we'll be using in this tutorial. Add the appropriate class to your page, like so: </p> <pre> &lt;body class=&quot;yui-skin-sam&quot;&gt; </pre> <p><br /> </p><p>OK, now we're ready! </p> <a name="Go_.27Round_With_The_Carousel_Control"></a><h2> <span class="mw-headline">Go 'Round With The Carousel Control</span></h2> <p>The rotating content pane is a common sight on information-heavy pages. For example, Yahoo's homepage has a version that cycles through the top stories of the moment. In YUI, this is called a carousel and implementing one is easy. </p><p>You can <a href="http://www.webmonkey.com/codelibrary/YUI_Carousel" class="external text" title="http://www.webmonkey.com/codelibrary/YUI_Carousel" rel="nofollow">grab the code</a> for this entire example in Webmonkey's Code Library, saving it as an HTML file, or simply follow along with each portion below. </p><p><br /> </p> <a name="Start_With_an_Ordered_List"></a><h3> <span class="mw-headline">Start With an Ordered List</span></h3> <p>One of the nice things about YUI Library is that it makes it easy to write code that degrades gracefully. The controls all start with basic HTML used as hooks for the JavaScript. In this case, our carousel is simply an ordered list. If the YUI code is somehow unable to load, the content will still show up in list form. It will look a little funky, but that's better than making the page explode or showing nothing at all. </p><p>Here's the HTML to get ready for our carousel: </p> <pre> &lt;div id=&quot;carouselcontainer&quot;&gt; &lt;ol id=&quot;carousel&quot;&gt; &lt;li&gt; &lt;div&gt;Monkey&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div&gt;Likes&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div&gt;Riding&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div&gt;The&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;div&gt;Carousel&lt;/div&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; </pre> <p>The outer div is used as a hook for the entire object. Within it, I included a simple ordered list. Each list item is a Carousel panel. You can include anything within the <code>&gt;li&lt;</code> tag. Here I'm just using a div, then adding some style. Go ahead and copy this into your stylesheet or between <code>&lt;style&gt;</code> tags in your header: </p> <pre> ol#carousel li div { width: 400px; padding: 50px 0; font-size: 40px; } </pre> <p><br /> </p><p><br /> </p> <a name="Transform_List_Into_a_Carousel"></a><h3> <span class="mw-headline">Transform List Into a Carousel</span></h3> <p>Now it's time to apply the code used to make our ordinary ordered list into a beautiful carousel. Inside the <code>&lt;head&gt;</code> HTML tags, place these few lines of JavaScript: </p> <pre> &lt;script type=&quot;text/javascript&quot;&gt; function init_carousel() { var carousel = new YAHOO.widget.Carousel(&quot;carouselcontainer&quot;, { numVisible: 1 }); // Create the carousel object carousel.render(); // Let YUI set up its styles carousel.show(); // Finally, show the carousel } YAHOO.util.Event.onDOMReady(init_carousel); &lt;/script&gt; </pre> <p><br /> </p><p>There are two pieces to the above code. First, the <code>init_carousel</code> function that has the three lines necessary to transform the ordered list into the carousel. Then, the final line tells YUI to wait for the Document Object Model (DOM) to load in the browser before calling the <code>init_carousel</code> function. </p><p>Let's see how it works. Save the file and load it in a browser and you should see something like this: </p><p><iframe src="http://www.wired.com/wired/archive/webmonkey/YUI/carousel.html" align="middle" name="Page1" frameborder="0" height="230" scrolling="no" width="600"></iframe> </p> <a name="Make_it_Loop_Infitely"></a><h3> <span class="mw-headline">Make it Loop Infitely</span></h3> <p>Normally programmers try to avoid infinite loops, but this is a different kind of loop. Here we want to tell the carousel that when the next button is hit on the final panel, it can go back to the first panel. Even better, let's have it move to the next panel automatically. </p><p>Each of these features is part of the Carousel control from YUI. With just a few keystrokes, we can add them to our current carousel. </p><p>Find the first line of <code>init_carousel</code> and replace it with this line to create the carousel object with the features we want: </p> <pre> var carousel = new YAHOO.widget.Carousel(&quot;carouselcontainer&quot;, { numVisible: 1, isCircular: true, autoPlay: 2000 }); // Create the carousel object, with auto looping </pre> <p><br /> </p><p>This adds two more options to the call that creates our carousel: </p> <ol><li> /isCircular/ tells the final panel to go to the first panel next, to make it loop. </li><li> /autoPlay/ tells how many milliseconds to wait before going to the next panel. I set this one to 2000, which is two seconds. </li></ol> <p>If you load up this new version, you'll notice that the panels do go 'round and 'round when you click. They don't advance on their own, despite adding autoPlay to our options. That's because the carousel also needs us to <b>start</b> the autoplaying. </p><p>On the final line of init_carousel (right after the <code>.show()</code> line), give it the go-ahead: </p> <pre> carousel.startAutoPlay(); </pre> <p><br /> </p><p>Now your carousel should loop infinitely, all on its own! </p> <a name="Get_a_Date_With_The_Calendar_Control"></a><h2> <span class="mw-headline">Get a Date With The Calendar Control</span></h2> <p>The Carousel example in the previous section shows how YUI Library can help you present content in a nicer way. In this section, we'll see an interface tool that's even more functional. The Calendar control accepts a date from a user and adds the result into a text field, which means you get to decide the format. </p><p>You can <a href="http://www.webmonkey.com/codelibrary/YUI_Calendar" class="external text" title="http://www.webmonkey.com/codelibrary/YUI_Calendar" rel="nofollow">download this entire example</a> from Webmonkey's Code Library or follow along with each portion below. </p><p><br /> </p> <a name="Start_With_an_Input_Field"></a><h3> <span class="mw-headline">Start With an Input Field</span></h3> <p>Like the Carousel example, the Calendar object starts as normal HTML. In this case, we need a standard text box and an empty div, which provides the hooks necessary for YUI to build the calendar. </p><p>Add this HTML to a file that already references the JavaScript and CSS files: </p> <pre> &lt;form&gt; Date: &lt;input type=&quot;text&quot; id=&quot;datefield&quot; /&gt; &lt;div id=&quot;cal&quot;&gt;&lt;/div&gt; &lt;/form&gt; </pre> <p><br /> </p><p>That's it. Now let's write the JavaScript. </p><p><br /> </p> <a name="Attach_a_Calendar"></a><h3> <span class="mw-headline">Attach a Calendar</span></h3> <p>Now we can apply the code used to make that little empty div nubbin into an interactive calendar. Inside the <code>&lt;head&gt;</code> HTML tags, place these few lines of JavaScript: </p> <pre> &lt;script type=&quot;text/javascript&quot;&gt; function init_calendar() { var cal = new YAHOO.widget.Calendar(&quot;cal&quot;, { title:&quot;Choose a date:&quot;, close:true } ); cal.render(); } YAHOO.util.Event.onDOMReady(init_calendar); &lt;/script&gt; </pre> <p><br /> </p><p>Just two lines to initialize the calendar! One creates the object and the other draws it to the screen. Then one final line calls the <code>init_calendar</code> function when the DOM is ready. </p><p>Save and load your file and you'll see something like this: <iframe src="http://www.wired.com/wired/archive/webmonkey/YUI/calendar_basic.html" align="middle" name="Page1" frameborder="0" height="300" scrolling="no" width="600"></iframe> </p><p>You may notice that two promised pieces of the calendar are so far missing: </p> <ol><li> The calendar should only appear when the user clicks in the date field </li><li> The calendar should add the date when the user selects one </li></ol> <p>Adding events will help us add these two features. </p> <a name="Add_Some_Events"></a><h3> <span class="mw-headline">Add Some Events</span></h3> <p>Our calendar looks good, but it sure acts weird. In this section we'll add two events to make the calendar behave normally. </p><p>Add these lines inside the <code>init_calendar</code> function: </p> <pre> cal.hide(); // Show Calendar when text field gets focus YAHOO.util.Event.addListener(&quot;datefield&quot;, &quot;focus&quot;, cal.show, cal, true); // Save calendar value inside text field cal.selectEvent.subscribe(addDateText, cal, true); </pre> <p><br /> </p><p>There are only three lines here, though it looks like more because of empty lines and those that are commented out (the ones that start with //). </p><p>The first line hides the calendar when it loads. We don't want to show it until the user clicks. </p><p>The second line creates a new event. Whenever the text box (with id="datefield") receives "focus," the <code>cal.show</code> function will be called. That one line is enough to make the calendar appear whenever the user clicks into the date field. </p><p>The third line creates yet another event. It's a special, calendar-specific event for when the user selects a date. It calls the <code>addDateText</code> function, which we need to create. Go ahead and add the following code above the init_calendar function: </p> <pre> function addDateText(type, args, obj) { var datedata = args[0][0]; var year = datedata[0]; var month = datedata[1]; var day = datedata[2]; document.forms[0].datefield.value = month+'/'+day+'/'+year; obj.hide(); } </pre> <p>The parameters (/type/, /args/, /obj/) are decided by the Calendar control and automatically passed to our function. The /args/ variable contains our date data, which I extracted into three new variables: /year/, /month/, and /day/. </p><p>Then I create the text for the text box by concatenating them together. The format I used is MM/DD/YYYY, but you could manipulate the JavaScript to change it to whatever you want. </p><p>Finally, the last thing I do is to hide the calendar (passed as the /obj/ variable), because we don't need the calendar displayed once the user has selected a date. </p><p>And that's it. You've used YUI and a little bit of custom JavaScript to create a text field that lets a user choose a date from a calendar. </p> <a name="Where_to_go_From_Here"></a><h2> <span class="mw-headline">Where to go From Here</span></h2> <p>You've seen only a small piece of what's possible with YUI Library. Here are some ideas to consider for your first unassisted foray into building something cool with YUI: </p> <ul><li> Add a <a href="http://developer.yahoo.com/yui/editor/" class="external text" title="http://developer.yahoo.com/yui/editor/" rel="nofollow">rich text editor</a> to give users more control over how their content looks. </li><li> Rather than ask for numbers, use a <a href="http://developer.yahoo.com/yui/slider/" class="external text" title="http://developer.yahoo.com/yui/slider/" rel="nofollow">slider to get numeric input</a>. </li><li> Similar to the Carousel, use the <a href="http://developer.yahoo.com/yui/tabview/" class="external text" title="http://developer.yahoo.com/yui/tabview/" rel="nofollow">TabView to segment content</a> into panels to be viewed on a single page. </li><li> Read the YUI team's article on <a href="http://developer.yahoo.com/yui/articles/skinning/" class="external text" title="http://developer.yahoo.com/yui/articles/skinning/" rel="nofollow">skinning YUI</a>, which lets you decide exactly how the widgets are displayed. </li></ul> <p>When you're done, be sure to <a href="http://www.webmonkey.com/services/create/" class="external text" title="http://www.webmonkey.com/services/create/" rel="nofollow">create a tutorial</a> on Webmonkey that shows how you did it. </p>]]>http://www.webmonkey.com/tutorial/Create_Simpler_PHP_LoginsTutorial:Create Simpler PHP Loginshttp://www.webmonkey.com/tutorial/Create_Simpler_PHP_LoginsThu, 04 Dec 2008 21:08:13 -0500 (EST)<![CDATA[<div style="width:400px;background-color:#FF9900;border-style:solid double;border-width:4px;border-color:#FF0000;padding:5px"> <p><b>EDITORS NOTE</b>: This page is incomplete. The user-generated content in this page may need your help. It may contain errors, inappropriate links and methods have not not been verified to work. </p><p>Comments on the future of this page belong under the <b>Discussion</b> tab. Press <b>Edit</b> to modify this page to add and remove content or correct for grammar and/or code errors. </p> </div> <a name="Introduction"></a><h2> <span class="mw-headline"> Introduction </span></h2> <p>Creating a log in script using PHP can be easier using the power of strcmp(). </p> <a name="What_you.27ll_need"></a><h2> <span class="mw-headline"> What you'll need </span></h2> <p>You'll need to have a database, or text file and know how to look up the password using the username. This is simply to create a faster, easier, more secure way of comparing the two strings using PHPs built in strcmp() or strcasecmp() functions. </p> <a name="Steps"></a><h2> <span class="mw-headline"> Steps </span></h2> <p>After accessing your username/password combinations through MySQL, a text file or other methods you can easily compare the string values using strcmp(). </p><p>if(strcmp($userpass,$passentered)){ //display secure content } else { //ask for username/password combo again } </p><p>This is a quick and easy method. If the two strings passed to the function are EXACTLY the same, then the returned value will be 0. If case sensitivity is not necessary then use strcasecmp($a,$b) - which works exactly the same way but ignores case sensitivity. </p>]]>http://www.webmonkey.com/tutorial/Create_and_Customize_Business_Applications_with_New_Book_on_Apache_OFBizTutorial:Create and Customize Business Applications with New Book on Apache OFBizhttp://www.webmonkey.com/tutorial/Create_and_Customize_Business_Applications_with_New_Book_on_Apache_OFBizThu, 04 Dec 2008 21:08:13 -0500 (EST)<![CDATA[<a name="Introduction"></a><h2> <span class="mw-headline"> Introduction </span></h2> <p>Apache OFBiz Development: The Beginner's Tutorial is a new book from Packt that will help developers install and configure OFBiz to optimize system performance. Written by two leading OFBiz consultants Rupert Howell and Jonathon Wong, this book teaches developers to use services, entities, and widgets to build custom ERP and CRM systems. </p><p>Apache OFBiz (Open For Business) is an open-source enterprise automation software that powers many small and medium sized businesses around the world. Built around an MVC framework with common logic, data model and process components, Ofbiz allows existing and bespoke applications to be added through a component-based architecture. </p><p>Through examples in this book, readers will learn what OFBiz is, and how to build business applications rapidly. The book explains the Model-View-Controller framework and readers will learn about Widgets, Entities, and The Service Engine. They will also be able to develop a bespoke OFBiz component and also enhance and modify existing components. </p><p>Users will be able to simplify database operations and perform complicated queries by learning the basic units of the framework's Model. They will also learn to build synchronous and asynchronous communications by creating Java services in the Service Engine. Using the OFBiz language: MiniLang, readers will be able to speed up their OFBiz development. </p><p>This book is targeted at developers wanting to build easily deployed and supported OFBiz applications. For more information, please visit <a href="http://www.packtpub.com/apache-ofbiz-development-beginners-tutorial/book" class="external free" title="http://www.packtpub.com/apache-ofbiz-development-beginners-tutorial/book" rel="nofollow">http://www.packtpub.com/apache-ofbiz-development-beginners-tutorial/book</a> </p>]]>http://www.webmonkey.com/tutorial/Play_mary_had_a_little_lamb_on_the_violinTutorial:Play mary had a little lamb on the violinhttp://www.webmonkey.com/tutorial/Play_mary_had_a_little_lamb_on_the_violinThu, 04 Dec 2008 21:08:13 -0500 (EST)<![CDATA[<a name="Introduction"></a><h2> <span class="mw-headline"> Introduction </span></h2> <p>\ </p>]]>