<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rochak Chauhan::Unpredictably Exciting &#187; Ajax</title>
	<atom:link href="http://rochakchauhan.com/blog/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://rochakchauhan.com/blog</link>
	<description>Know your limits, but never stop trying to exceed them.</description>
	<lastBuildDate>Thu, 03 May 2012 11:48:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>AJAX browser vote exceeds &#8216;wild&#8217; expectations</title>
		<link>http://rochakchauhan.com/blog/2008/07/10/ajax-browser-vote-exceeds-wild-expectations/</link>
		<comments>http://rochakchauhan.com/blog/2008/07/10/ajax-browser-vote-exceeds-wild-expectations/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 09:09:14 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[Tech News]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Browser]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/2008/07/10/ajax-browser-vote-exceeds-wild-expectations/</guid>
		<description><![CDATA[There&#8217;s been a late surge of interest in voting for a wishlist of features users want added to web browsers, after being ignored for months. With less than a day left before the OpenAjax Alliance closes its poll for most-wanted browser features 116 people have now voted, according to the project&#8217;s summary. That&#8217;s up from &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/07/10/ajax-browser-vote-exceeds-wild-expectations/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s been a late surge of interest in voting for a wishlist of features users want added to web browsers, after being ignored for months.</p>
<p>With less than a day left before the <a href="http://www.openajax.org/index.php">OpenAjax Alliance</a> closes its poll for most-wanted browser features 116 people have now voted, according to the project&#8217;s <a href="http://www.openajax.org/runtime/wiki/Feature_Requests_Summary_Page">summary</a>. That&#8217;s up from a miserable 13 by early June, two months after OpenAjax called for votes, and following last month&#8217;s <em>Reg</em> <a href="http://www.theregister.co.uk/2008/06/10/ajax_alliance_poll_apathy/">article</a>.</p>
<p>IBMer Jon Ferraiolo, a member of the Alliance&#8217;s <a href="http://www.openajax.org/member/wiki/Runtime">Runtime Task Force</a>, <a href="http://openajax.org/pipermail/public/2008q3/000034.html">said</a> he&#8217;s pleased with the level of participation.</p>
<p>&#8220;From my perspective, the initiative has exceeded even the wildest expectations, both in terms of the quantity and quality of the feature requests and the level of community participation,&#8221; Ferraiolo said.</p>
<p>OpenAjax boasts a membership of more than 100 companies, organizations and projects with a mission to standardize AJAX implementations. The poll&#8217;s results will be presented to vendors as a call for features that they&#8217;d like to see in browsers. The initiative was <a href="http://www.openajax.org/runtime/wiki/Main_Page">launched</a> in April and is scheduled to be completed by the end of this month.</p>
<p>So far, there have been 37 feature requests. At time of going to press on the eve of the poll closing, <a href="http://www.openajax.org/runtime/wiki/2D_Drawing/Vector_Graphics">2D drawing and vector graphics</a> topped the list, followed by <a href="http://www.openajax.org/runtime/wiki/Native_JSON_Parsing" target="_blank">native JSON parsing</a> and <a href="http://www.openajax.org/runtime/wiki/Better_Security_for_Cross-site_Scripts">better security for cross-site scripts</a>. Other features attracting significant levels of support include <a href="http://www.openajax.org/runtime/wiki/DOM_Performance">improved HTML DOM performance</a> and <a href="http://www.openajax.org/runtime/wiki/Better_APIs_Positioning_Styling">better APIs for positioning and styling</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/07/10/ajax-browser-vote-exceeds-wild-expectations/feed/</wfw:commentRss>
		<slash:comments>349</slash:comments>
		</item>
		<item>
		<title>Streamline your search with Yahoo! Web Services and AJAX</title>
		<link>http://rochakchauhan.com/blog/2008/02/05/streamline-your-search-with-yahoo-web-services-and-ajax/</link>
		<comments>http://rochakchauhan.com/blog/2008/02/05/streamline-your-search-with-yahoo-web-services-and-ajax/#comments</comments>
		<pubDate>Tue, 05 Feb 2008 16:57:10 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tech News]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[Yahoo]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/2008/02/05/streamline-your-search-with-yahoo-web-services-and-ajax/</guid>
		<description><![CDATA[Despite what you might read and hear about Google&#8217;s web dominance, this is not Google-owned world. Yahoo! may be playing second fiddle to the internet&#8217;s favorite search and ads service, but it still plays one hell of a tune in terms of numbers of users and the services it offers. If you use Yahoo! for &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/02/05/streamline-your-search-with-yahoo-web-services-and-ajax/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Despite what you might read and hear about Google&#8217;s web dominance, this is not Google-owned world. Yahoo! may be playing second fiddle to the internet&#8217;s favorite search and ads service, but it still plays one hell of a tune in terms of numbers of users and the services it offers.</p>
<p>If you use Yahoo! for your web search, then Yahoo! provides web services that may be included in web applications to generate dynamic content for an input.</p>
<p id="MidArticleAd"><script type="text/javascript">     document.write(\'\x3Cscript src="http://ad.uk.doubleclick.net/adj/reg.developer.4159/code;\'+RegExCats+GetVCs()+\'chl=;pid=\'+RegId+\';\'+RegKW+\'maid=\'+maid+\';test=\'+test+\';pf=\'+RegPF+\';dcove=d;sz=336x280;tile=3;ord=\' + rand + \'?" type="text/javascript">\x3C\/script>\');</script><script src="http://ad.uk.doubleclick.net/adj/reg.developer.4159/code;vc=print.print;vc=dev.code;chl=;pid=0;maid=;test=;pf=1;dcove=d;sz=336x280;tile=3;ord=74835324578534?" type="text/javascript"></script><noscript></noscript></p>
<p>In this article, we follow up  Asynchronous JavaScript and XML (AJAX) to your Google search, by looking at adding AJAX to web search using Yahoo! Web Services in Oracle JDeveloper 11g. Why JDeveloper 11g? Because this provides a new feature for web and AJAX development &#8211; an integrated JavaScript editor.</p>
<h3>Limits of AJAX</h3>
<p>AJAX is a web technique to transfer XML data between a browser and a server without reloading the web page. Ajax is implemented using the <code>XMLHttpRequest</code> object.</p>
<p>A limitation of <code>XMLHttpRequest</code> is that AJAX requests may be made only to the same web server that serves the web page from where the AJAX request is sent. If the web application is running on one server and the web service is on another server a <code>XMLHttpRequest</code> request does not get sent. Various methods are available to send an AJAX request to a remote server some of which are digitally signing your scripts and using an alternative <code>XMLHttpRequest</code> API. One of the methods, which we shall discuss in this article, is to use a proxy web server that routes AJAX requests from the web application to the web service.</p>
<p>Yahoo! Web Services provide various web search services and content that may be included to develop dynamic web applications. Yahoo! Web Search AJAX Web Services have an advantage over the Google web search AJAX web services. Yahoo! Web Services have the provision to search within a context; contextual web search. For example, search for the term &#8220;Eclipse&#8221; in the context of &#8220;Java IDE&#8221;. The various Web Search Web Services provided by Yahoo! are discussed in following Table.</p>
<table border="1">
<tr>
<th>Web service</th>
<th>Description</th>
</tr>
<tr>
<td>Context search</td>
<td>The contextual web search service returns web pages that match a query within a specified context</td>
</tr>
<tr>
<td>Related suggestion</td>
<td>Provides suggestions for related queries based on the submitted query</td>
</tr>
<tr>
<td>Spelling suggestion</td>
<td>Provides suggested spellings for a specified term</td>
</tr>
<tr>
<td>Web search</td>
<td>Provides a web search service using REST (Representational State Transfer)</td>
</tr>
</table>
<p>Before Yahoo! Web Service may be used, register with <a href="https://login.yahoo.com/config/login_verify2?.src=devnet&amp;.done=https%3A%2F%2Fdeveloper.yahoo.com%2Fwsregapp%2Findex.php">Yahoo Web Services</a> (<span class="URL">https://login.yahoo.com/config/login_verify2?.src=devnet&amp;.done=https%3A%2F%2Fdeveloper.yahoo.com%2Fwsregapp%2Findex.php</span>) to obtain an application identity with which Yahoo! Web Services may be accessed.</p>
<h3>Create a web application</h3>
<p>First, create a JDeveloper application, <code>WebSearchApp</code>, and project, <code>WebSearchWebService</code>. Create a JSP file, <code>input.jsp</code>, in the project. The web application URL, which is used to register with Yahoo! Web Services, is <code>http://127.0.0.1:8988/WebSearchApp-WebSearchWebService-context-root/input.jsp</code>. In the web application we shall use the Contextual Web Search service to submit a context-base web search query.</p>
<p>The request URL for the contextual web search web service is <code>http://search.yahooapis.com/WebSearchService/V1/contextSearch</code>. The required request parameters to a contextual web search query are <code>appid</code> and <code>context</code>. The value of the <code>appid</code> parameter is the application ID provided by Yahoo! Web Services and the context parameter specifies the context string in which the web search query is sent.</p>
<hr class="PageBreak" />The XML response returned by the Contextual Web Search service conforms to the XML Schema <code>http://search.yahooapis.com/WebSearchService/V1/WebSearchResponse.xsd</code>. In the <code>input.jsp</code> add a form containing fields for application ID, query, results, and context. The form may be submitted using GET or POST, but to use a context with many search terms use the POST method.</p>
<h3>Send an AJAX request</h3>
<p>To send an AJAX request we shall use a proxy servlet that routes the <code>XMLHttpRequest</code> from the browser to the Yahoo! Web Service. If an <code>XMLHttpRequest</code> is sent without a proxy servlet the <code>XMLHttpRequest</code> does not get sent and an error, such as the one below, is generated.</p>
<pre>Error: uncaught exception: Permission denied to call method XMLHttpRequest.open</pre>
<p>A proxy servlet may be developed or the <a href="http://www.servletsuite.com/servlets/httpproxy.htm">HTTP proxy servlet</a> (<span class="URL">http://www.servletsuite.com/servlets/httpproxy.htm</span>) may be used. Download <code>httpProxyPackage.jar</code>. Add the proxy servlet JAR file to the Libraries of the <code>WebSearchWebService</code> project. To the <code>web.xml</code> file add <code>&lt;servlet/&gt;</code> and <code>&lt;servlet-mapping/&gt;</code> elements for the proxy servlet.</p>
<pre>&lt;servlet&gt;         &lt;servlet-name&gt;HttpProxy&lt;/servlet-name&gt;         &lt;servlet-class&gt;com.jsos.httpproxy.HttpProxyServlet&lt;/servlet-class&gt;         &lt;init-param&gt;             &lt;param-name&gt;host&lt;/param-name&gt;             &lt;param-value&gt;http://search.yahooapis.com/WebSearchService/V1/contextSearch&lt;/param-value&gt;         &lt;/init-param&gt;     &lt;/servlet&gt;     &lt;servlet-mapping&gt;         &lt;servlet-name&gt;HttpProxy&lt;/servlet-name&gt;         &lt;url-pattern&gt;/servlet/yahoo&lt;/url-pattern&gt;     &lt;/servlet-mapping&gt;</pre>
<p>The procedure to send an AJAX request is as follows:</p>
<ol>
<li>Initiate an AJAX request from an HTML event such as a button click</li>
<li>Create a <code>XMLHttpRequest</code> object</li>
<li>Open a connection with the web service URL using the open() method of the <code>XMLHttpRequest</code> object</li>
<li>Register a callback function to be invoked when the Ajax request is complete</li>
<li>Send the AJAX request with the send() method</li>
<li>Update the web page with the web service response</li>
</ol>
<p>In the <code>input.jsp</code>, to the input element of type button add a <code>onclick</code> event handler to invoke a JavaScript function <code>displaySearchResults()</code>. In the <code>displaySearchResults</code> function create an <code>XMLHttpRequest</code> object. <code>XMLHttpRequest</code> is supported as a native object in some browsers such as Netscape 6 or later and Internet Explorer 7 and as an ActiveXObject in other browsers such as IE 6.</p>
<p>Specify the proxy servlet URL to which an AJAX request is to be sent. Obtain the values for query, results and context request parameters from the input form. Open an <code>XMLHttpRequest</code> request using the <code>open()</code> method. Register a callback function that is to be invoked when the request state changes using the <code>onreadystatechange</code> property of the <code>XMLHttpRequest</code> object. Send the <code>XMLHttpRequest</code> request using the <code>send()</code> method. In the callback function check if the request is complete and invoke the JavaScript function <code>processResponse()</code> to update the web page with the Web Service response. The complete <code>input.jsp</code> is available in <a href="http://regmedia.co.uk/2008/01/29/yahooajax_resources.zip">this</a> (<span class="URL">http://regmedia.co.uk/2008/01/29/yahooajax_resources.zip</span>) zipped folder.</p>
<h3>Integrated JavaScript editor</h3>
<p>JDeveloper 11g includes an integrated JavaScript editor for creating JavaScript. In the previous section we added the JavaScript directly to the JSP, but the JavaScript may also be created in a separate <code>.js</code> file and the <code>.js</code> file added to the JSP using the <code>&lt;script/&gt;</code> tag. Create a JavaScript file by selecting File&gt;New and in the New Gallery window Web Tier&gt;HTML&gt;JavaScript File. Copy the JavaScript from the <code>input.jsp</code> JSP to the JavaScript file and delete the JavaScript from the JSP.</p>
<hr class="PageBreak" />One of the features of the JavaScript editor is syntax highlighting. To add syntax highlighting select Tools&gt;Preferences and in the Preferences window Code Editor&gt;Syntax Colors. Select JavaScript in the Language list. The Font Style, Foreground color and Background color may be set for the different JavaScript constructs in the Syntax Colors window.JavaScript editor also provides code completion. As the JavaScript syntax varies in the different browsers we need to specify the browser for which code completion is to be implemented. Select JavaScript Editor in the Preferences window and select a Target Browser for code completion. In the JavaScript file right click and select Source&gt;Completion Insight or Smart Completion Insight for code insight.</p>
<p>Another useful feature of the JavaScript editor is Go To Declaration, to navigate to or from a JavaScript variable or function. You can try this by selecting a use for the variable <code>xmlHttpRequest</code> and then right click and select Go To Declaration to go to the declaration of the <code>xmlHttpRequest</code> variable. JavaScript editor also provides brace matching and code folding.</p>
<p>Error underling and error audits are also helpful. Here&#8217;s a simple way to test them: add an error by removing the &#8216;{&#8216; for a function declaration. An error analysis will then be run and the error underlined. Usages for a variable or function may be retrieved by selecting the variable/function and selecting Find Usages. For example, select <code>xmlHttpRequest</code>, right click and select Find Usages. The usages of the <code>xmlHttpRequest</code> variable get listed in the log window.</p>
<p>A JavaScript file is integrated with the Structure pane from which different variables and functions may be navigated to. JavaScript editor also provides refactoring to rename or delete a variable or function. To refactor, right click and select Refactor&gt;Rename or Delete Safely. To add the JavaScript file to the <code>input.jsp</code> drag and drop the file from the Application navigator to the JSP. A <code>&lt;script/&gt;</code> element for the JavaScript file gets added to the JSP.</p>
<h3>Run the AJAX web search</h3>
<p>Next, we shall run the AJAX web application to send a query using AJAX an update the web page with the query response. Right click on <code>input.jsp</code> and select Run. In the web search form specify a query term and a context term. As an example, search for the term &#8220;AJAX&#8221; in the context of &#8220;web services&#8221;. Click on the Submit Query button. The web page gets updated with the AJAX web service response.</p>
<p>More than one context terms may be specified and the number of results to be returned may also be specified. As an example specify results as five and specify context terms as &#8220;web services&#8221;, &#8220;XML&#8221;, and &#8220;ADF&#8221; for query term &#8220;AJAX&#8221;. The specified number of web pages get displayed for the context based web search.</p>
<h3>Conclusion</h3>
<p>You now have the recepie for building fast and efficient web services. Contextual web search using Yahoo Web Services will help you narrow down your search results. The addition of AJAX will help reduce response times and the amount of network bandwidth consumed as the complete web page is not reposted.</p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/02/05/streamline-your-search-with-yahoo-web-services-and-ajax/feed/</wfw:commentRss>
		<slash:comments>514</slash:comments>
		</item>
		<item>
		<title>Great User Interface with YUI (Yahoo! User Interface) Library</title>
		<link>http://rochakchauhan.com/blog/2008/01/14/great-user-interface-with-yui-yahoo-user-interface-library/</link>
		<comments>http://rochakchauhan.com/blog/2008/01/14/great-user-interface-with-yui-yahoo-user-interface-library/#comments</comments>
		<pubDate>Mon, 14 Jan 2008 10:14:15 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Yahoo]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/2008/01/14/great-user-interface-with-yui-yahoo-user-interface-library/</guid>
		<description><![CDATA[YUI Library The YUI Library is a set of utilities and controls in JavaScript, as well as CSS templates for building richly interactive Web applications using standard technologies such as DHTML, DOM scripting, and AJAX. You can download the YUI Library 2.3.1 for free from SourceForge.net. The download allows you to install the libraries on &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/01/14/great-user-interface-with-yui-yahoo-user-interface-library/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p align="center"><strong>YUI Library</strong></p>
<p>The YUI Library is a set of utilities and controls in JavaScript, as well as CSS templates for building richly interactive Web applications using standard technologies such as DHTML, DOM scripting, and AJAX.</p>
<p>You can <a href="http://sourceforge.net/project/downloading.php?group_id=165715&amp;filename=yui_2.3.1.zip">download the YUI Library 2.3.1</a> for free from SourceForge.net. The download allows you to install the libraries on a Web server. Another option is to use the library files directly from Yahoo! servers. Yahoo! provides an excellent overview of how to use its servers for applications implementing functionality via the YUI Library.</p>
<p><strong>Rich Text Editor</strong></p>
<p>A recent addition to the YUI Library is the Rich Text Editor. It is a user interface control that replaces the standard HTML textarea element. It allows for the rich formatting of text content, including common structural treatments like lists, formatting treatments like bold and italic text, and drag-and-drop inclusion and sizing of images.</p>
<p>A critical feature of the Rich Text Editor is its toolbar, which provides access to various features like text formatting, colour choices, and so forth. You may choose which toolbar features to include in an implementation via scripting. In addition, the toolbar is extensible via a plug-in architecture so that advanced implementations can achieve a high degree of customisation.</p>
<p><strong>Putting the Rich Text Editor to work</strong></p>
<p>If you want to use the Rich Text Editor, it requires a YUI Library CSS skin to properly render the control. The following YUI Library files (CSS and JavaScript source files) are necessary to use the Rich Text Editor. The following lines reference the files on the previously mentioned Yahoo! servers, but you may use a local installation as well.</p>
<pre><code>&lt;!-- Skin CSS file --&gt;
&lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.3.1/build/assets/skins/sam/skin.css"&gt;
&lt;!-- Utility Dependencies --&gt;
&lt;script type="text/javascript" src="http://yui.yahooapis.com/2.3.1/build/yahoo-dom-event/yahoo-dom-event.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://yui.yahooapis.com/2.3.1/build/element/element-beta-min.js"&gt;&lt;/script&gt;
&lt;!-- Needed for Menus, Buttons and Overlays used in the Toolbar --&gt;
&lt;script src="http://yui.yahooapis.com/2.3.1/build/container/container_core-min.js"&gt;&lt;/script&gt;
&lt;script src="http://yui.yahooapis.com/2.3.1/build/menu/menu-min.js"&gt;&lt;/script&gt;
&lt;script src="http://yui.yahooapis.com/2.3.1/build/button/button-beta-min.js"&gt;&lt;/script&gt;
&lt;!-- Source file for Rich Text Editor--&gt;
&lt;script src="http://yui.yahooapis.com/2.3.1/build/editor/editor-beta-min.js"&gt;&lt;/script&gt;</code></pre>
<p>The following base HTML is used to deliver the Rich Text Box, but you&#8217;ll still need to add scripting to fully implement the control.</p>
<pre><code>&lt;body class="yui-skin-sam"&gt;
&lt;textarea name="texteditor" id="texteditor" cols="50" rows="10"&gt;
This text will be displayed in the text area.
&lt;/textarea&gt;&lt;/body&gt;</code></pre>
<p>Now the cols and rows attributes of the HTML texarea element will be overridden by settings specified in the Rich Text Editor&#8217;s script. The name assigned to the HTML textarea element is important, since it will be used in the JavaScript code when establishing the relationship between a textarea element and a Rich Text Editor.</p>
<p>Also, the class assigned to the HTML body element (yui-skin-sam) is used to visually format the Rich Text Editor control. This CSS skin is defined in the CSS file imported into the application (see previous list). The skin should be applied to the parent HTML element of the textarea element. In this case, the HTML body element is used, but it could be any element that contains the textarea.</p>
<p>Once the textarea has been defined along with the proper YUI Library files included in the page, the Rich Text Editor control must be rendered. The rendering is accomplished via JavaScript placed within the page. The script can be used to define various Rich Text Editor options such as the toolbar. As an example, I may use the following JavaScript to format our Rich Text Editor:</p>
<pre><code>var rtf = new YAHOO.widget.Editor('texteditor', {
height: '300px',
width: '522px'});
rtf.render();</code></pre>
<p>This snippet establishes the height and width of the editor while declaring an instance of the Rich Text Editor. Also, it assigns the textarea called texteditor to the Rich Text Editor. The final line in the script actually causes the Rich Text Editor to display when it calls its render method.</p>
<p>When you use the Rich Text Editor control without any specifics about the toolbar, it results in the default behaviour of including all toolbar features like text alignment, font face, font size, colour, and so forth. You may choose to limit the toolbar options available to users.</p>
<p>The final example uses a Rich Text Editor, but the toolbar options are defined in the JavaScript code to render it. The following options are used:</p>
<ul class="unIndentedList">
<li>The toolbar options are defined in its own variable. This is later used to instantiate the editor.</li>
<li>A title is assigned to the editor via the toolbar&#8217;s titlebar property.</li>
<li>The collapse property signals whether the user may collapse/hide the toolbar.</li>
<li>The buttons property allows you to define the buttons displayed in the toolbar. In this example, buttons are displayed for text formatting as well as selecting colours.</li>
</ul>
<p>Once the toolbar options are defined, a Rich Text Editor object is instantiated with the toolbar variable passed to it along with the HTML textarea element. The final step is to render the control. A complete list of options is available in the <a href="http://developer.yahoo.com/yui/docs/YAHOO.widget.Editor.html">YUI Library API documentation</a>.</p>
<pre><code>&lt;html&gt;&lt;head&gt;
&lt;title&gt;Working with YUI Library Rich Text Editor&lt;/title&gt;
&lt;!-- Skin CSS file --&gt;
&lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.3.1/build/assets/skins/sam/skin.css" /&gt;
&lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.3.1/build/fonts/fonts-min.css" /&gt;
&lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.3.1/build/container/assets/skins/sam/container.css" /&gt;
&lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.3.1/build/menu/assets/skins/sam/menu.css" /&gt;
&lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.3.1/build/button/assets/skins/sam/button.css" /&gt;
&lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.3.1/build/editor/assets/skins/sam/editor.css" /&gt;
&lt;!-- Utility Dependencies --&gt;
&lt;script type="text/javascript" src="http://yui.yahooapis.com/2.3.1/build/yahoo-dom-event/yahoo-dom-event.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://yui.yahooapis.com/2.3.1/build/element/element-beta-min.js"&gt;&lt;/script&gt;
&lt;!-- Needed for Menus, Buttons and Overlays used in the Toolbar --&gt;
&lt;script src="http://yui.yahooapis.com/2.3.1/build/container/container_core-min.js"&gt;&lt;/script&gt;
&lt;script src="http://yui.yahooapis.com/2.3.1/build/menu/menu-min.js"&gt;&lt;/script&gt;
&lt;script src="http://yui.yahooapis.com/2.3.1/build/button/button-beta-min.js"&gt;&lt;/script&gt;
&lt;!-- Source file for Rich Text Editor--&gt;
&lt;script src="http://yui.yahooapis.com/2.3.1/build/editor/editor-beta-min.js"&gt;&lt;/script&gt;
&lt;style&gt;
body { margin:0; padding:0; font-face: arial; font-size: 10pt;}
.yui-editor-container {z-index: 999;}
.editable {
border: 5px solid black;
margin-top: 100px;
margin: .25em;
float: left;
width: 350px;
height: 100px;
overflow: auto;
}
.textbox {
margin-left: 10px;
width: 100px;
height: 25px;
}
.label {
margin-left: 10px;
width: 50px;
height: 25px;
font-weight: bold;
}
&lt;/style&gt;&lt;/head&gt; 

&lt;body class="yui-skin-sam"&gt;
&lt;span class="label"&gt;First Name:&lt;/span&gt;&lt;input type="text" name="firstName" id="firstName" class="textbox" /&gt;&lt;br /&gt;
&lt;span class="label"&gt;Last Name:&lt;/span&gt;&lt;input type="text" name="lastName" id="lastName" class="textbox" /&gt;&lt;br /&gt;
&lt;textarea name="texteditor" id="texteditor"&gt;
Test within TextArea.
&lt;/textarea&gt; 

&lt;script&gt;
var toolbar = {
height: '200px',
width: '420px',
toolbar: {
titlebar: 'TechRepublic.com Editor',
collapse: true,
buttons: [
{ group: 'textstyle', label: 'Font Style',
buttons: [
{ type: 'push', label: 'Bold', value: 'bold' },
{ type: 'push', label: 'Italic', value: 'italic' },
{ type: 'push', label: 'Underline', value: 'underline' },
{ type: 'separator' },
{ type: 'select', label: 'Arial', value: 'fontname', disabled: true,
menu: [
{ text: 'Arial', checked: true },
{ text: 'Arial Black' },
{ text: 'Comic Sans MS' },
{ text: 'Courier New' },
{ text: 'Lucida Console' },
{ text: 'Tahoma' },
{ text: 'Times New Roman' },
{ text: 'Trebuchet MS' },
{ text: 'Verdana' }
] },
{ type: 'spin', label: '13', value: 'fontsize', range: [ 9, 75 ], disabled: true },
{ type: 'separator' },
{ type: 'color', label: 'Font Color', value: 'forecolor', disabled: true },
{ type: 'color', label: 'Background Color', value: 'backcolor', disabled: true }
] } ] } }; 

myEditor = new YAHOO.widget.Editor('texteditor', toolbar);
myEditor.render();
&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;</code></pre>
<pre></pre>
<p>It is worth noting that the text is formatted using standard HTML to format the text within the Rich Text Editor, so bold text uses the HTML strong element; the font element is used for font styling, and so forth.</p>
<p><strong>An improved interface</strong></p>
<p>I have been a big fan of the YUI Library since I first discovered it more than a year ago. It allows developers to build powerful Web interfaces using code that has been fully tested for proper functionality. The Rich Text Editor is just one example of the power controls available in the YUI Library.</p>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/01/14/great-user-interface-with-yui-yahoo-user-interface-library/feed/</wfw:commentRss>
		<slash:comments>383</slash:comments>
		</item>
		<item>
		<title>7 Deadly Sins of AJAX application development</title>
		<link>http://rochakchauhan.com/blog/2008/01/09/7-deadly-sins-of-ajax-application-development/</link>
		<comments>http://rochakchauhan.com/blog/2008/01/09/7-deadly-sins-of-ajax-application-development/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 09:12:39 +0000</pubDate>
		<dc:creator>rochakchauhan</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Sins in AJAX]]></category>

		<guid isPermaLink="false">http://rochakchauhan.com/blog/2008/01/09/7-deadly-sins-of-ajax-application-development/</guid>
		<description><![CDATA[At first blush, those pitfalls may seem avoidable through sheer common sense, and to a degree, that&#8217;s true. But AJAX apps bristle with architectural differences from its DHTML forebears. No matter how much common sense you bring to the application development task, it is still good to learn from the mistakes of those who have &#8230; <a class="read-excerpt" href="http://rochakchauhan.com/blog/2008/01/09/7-deadly-sins-of-ajax-application-development/">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At first blush, those pitfalls may seem avoidable through sheer common sense, and to a degree, that&#8217;s true. But AJAX apps bristle with architectural differences from its DHTML forebears. No matter how much common sense you bring to the application development task, it is still good to learn from the mistakes of those who have preceded you. We&#8217;ll call these mistakes our Seven Deadly Sins, but they are by no means the whole story.</p>
<p>In fact, before you commit any of the deadly sins, you&#8217;re much more likely to commit a few lesser sins. So we&#8217;ll start with those. These are the ones that make everybody&#8217;s list. These mistakes are so common that you can find most of them in a simple Google search.</p>
<p><strong>The Seven Lesser Sins </strong></p>
<p><strong>1.</strong><strong>Misuse of the Back Button &#8211;</strong> This is the one mistake everyone&#8217;s going to have on their list. The Back Button has become a user expectation in many kinds of Web apps. Many new AJAX developers drop a Back Button into their AJAX app and promptly break it, for several reasons. First, JavaScript isn&#8217;t the friendliest language for it; and second, AJAX design requires a new way of thinking.<br />
It&#8217;s not always readily apparent to a new AJAX developer that &#8220;Back&#8221; isn&#8217;t best. &#8220;Back&#8221; is a feature you&#8217;ll need at a page-update point or more often, when you want an event-specific &#8220;Undo&#8221; feature. Think this through before you code, or you&#8217;ll end up doing it twice.<br />
<strong>2.</strong><strong>Not telling the user what&#8217;s happening &#8211;</strong> Part of how AJAX works is that it doesn&#8217;t use conventional Web UI page loading. So you need to explicitly design some visual cue to let the user know what&#8217;s happening.<br />
<strong>3.</strong><strong>Neglecting Links &#8212; </strong>Here&#8217;s another AJAX standard blunder: neglecting URLs that can be cut-and-pasted for uses outside the app. How many times have we grabbed a URL and e-mailed it to someone? When you&#8217;re using AJAX, the only way to provide your user with useful cut-and-pasteable URLs is to manually provide them. Why? Because in an AJAX app, <em>the server is not providing the page</em>: JavaScript is dynamically generating it! Don&#8217;t neglect your users&#8217; potential interest in this all-too-common feature of Web apps. Take pains to provide URLs, since the server won&#8217;t.<br />
<strong>4.</strong><strong>Trading content control for page control &#8212; </strong>Breaking with the traditional client-server interaction is a wonderful gift, if you&#8217;re seeking dynamic content control. But it&#8217;s also a curse: rewriting highly-specific areas of a page to fine-tune a user&#8217;s interactive experience does indeed give you fine control, but this pulls you away from the big picture.<br />
All too often, we focus on processing some sector of the page and forget that the page isn&#8217;t going to be refreshed by the server. This can lead to a fragmented page, a confusing user experience, wherein the screen they&#8217;re looking at can be out-of-date with itself! Take care to keep your attention on the entire page; make sure that any dynamic content event evokes changes everywhere the user will need to see them.<br />
<strong>5.</strong><strong>Killing spiders &#8211;</strong> The upside of AJAX is the truckloads of text you can feed a page without a reload. And the downside of AJAX is the truckloads of text you can feed a page without a reload. If the app is intended to be search-engine-friendly &#8212; well, you can imagine. Whatever is happening in the guts of the page, be sure to plant plenty of stable text up top, for the spiders to play with.<br />
<strong>6.</strong><strong>Producing unspeakable text &#8212; </strong>AJAX doesn&#8217;t support many character sets. This isn&#8217;t a life-or-death limitation, but forgetting it can create real problems. Your basic character set is UTF-8. Don&#8217;t forget to properly encode whatever JavaScript is sending, and remember to set the server-side character set for content.<br />
<strong>7.</strong><strong>Not letting the JavaScript-challenged user know what&#8217;s going on.</strong> There are browsers out there that don&#8217;t have JavaScript enabled, and users out there who don&#8217;t understand immediately what that means. Be sure to clue them in.</p>
<p>Truth to tell, most of those are common-sense issues. The real killers are less obvious.</p>
<p><strong>The Seven Deadly AJAX Sins</strong></p>
<p><strong>1.</strong><strong>Letting memory leak &#8211;</strong> Anyone who has worked in development for very long understands cyclic references and the danger they pose to memory management. JavaScript, the workhorse of AJAX, is a memory-managed language. What that means is that JavaScript has built-in garbage collection, so that it sniffs out variables no longer accessible by any reference path and de-allocates the memory they&#8217;re using.<br />
That&#8217;s fine as a general principle; but you can&#8217;t count on it to keep your memory usage optimised, because of those cyclic references, when a Model-layer object is referencing a View element and vice versa. Nulling the object nulls the element, in principle, but if there&#8217;s a backward reference from element to object, then the garbage collector won&#8217;t touch the object.<br />
Now, here&#8217;s where it gets tricky: in the Document Object Model, any DOM node that&#8217;s part of the document tree may be referenced by virtue of its presence in the tree, whether it&#8217;s explicitly referenced by another object or not! So any object you tag for garbage collection that is back-referenced by a DOM node must be explicitly nulled in that direction, or its memory remains allocated!<br />
<strong>2.</strong><strong>Not knowing what &#8220;asynchronous&#8221; means &#8211;</strong> Asynchrony can be really unsettling to a user unaccustomed to it, and this can be ironic, since the Web apps you&#8217;ll design and build for those users wouldn&#8217;t find them at all unsettling <em>if they were desktop apps</em>. This is a crucial design point! Most Web apps are functionally very similar to their desktop counterparts. But in a Web app, there&#8217;s a looming characteristic that sets it apart: <em>user expectations</em>.<br />
Users carry a very different set of biases and anticipations into a session with a Web browser that they don&#8217;t tote into a desktop app exchange. So while it may be incredibly cool and efficient to have myriad responses trotting back to the page from the server, and the page revising itself in the meantime, it can be deeply disorienting to the user to see this constant barrage of change. For this reason, you need to apply two rules, and consider them with <em>every</em> change that comes into the user&#8217;s field-of-vision: If the update is not immediately essential to the user, make the update unobtrusive, so that it does not distract; and if the update is vital to the user&#8217;s interaction with the app, make its presence on the page clear and prominent.<br />
<strong>3.</strong><strong>Keeping the server in the dark &#8211;</strong> The decoupling of client and server has a huge downside that seldom occurs to us up-front. Server-side apps know all and see all: every exception, every reload, every event can be watched and recorded, and of course the server knows exactly what the client looks like, because the server basically wrote whatever&#8217;s on the screen.<br />
In an AJAX app, this isn&#8217;t the case. Stuff happens, and it happens independently of the server, and this means that there can be problems on the client side that the server won&#8217;t immediately be privy to. Capture and log events and exceptions on the client side, in a place and manner that enables the server to home in on problems that require its intervention as soon as possible.<br />
<strong>4.</strong><strong>Getting lazy with GET &#8211;</strong> GET is for retrieving data; POST is for setting it. Don&#8217;t use GET when you know you shouldn&#8217;t, even if you think it will do no harm. GET operations change state, and links that change state are confusing to users; most are accustomed to links as guides to navigation, not function.<br />
<strong>5.</strong><strong>Not accounting for data type &#8211;</strong>JavaScript, isn&#8217;t part of the .NET Framework. While this may draw tears of sorrow, it presents us with an example of a problem you&#8217;ll eventually run into: making certain that JavaScript understands the data types of the platform it&#8217;s running on, and vice versa, be it .NET or otherwise. There are various converters available to you, and you should seek them out. The Ajax.NET Pro library, for instance, offers converters that can convert objects between .NET and JavaScript Object Notation.<br />
<strong>6.</strong><strong>Some apps just don&#8217;t know when to shut up &#8211;</strong> Dynamic generation of content, with no dependency on page-reload, can be disastrous if left open-ended. How many Web pages have you seen that were longer than the Congressional Record? If Web pages that go on forever are a confusing nightmare for users, just imagine how they&#8217;ll feel about an <em>application</em> that goes on and on and on. Make your Web app pages dynamic, but build in some practical limits.<br />
<strong>7.</strong><strong>Keep your JavaScript out of your DOM &#8212; </strong>Remember that AJAX is built on the Model-View-Controller structure. Take this seriously. JavaScript belongs in the Model layer, DOM in the View layer, and the Controller is their marriage counselor. Make sure your Web document has the same content independent of JavaScript (this helps with the JavaScript-disabled user) &#8212; except when the content itself is only meaningful or practical if the user can use JavaScript. In that instance, create that content with JavaScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://rochakchauhan.com/blog/2008/01/09/7-deadly-sins-of-ajax-application-development/feed/</wfw:commentRss>
		<slash:comments>343</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
