/**
* Creates a new HTTPDemo object
*/
public HTTPDemo() {
_fetchMenuItem = new MenuItem(new StringProvider("Fetch"), 0x230010, 0);
_fetchMenuItem.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
// Don't execute on a blank url.
if (_url.getText().length() > 0) {
if (!_connectionThread.isStarted()) {
fetchPage(_url.getText());
} else {
createNewFetch(_url.getText());
}
}
}
}));
_clearContent =
new MenuItem(new StringProvider("Clear Content"), 0x230020, 3);
_clearContent.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
_content.setText("<content>");
}
}));
_fetchHTTPSPage =
new MenuItem(new StringProvider("Fetch Sample HTTPS Page"),
0x230030, 2);
_fetchHTTPSPage.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
if (!_connectionThread.isStarted()) {
// Menu items are executed on the event thread, therefore we
// can edit the
// URL field in place.
_url.setText(SAMPLE_HTTPS_PAGE);
fetchPage(SAMPLE_HTTPS_PAGE);
} else {
createNewFetch(_url.getText());
}
}
}));
_wapStackOption =
new MenuItem(new StringProvider("Use Wap Stack"), 0x230040, 4);
_wapStackOption.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
_useWapStack = !_useWapStack; // Toggle the wap stack option
}
}));
_wapStackOptionScreen =
new MenuItem(new StringProvider("Wap Options"), 0x230050, 5);
_wapStackOptionScreen.setCommand(new Command(new CommandHandler() {
/**
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/