search the site  

Enter search terms:


subscribe to newsletters   WebReference.com logo   WebReference.com
dev the Web
tip archive  •   about  •   contact  •   jobs  •   sitemap


[next]

Widget Initialization Using JSON, HTML Custom Tags and XML Files

By Nicolas Erlijman

Digg This Add to del.icio.us

ASP 3.0/.NET Developer
Jupitermedia
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Component reuse is a must in development. Reuse reduces development time, avoids coding errors, visual components will look identical, and so on.... Code once, use anywhere! DHTML (Dynamic HyperText Markup Language) components or widgets are common nowadays; existing all over the Internet, from simple components such as calendars, toolbars, menus, etc., to more sophisticated frameworks like the Yahoo! UI Library. These components will behave in a different way according to some parameters or properties passed to them. This article will explain some ways to configure DHTML widgets, exposing its pros and cons, as well as programming techniques to avoid errors and speed up development time.

Properties Declaration

Imagine a list widget, a common widget used to display, for example, tabular customer data. This kind of widget is also called a table or grid widget. To place a widget in a page, this example will retrieve the widget properties, construct a widget object, then place it where the <div> reference is located. Properties (height, weight, number of rows, etc.) give shape to our widget, including its behavior (such as the onclick event, onmouseover event, etc). Throughout this article, various ways to perform this task will be detailed.

Old style declarations with global variables

Global variables are defined and used as widget property values. This kind of declaration should not be used in order to avoid global scope issues.

Parameters to the constructor object

The properties of the widget are defined as passing parameters to the list widget constructor. This approach solves the global scope issue but the number of properties to pass is fixed. If we want to add a new property to the widget, the method signature must be changed, and thus, if we have a lot of properties in our widget, the method signature will become unreadable. This option is not recommended if we want to have an extensible widget framework.

JSON (JavaScript Object Notation) as a properties object

This option uses JSON notation as a method to pass parameters, avoiding global scope issues, reducing the number of parameters and increasing code readability. This alternative is 100% pure JavaScript programming, as opposed to the use of custom tags and XML files (explained in following sections), which denotes simpler and easier notation.

JSON objects are passed to the list widget constructor and a list object is returned:


[next]

Recent Articles

WebReference.com site name
Perl Pragma Primer
Implement Drag and Drop in Your Web Apps: Part 2
How to Create an Ajax Autocomplete Text Field: Part 5
internet.com site name
SQL Server 2005 Express Edition - Part 22 - Upgrading from Microsoft SQL Server Desktop Engine (MSDE)
Vyatta: Downgrades that Pay Off
NetMotion Brings Cross-Network Support to Wireless VoIP




JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES