Dynamic elements, Figure 4-1, The files of a webobjects component – Apple WebObjects 5 User Manual
Page 39

C H A P T E R 4
HTML-Based Applications
A Programmer’s View of WebObjects
39
Apple Computer, Inc. January 2002
Figure 4-1
The files of a WebObjects component
Dynamic Elements
The template file in Figure 4-1 looks like any other HTML file except for the element
with the
<WEBOBJECT>
tag. In this example, this tag represents a dynamic element.
Dynamic elements are the basic building blocks of a WebObjects HTML application.
They link an application’s behavior with the HTML page shown in the Web
browser, and their contents are defined at runtime. A dynamic element appears in
the template as a
<WEBOBJECT>
tag with a corresponding
</WEBOBJECT>
closing tag.
<HTML>
<HEAD><TITLE>Greeting</TITLE></HEAD>
<BODY>
Hello <WEBOBJECT NAME=String1></WEBOBJECT>!
<P></BODY>
</HTML>
import com.webobjects.appserver.*;
public class Greeting extends WOComponent {
protected String userName;
public Greeting(WOContext context) {
super(context);
}
public String userName() {
return userName;
}
public void setUserName(String newUserName) {
userName = newUserName;
}
}
String1 : WOString {
value = userName;
}
Component (Greeting.wo)
Template (Greeting.html)
Code (Greeting.java)
Bindings (Greeting.wod)