BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-01-2010, 10:46 PM   #1 (permalink)
New Member
 
Join Date: Oct 2010
Model: 9650
PIN: N/A
Carrier: Developer
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Error Javascript has turned off ?

Please Login to Remove!

Hi all.
I run the code sample that connect to a IP Camera ( IP Address : 10.0.0.83 ) and get content that is responded to BlackBerry Device. But I have encouraged a error "Your browser has javascript turned off, for the user interface work, you must enable javascript in your browser and reload/refresh this page".
I have check on "Support Javascript", " Allow Javascript Pop-ups" in Browser configuration. And check on "Enable javascript location support" in General properties but It has no effect.

This is my code :
Code:
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.UiApplication;
import java.io.*;
import javax.microedition.io.*;
public class NetworkSample extends UiApplication 
{
	public static void main(String[] args) 
	{
		NetworkSample app = new NetworkSample();
		app.enterEventDispatcher();
	}
	public NetworkSample() 
	{
		new HTTPConnectionSetup();
	}
}
final class HTTPConnectionSetup 
{
	public HTTPConnectionSetup()
	{
		Thread t = new Thread(new Runnable()
		{
			public void run() 
			{
				Connection c = null;
				try 
				{
					c = Connector.open("h t t p: //10.0.0.83;interface=wifi"); 
/*I must use "h t t p" replace "http" because I can not insert hyperlink in my post*/
				} 
				catch (IOException e) 
				{
					e.printStackTrace();
				}
			
				
				if(c != null)
				{
					displayContent(c);
				}
			}
		});
		t.start();
	}
	private void displayContent(final Connection c) 
	{
		// When the connection thread completes, show the data from the web server
		UiApplication.getUiApplication().invokeLater(new Runnable()
		{
			public void run() 
			{
				UiApplication.getUiApplication().pushScreen(new HTTPOutputScreen(c));
			}
		});
	}
}
final class HTTPOutputScreen extends MainScreen 
{
	RichTextField _rtfOutput = new RichTextField();
	public HTTPOutputScreen(Connection conn)
	{
		// Create a container for the data, and put it on the screen
		_rtfOutput.setText("Retrieving data. Please wait...");
		add(_rtfOutput);
		// Retrieve the data from the web server, using the connection, on a
		// separate thread
		ContentReaderThread t = new ContentReaderThread(conn);
		t.start();
	}
	// After the data has been retrieved, display it
	public void showContents(final String result) 
	{
		UiApplication.getUiApplication().invokeLater(new Runnable() 
		{
			public void run() 
			{
				try 
				{
					Thread.currentThread();
					Thread.sleep(200);
				} 
				catch (InterruptedException e) 
				{
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				_rtfOutput.setText(result);
			}
		});
	}
	private final class ContentReaderThread extends Thread
	{
		private Connection _connection;
		ContentReaderThread(Connection conn)
		{
			_connection = conn;
		}
		public void run()
		{
			String result = "";
			OutputStream os = null;
			InputStream is = null;
			try
			{
				// Send HTTP GET to the server
				OutputConnection outputConn = (OutputConnection) _connection;
				//Open and return an output stream for a connection. 
				os = outputConn.openOutputStream(); 
				String getCommand = "GET " + "/" + "axis-cgi/jpg/image.cgi" + " HTTP/1.1\r\n\r\n";
				os.write(getCommand.getBytes());
				os.flush();
				// Get InputConnection and read the server's response
				InputConnection inputConn = (InputConnection) _connection;
				is = inputConn.openInputStream();
				byte[] data = net.rim.device.api.io.IOUtilities.streamToBytes(is);
				result = new String(data);
				// is.close();
			}
			catch(Exception e)
			{
				result = "ERROR fetching content: " + e.toString();
			}
			finally
			{
				// Close OutputStream
				if(os != null)
				{
					try
					{
						os.close();
					}
					catch(IOException e)
					{
					}
				}
				// Close InputStream
				if(is != null)
				{
					try
					{
						is.close();
					}
					catch(IOException e)
					{
					}
				}
				// Close Connection
				try
				{
					_connection.close();
				}
				catch(IOException ioe)
				{
				}
			}
			// Show the response received from the web server, or an error message
			showContents(result);
		}
	}
}
Please Help me. Thank You !

Last edited by levanphong7887 : 11-01-2010 at 10:48 PM.
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.