Documentation Archive Developer
Search
Table of Contents Previous Section 

Modifying Your Application's Code

You can modify your application's code just as you would in any other WebObjects application. In addition, there is an API for you to use specifically in Direct to Web applications. This consists of a set of methods defined in the D2WSession class.

You can use the following methods to return a specific component of a given class, given its name:

QueryPageInterface queryPageForEntityNamed (String entity);

ListPageInterface listPageForEntityNamed (String entity);

EditPageInterface editPageForEntityNamed (String entity);

InspectPageInterface inspectPageForEntityNamed (String entity);

There are three other methods provided by Direct to Web that you may want to override:

public Component defaultPage();

public Component defaultPageWithAssistant();

public Component transitionToWebAssistant();

These methods have the following functionality:

The following example shows how you can use these routines:

If you examine your application's Main component in WebObjects Builder, you'll notice that it contains a login form with text fields to enter a name and password, as well as two submit buttons.

 

The text fields are bound to the variables username and password (declared in Main.java ). The Login button is bound to session.defaultPage , and LoginWithWebAssistant is bound to session.defaultPageWithAssistant . You can override these methods to change the behavior of the buttons. For example, you may wish to add password-checking code (the default implementation doesn't have any). You also might want to begin with an entity that's not the first one in the list.

The following code in Session.java overrides session.defaultPage to change the default page to the query page for the Movie entity. It also changes the application's default timeout value.

 

Note: When you override defaultPage , this also takes care of the case where you use the LoginWithWebAssistant button, because the implementation of defaultPageWithAssistant calls defaultPage , which is now overridden by your code.

Table of Contents