General

What is WebJS ?
WebJS is a Web framework for Java, based on JavaScript and jQuery on both server and client-side.
Why JavaScript and jQuery ?
JavaScript is a widely used language, required on client-side by modern applications, frequently coupled with jQuery. They are really efficient for manipulating Web page, so why not use them both on client and server side ? Why use another complicated technology ?

Configuration

How do I use WebJS in my WAR project ?
Use a Servlet 3.0.1 compatible server and maven as described here.
How can I customize warnings, errors, etc... ?
All client errors, warnings, etc... shown in popups and in WebJS console are using Messages JavaScript namespace. You can disable default messages management by setting these 2 properties in your WEB-INF/webjs.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<webjs xmlns="http://webjs.dz.fr/config">
    <configuration>
        
        [...]
        
        <clientBehavior>
            <!-- If enabled, everything logged on client-side is stored in the console -->
            <console enabled="false" />
            
            <!-- If enabled, every message with a popup enabled type is displayed in a popup -->
            <popup enabled="false" />
        </clientBehavior>
        
        [...]
        
    </configuration>
</webjs>
You can then customize messages behavior using the events described in WebJS.Events namespace.
How can I customize the loading div ?
On every Ajax request, a loading div overrides all the page to avoid user actions during the action. If you want to customize this behavior, you can disable it using this property in your WEB-INF/webjs.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<webjs xmlns="http://webjs.dz.fr/config">
    <configuration>
        
        [...]
        
        <clientBehavior>
            <!-- If enabled, every ajax query displays a waiting div -->
            <loading enabled="false" />
        </clientBehavior>
        
        [...]
        
    </configuration>
</webjs>
You can then customize loading behavior using the events described in WebJS.Events namespace.
How can I customize the theme ?
You can customize the theme using this property in your WEB-INF/webjs.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<webjs xmlns="http://webjs.dz.fr/config">
    <configuration>
        
        [...]
        
        <clientBehavior>
            <!-- Default theme -->
            <defaultTheme>ui-darkness</defaultTheme>
        </clientBehavior>
        
        [...]
        
    </configuration>
</webjs>

Coding

What basic rules do I need to know to become a WebJS master ?
You need to keep in mind that when WebJS receives an HTTP request, it works in 4 simple steps :
  1. Find the corresponding @WebPage class using the path attribute
  2. Execute the asked @WebPart method (if not precised, the @Default one)
  3. Execute the server-side JavaScript corresponding to the script attribute of the @WebPage annotation. The execution context is the web page corresponding to the page attribute.
  4. Filter the HTML result user the web part @Selector annotation using jQuery.
And you are now a WebJS killer dev !
How do I show WebJS console ?
Every actions, every exceptions or errors are logged into the WebJS console. It is not showed by default, but you can open it using this little code snippet on client-side :
Messages.showConsole();