Using service classes – PB Docs 126

Using service classes

You can use the methods available on the server component
to perform most server-side processing, including validation routines
and error handling. The Web DataWindow also provides another way
to add specialized processing.

To include server-side processing not available on the server
component, you can define one or more PowerBuilder custom class
user objects called service classes. These service classes are stored
in the same PBL or PBD as the DataWindow
object for the server component. They can be used whenever you want
to include additional processing on the server. For example, you
might want to use this technique to access the SQLPreview event so that
you can examine the syntax of a SQL statement
before it is committed to the database.

Where you implement the code

The service classes implement user-defined events with prescribed
signatures. These events correspond to standard DataWindow events.
In the user-defined events, you perform the processing and specify
return codes that tell the server component whether to cancel the
corresponding DataWindow event.

In the server component, you set a property or call a method
that identifies these user objects as service classes for the server
component.

How the code is called

Service classes work like this:

  1. Service classes are instantiated when the component is instantiated
    (if they are specified in an EAServer property)
    or when they are first registered by the SetServerServiceClasses
    method.

  2. An event occurs in the server component for the
    DataStore.

  3. The server component calls an event of the same
    name in each registered service class.

  4. If the service class implements the event, the event
    script is executed and a return code is sent back to the server
    component.

  5. If the event can be canceled via a return code and
    if any of the service classes returns that code, the event is canceled
    in the server component.

Figure 7-2: How service classes work

hdw03val.gif

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x