Introduction to JavaScript and WebObjects

First, let's revisit the Hello application created in Chapter 1, “A Web Objects Primer.” We are going to return the greeting in the form of a JavaScript pop-up window instead of a second page.

Dynamically Vended JavaScript Alert Panel

Duplicate the Hello project and rename it DynamicHello by following the instructions in Chapter 1.

Open Main.wo in WebObjects Builder. We are going to use an onLoad script to perform the JavaScript alert.

Add the following key to the Main page:

Name: onLoad

Type: String (java.lang.String)

As Variable: NO

Accessors: Only the Method returning the value

Now bind the onLoad key to the WOBody element. Because onLoad isn't a defined binding for WOBody (that is, you wouldn't see it ...

Get WebObjects® Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.