• Home
  • Download
  • Manual
    • Installation
    • Static Site
    • patTemplate
    • patForms
    • Users
    • Content Modules
    • Class Overriding
    • AJAX and JavaScript
      • Class loader
    • Tunning Features
    • REST Service
    • Framework
      • Directory Layout
      • Class Loader
    • 3rd party libraries
  • About
    • Ohloh
    • Imprint
    • License
    • Related Blogs
  • Developer
    • To Do
    • Changelog
    • Source
    • Demo Site

Class Loader

A very basic feature is the dynamic class loader. This implements sort of PHP's "require_once" for JavaScript classes.

As always you have to solve a hen-egg-problem. In this case the hen is the class loader, which can lay egg, respecive load classes. Still, you need to load the class loader first manually to load classes dynamically.

<script type="text/javascript" src="/js/?cs=b896f7319f"></script>
<script type="text/javascript" src="/js//WB/prototype"></script>
<script type="text/javascript" src="/js//WB"></script>

Simply load WB.js to gain basic functionality. Well, Wombat usually takes care that essential JavaScript files are loaded. Take a look at the HTML output, there should be something like the examples above.

The source can be found in resource/js/WB.js. This file provides some classes and static functions. On is WB.Class and the function WB.Class.load().

WB.Class.load("WB.Ajax");

Test Load WB.Ajax

WB.Class.load("WB.TestClass");
var foo = new WB.TestClass();
foo.test("This should complete the test");

Load test class

The examples above show how to include a JavaScript class the PHP way. The class loader makes sure, that each class is included only once. This avoids too much request and overriding code.