Application Techniques
Contents
Preface
- Purpose
- Audience
- Background
- Examples
- Organization
- Java
- General
Casting
- Casting an Object to an Integer
- Casting an Object to a String
- Casting an Object to a Date
Converting Data Types
- Converting a String to an int
- Converting an int to a String
- Converting a String to a Date
- Converting a Date to a String
Setting Colors
- Setting a default color choice in a list box
- Handling a user selection from the list box
- Handling red, green, and blue sliders
- Making the color change
Setting Fonts
- Setting a default font name, size, and style in list boxes
- Handling a user selection from the font name list box
- Handling a user selection from the font size list box
- Handling a user selection from the font style list box
- Making the font change
Using Hashtables
- Creating a Hashtable
- Adding data to a Hashtable
- Retrieving a value from a Hashtable with a key
- Removing selected data from a Hashtable
- Clearing an entire Hashtable
Using Reflection
- Getting the name of a selected class
- Getting a class
- Getting the class methods
- Getting the class properties
- Getting the constructors
- Displaying the class methods, properties, and constructors
- Getting a superclass and displaying its name
Using Multidimensional Arrays
- Using an array of labels to contain display characters
- Setting the array element specified by the user
- Obtaining array values to check for a winning pattern
- Using a timer before generating a move
Validating with String Pattern Matching
- Walking through the overall matching process
- Comparing strings by length
- Comparing strings character by character
- Checking for uppercase and lowercase characters
- Checking for letter characters
- Checking for digit characters
- Checking for letter or digit characters
- Checking for the any-character wildcard
- Checking for a character match
Using Utility-Class Methods
- Creating a utility class
- Calling a method of the utility class
Using JavaBeans on Forms
- Adding a JavaBean to a form
- Modifying the properties of a JavaBean
- Displaying the selected date in a text field
- Data source objects
- Oracle access
- General
Using an executeSQL DSO
- Invoking the DSO and passing the SQL statement
- Executing the SQL on the database
Using a setResultSet DSO
- Objects and data flow
- Invoking the DSO and displaying data
- Code for the retrieveOrders() method
- Instantiating and setting the Java ResultSet
- Code for the invokeQuery event
- Implementing the Java ResultSet
- Code for the executeQuery() method
- Code for the next() method
Using a setDataSource DSO
- Objects and data flow
- Invoking the DSO
- Instantiating and setting the AgiDataSource
- Implementing AgiDataSource
- Implementing AgiBandDescriptor
- Extending AgoDataUpdateRequest
- Extending AgoDataUpdateRow
- Implementing AgiTransactionHandle
Importing a Comma-Delimited File into a Database Table
- Objects used in this technique
- Data flow
- Invoking the business object
- Invoking the data source object
- Importing the file
Exporting a Database Table to a Formatted File
- Objects used in this technique
- Data flow
- Invoking the servlet
- Invoking the data source object
- Returning the generated file
- Generating the file
Publishing Data Between Databases
- Objects used in this technique
- Data flow
- Passing data to the invoked business object
- Invoking the data source object
- Copying the data to the destination table
Developing a DSO for Use by Multiple Clients
- The data source object (dsoEditTableData)
- Objects used in this technique
- Calling the data source object
- Data flow
- Coding the data source object
- Implementing the AgiDataSource
- JDBCBandDescriptor
- JDBCDataUpdateRequest
- JDBCDataUpdateRow
- JDBCTransactionHandle
Accessing Blobs in Oracle
Accessing Clobs in Oracle
Calling an Oracle PLSQL Function Returning a Cursor
Handling Data Concurrency Errors
- Catching concurrency errors when updating changes
- Refreshing the screen with the latest data
Dynamically Binding Controls to Data
- Creating a control that accesses an independent data set
- Binding the property of a text field to a data source property
- Invoking the data source object
- Basic techniques
- Page flow and state management
- JavaScript
- HTML-based views
- Page beans
- Security
- JavaServer Pages
- Miscellaneous
Altering Page Controls
Doing Basic Data Navigation and Manipulation
Manipulating Lists
- Adjusting an empty list's size
- Moving items to the selected list
- Moving items to the deselected list
- Displaying selected items as text in a dialog box
Programming Page Events
Setting Response Headers, Form Tags, and Body Tags
Controlling Page Flow Using the Session Object
- Walking through the flow scenario
- Setting a session value
- Removing a session value
- Redirecting an HTTP request to another URL
- Redirecting an HTTP request upon page loading
- Redirecting the HTTP request to the first page
- Writing the error message servlet
Implementing Persistent Session-Level Failover
- Setting up the application
- Using the persistent state manager on a page
- Getting a reference to the object
- Reading and writing state data
- Implementing a store manager
- Editing the PersistentSession.props file
Sharing Page State Using the Session Object
Confirming a Request before Submitting it to the Server
- Adding JavaScript to a page
- Writing JavaScript for a button click
- Handling a submit request
Displaying Hover-Sensitive Images
- Writing hover code in line
- Writing hover code in a function
Dynamically Changing Styles
Implementing Tabs with JavaScript and DHTML
- Setting up
- Coding the tabs
Manipulating Documents and Windows with JavaScript
- Switching the document in a window
- Opening a new window
- Writing to the document in a window
- Passing information between windows
Manipulating Page Controls with JavaScript
- Coding it in plain HTML and JavaScript
- Coding it in SilverStream
Manipulating Strings with JavaScript
- Replacing strings
- Inserting strings
- Extracting strings
Opening and Closing Windows Using JavaScript
- Getting user-specified window features
- Using openWindow(url, window, features)
- Using openWindow(url, window, features, params)
- Using openWindow(url, window, features, query, orderby)
- Applying request information to the page in the window
- Closing the window
Recognizing your Browser
- Approach 1: Getting the appName and appVersion
- Approach 2: Getting the userAgent
Using the AgpScriptHelper Object
Validating Control Values
Validating Data Entry with JavaScript
- Coding it in plain HTML and JavaScript
- Coding it in SilverStream
Building a Master/Detail Page
- Specifying the master Orders data view
- Specifying the Order Details data view
- Specifying the total fields
- Navigating to the first record
- Navigating to the previous record
- Navigating to the next record
- Navigating to the last record
- Initiating find mode
- Completing the find request
- Performing the Click event to bring up details
Building a Matrix Style Report Using an AgoVectorRowCursor
- Declaring variables
- Creating the AgoVectorRowCursor
- Retrieving the data
Displaying Images in a Data View
- Setting up
- Associating a database with the page
- Creating the data view control
- Creating the label control
- Setting the label to raw HTML mode
- Testing the page
Updating Rows in a View Using a Dialog
- Binding controls in separate pages to the same database
- Invoking the update dialog
- Updating rows from the update dialog
Using Page Beans
Forcing Access through HTTPS
Using JavaServer Pages with SilverStream
- Setting up
- Coding the JSP pages
- Source for date.jsp
- Source for include.jsp
- Coding the JavaBeans components
- Source for JspCalendar.java
- Source for JspSQL.java
- Coding the deployment XML file
- Creating the batch file to deploy the JAR
- Deploying and testing the JSP pages
Broadcasting Events between Subpages
- Adding code to the parent page
- Adding code to the list page
- Adding code to the details page
- Defining the listener interface
- Defining the event utility class
Graphing Data Using a Servlet
- Loading the image from the servlet
- Importing the Acme classes into the servlet
- Coding the service method on the servlet
- Creating the graph
Graphing Data Using a Servlet that Calls a JavaBean
- Loading the image from the servlet
- Importing the Acme and KLG classes into the servlet
- Instantiating the JavaBean
- Coding the service method on the servlet
- Creating the graph
Sending E-Mail Asynchronously
Using an Invisible Tab Control to Create a Multi-Page Look
- Setting up the page
- Adding code to the Back button
- Adding code to the Next button
Using File Attachments on Pages
- General techniques for controls
- Version 3 Swing-based controls
- Version 2 AWT-based controls
- Java-based views
- Dialogs and subforms
- Menus
- Keystrokes and drawing
- External Java clients
Validating Data Entry in the Form and Its Controls
- Validation for individual fields
- Finishing the validation process for controls
- Global validation for the form
Implementing Context-Sensitive Help
- Changing the help information for a control
- Implementing a custom help display
Using File Attachments on Forms
- Uploading a new file into the database
- Downloading content from the database as a file
- Saving modified content to the database
Using Timers
- Starting the timer control
- Stopping the timer control
Obtaining the Control with Focus
- Basic steps for adding a focus listener
- Adding an interface
- Adding the listener
- Processing the focus event and getting the control name
- Removing the listener
Instantiating Bound Controls Dynamically
- Changing the data source for an AgcData control
- Retrieving the data
- Adding controls dynamically
- Deleting controls
Extending a SilverStream Control
- Creating a subclassed control
- Adding the constructor
- Building the JAR file
- Adding the control to a form
- Responding to mouse events
Adding a Listener to a Form Control
- Adding a listener
Implementing a Nested Layout
- Creating a custom layout manager
Implementing a Custom Insert Image Dialog for the HTML Edit Control
- Hiding and showing controls
- Using the FileAttachment control to get an image file from disk
- Passing the image information back to the HTMLEditControl
Swing Sampler: Using an Assortment of Swing Controls
- Creating the controls
- Creating the split pane and its contents
- Creating the toolbar
- Getting a button image
- Initializing and adding a button
- Finishing the layout
- Loading data in the AgcJTable control
- Opening a file and displaying it in the editor pane
- Reading the file
Using the JCheckBox Control
- Getting the control state
Using the JList Control
- Getting the string and int values of a selected row
Using the JProgressBar Control
- Specifying the control's size and position
- Selecting colors
- Using the timer
- Responding to changes in the progress bar's value
Using the JRadioButton Control
- Getting the control state
Using the JSlider Control
- Initializing form controls with slider settings
- Changing the slider's appearance and parameters
- Setting the slider value
- Implementing the stateChanged event
- Executing a SQL statement
Using the JSpinner Control
- Getting the value of a spinner control
- Decrementing or incrementing the spinner value
Using the JTable Control
- Importing the Swing table package
- Initializing form controls with table defaults
- Loading the table with data
- Getting values from controls and changing the table appearance
- Changing a color
- Getting a slider value
- Getting a checkbox value
- Responding to the combo box
- Adding the column sorting feature
- Allowing column reordering
Using the JTextArea Control
- Getting and setting a string in a text area
- Appending a string to a string in a text area
- Getting and displaying selected text in a dialog box
Using the JTextField Control
- Getting and setting a string value for a text field
- Getting and setting an integer value for a text field
- Getting and setting a date value for a text field
Programming Swing Tree Controls
- Importing the Swing tree package
- treeLoaded control: populating nodes from static values during setup
- treeExpandable control: populating nodes on demand
- Adding a TreeWillExpandListener
- Allowing children for the first-level values
- Populating the hashtable with data for the child nodes
- Adding child nodes in the treeWillExpand event
- treeRowCursor control: populating a tree from database tables
- Using loadFromRowCursor()
- Customizing the root node
- Populating the second level from an AgcData control
Specifying a Pluggable Look and Feel
- Getting the look and feel settings for the form
- Changing the look and feel of the form
Using Choice Controls and Combo Boxes
- Getting the value of a selected row in a choice control
- Getting the value of a selected row in a combo box
Using Several Images from a Single File on an Image Button
- Specifying a portion of an image in the Property Inspector
- Dynamically changing image properties of an image button
Using Text Buttons
- Changing a text button label programmatically
- Simulating a clicked event on a text button
Using Tree Controls
- Creating and loading the tree control
- Expanding a node on the tree control
- Collapsing a node on the tree control
- Getting and setting text on a selected node
- Adding a node to the tree control
- Removing a node from the tree control
- Finding a node on the tree control
- Getting node and parent data from a selected node
Manipulating Views
- Setting a default department in the choice control
- Handling a user selection from the choice control
- Handling the rate percentage slider
- Making the salary rate change
- Saving the changes
Dynamically Formatting Data in Views
- Adding a data control to a form
- Defining column formats for a band format
- Adding band formats to a view format
- Initializing a view with dynamic data and a view format
Adding and Deleting Rows with Row Cursors
- Associating a vector and a row cursor
- Adding a row to a vector
- Deleting a row from a vector
- Updating the view
Constructing a Hierarchical View Using AgoTreeDataManager
- How this technique is organized
- Creating an AgcView with hierarchical columns
- Creating a multinode AgoTreeDataManager
Displaying Dialogs
- Displaying a message dialog
- Displaying an OK/Cancel dialog
- Displaying a Yes/No dialog
- Displaying a Yes/No/Cancel dialog
- Displaying an error message dialog
- Displaying a form for editing data in a dialog
Opening Subforms
- Opening various kinds of subforms from a parent form
- Firing a custom event back to the parent form
- Directly manipulating controls on the parent form
Using Subforms to Share Globals among Forms
- Creating a subform to contain globals
- Getting a reference to a single subfrmCircle instance
- Accessing a single subfrmCircle instance from any subfrmGlobals instance
- Launching subfrmGlobals forms
Basic Code for a MenuBar and Popup Menu
- Calling the methods in the FormActivate event
- Building the menubar
- Building the popup menu
- Displaying the popup menu
- Responding to standard menu selections
- Responding to check box menu selections
Building Menus and Generating Menu Code
- Creating a tree menu
- Creating a popup menu for editing the tree menu
- Implementing the popup menu's operations
- Obtaining generated code for the formActivate() and menuItemSelected() methods
Building a Text Editor with Menus
- Creating menus
- Displaying a popup menu for browser applications
- Handling menu item selections
- Performing the Copy clipboard operation
- Performing the Cut clipboard operation
- Perfoming the Paste clipboard operation
Processing Keystrokes
- Getting the pressed key and modifiers
- Sorting rows by column entry
Creating Animations
- Setting up images and user-input controls
- Implementing animation with the switch statement
Accessing Data from External Java Clients
- Setting up
- Coding the client
- Running the client
Providing Data to JTables in External Java Clients
- Setting up
- Coding the client
- Running the client
Calling EJB Session Beans from External Java Clients
- Setting up
- Coding the client
- Running the client
Invoking Business Objects from External Java Clients
- Setting up
- Coding the client
- Running the client
Administering the Server from External Java Clients
- Setting up
- Coding the client
- Running the client
Handling User Authentication from External Java Clients
- Designing your login handler
- Coding a basic login handler
- How it works
- Coding a graphical login handler
- How it works
Using EJB Environment Properties
- Using environment properties
- Specifying environment variables in the deployment descriptor
- Looking up the property at runtime
Using EJB Resource References
- Specifying resource references in the deployment descriptor
- Using the JAR Designer to map resources
- Using SilverCmd to map the resources
- Looking up the resource at runtime
- Resource scoping
Using EJB Bean References
- Specifying bean references in the deployment descriptor
- How the SBBankATM finds bean references
Using EJB Session Beans to Control an Entity Bean's Transaction Scope
- Writing a session bean with bean-demarcated transactions
- Using the Java Transaction API
- A closer look at the BankDemo's transactional methods
- Making sure the entity beans use the correct transaction context
- Specifying session bean transaction management type
Writing EJB Expression-Style Finder Methods
- Writing an expression-based finder method
- Specifying the expression using the JAR Designer
- Specifying the expression using the SilverCmd DeployEJB XML file
Writing EJB Method-Style Finder Methods
- Writing method-style finders
- Specifying method-style finders using the JAR Designer
- Specifying method-style finders in the SilverCmd DeployEJB XML file
Writing EJB Applications Using Accessors
- How accessor components work
- How to write accessor applications
- Writing the entity bean
- Writing the session bean
- Writing the accessor class
- Writing the accessor client
- Writing a form or page that uses accessors
- Where to get more information
- General
- Servlets
Serializing and Deserializing Business Objects
- Objects in this example
- Using ObjectInputStream to serialize data
- Using AgoObjectInputStream to deserialize data
- A page that calls the objects
Using a Session Object to Share Information
- Getting the session id from an invoked object
- Passing session values to the invoked object
- Setting the session values on the subform
- Handling requests from multiple callers
Using an Invoked Object to Cache Data
- Using the serverStarted event to cache data
- Invoking the object and managing the result
- Coding the handlePageException
- Resetting the last-modified date
- Using the invoked object to determine if data is current
- Setting the data modified flag
- Getting and storing the data in the Vector variable
Developing a Servlet that Uses Caching
- How this example works
- Class member variables
- Caching data when the server is started
- Determining if session data has been updated
- Managing the cached data in the servlet
Using a Servlet to Build an HTML Page
- Using the HTML helper object in the servlet
- Creating helper methods for HTML formatting
Using a Servlet to Retrieve Data
- Creating a business object with a servlet trigger
- Adding a dataset to the business object
- Coding the servlet to query and return the result
Enumerating Server Objects
- Getting a server
- Enumerating databases on the server
- Enumerating other objects on the server
Enumerating Security Providers, Users, and Groups
- Enumerating security providers
- Enumerating provider servers
- Enumerating groups
- Enumerating users in a group
Identifying Users
- Getting the name of the current user
- Determining if the current user belongs to a specified group
Customizing the Logging Class
- Creating a custom logging class
- An example
- Using the example
Locking Down an Application
Locking Down a Server
Locking Down a Cluster
Copyright © 2000, SilverStream Software, Inc. All rights
reserved.