Q. But nextapp.echo.Component has a validate method. Isnt that valiudation?
A. No. This method is called just before an Component is to be redrawn. It allows the Component to update (or validate) its internal state before its UI peer draws its representation. This allows it to optimize its rendering by delaying property updates until the final moment.
For example the Tachometer component does not redrawn its graphical representation until the validate() method is called. This allows a number of property updates to occur without incurring the overhead of drawing the graphical image over and over.
Q. How can I name my Components?
A. nextapp.echo.Component has a getIdentifier()/setIdentifier() property that you can use. This property is an Object you like. In most cases it would be a String object, but you can set it to any object at all.
Q. How can I change the apprearance of my Echo Application without making Java code changes?
A. EchoPoint has a 'CSS like' style sheet capability that allows appearance related properties to be set by changing external files. It is built on top of the Echo Style class which each Component can use.
You can find much more detailed information about style sheets here.
Q. How can I link to another web page or servlet?
A. If you want to redirect the browser out of an Echo application, you'll want to make the Application "suspend" itself and redirect to a different URI.
An example of this is available in the TestForEcho program, specifically in the file
"nextapp_echo/src/testforecho/java/nextapp/testforecho/TerminationTest.java".
The Echo application's state will be preserved (until the session times out) and if the user returns the Echo app's URI, the app will reappear in the same state it was in immediately prior to suspending.
EchoPoint has an ExitButton component that makes it easier to provide a link to an outside web URL. You would create it as follows :
ExitButton exitButton = new ExitButton(getEchoInstance(), "http://echopoint.sf.net", "Click here to go there");
exitButton.setExitMode(false);
This will code will suspend the application state until the user returns or the session timesout. If a user returns within the session timeout period then all the application state will be exactly as it was.
However if you had :
ExitButton exitButton = new ExitButton(getEchoInstance(), "http://echopoint.sf.net,", "Click here to go there");
exitButton.setExitMode(true);
Then the application will "exit" and all application state will be lost. If the user returns, the application will go throught the normal application startup routine.
Q. Can I customize the Echo application startup routine?
A. Yes you can. You can have a properties file with the same name and in the same directory as your derived EchoServer class that contains information about the application startup. So if you have a MyEchoServer class then you will need a MyEchoServer.properties file.
This file has a number of properties you can set that affect application startup. If you don't provide your own file, the a default one is provided in the Echo library called EchoServer.properties. It is detailed below.
The configurable properties are :
# Title of the window while the application is starting.
startupWindowTitle Application starting...
# Text that will be displayed in the center of the page while the application
# is starting. This text will only appear if a splash screen is not set.
startupWindowText [ please wait ]
# Text displayed when JavaScript is found not to be enabled on the client
# browser.
startupNoScriptErrorText Your browser either does not support JavaScript or JavaScript is disabled. This application requires a JavaScript-enabled browser to function properly.
# Delay time before starting application. A value of 0 (the default)
# indicates that the application should start immediately. A value of -1
# indicates that the application should wait until the splash scren HTML page
# invokes a JavaScript call to its parent frame's E_start() method. A positive
# integer value indicates the number of milleseconds to delay before starting.
startupDelay 0
# When set, the specified splash screen will be displayed when the application
# is starting.
#splashScreenUri splash.html
Using this properties file you could provide your own flashy startup screen that displays itself for a number of seconds.
Q. How can I put a message box up on the client browser? Can I do this in JavaScript?
A. EchoPoint has a ConfirmButton component that will "prompt" a user with an OK/Cancel question. If they press OK then the button action command will proceed and possibly raise an event on the server. If they press Cancel, then nothing will happen.
ConfirmButton confirmButton = new ConfirmButton("Do you want to delete this record?");
confirmButton.addActionListener(this);
Q. I have a button in my application but when I press it nothing happens?
A. The button must haver an ActionListener attached to it in order for it to raise and event. Echo has a speed optimisation so that buttons without ActionListeners attached never generate server side events. The reasoning behind this is that components with no one listening really dont have an thing interesting to say.
You can add an action listener like so :
button = new Button("My Connected Button");
button.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent event) {
// what now brown cow
button.setText("Pressed");
}
}
);