View Single Post
Old 09-20-2009, 06:49 PM   #3
jj12
New Member
 
Join Date: Sep 2009
Model: 7100T
PIN: N/A
Carrier: AT&T
Posts: 3
Thumbs up

Thank you for your help. But it seems nothing is being displayed after implementing your code. I must be doing something incorrect. Here's my connection class.

Code:
public class LocalHttpConn implements HttpConnection {
	private InputStream is = null;

	public LocalHttpConn(String html){
		try 
		{
			is = new ByteArrayInputStream(html.getBytes("UTF-8"));
		}
		catch(Exception e) {}
	}
	
	public LocalHttpConn(byte[] bits){
		is = new ByteArrayInputStream(bits);
	}
	
	public long getDate() throws IOException {
		return 0;
	}

	public long getExpiration() throws IOException {
		return 0;
	}

	public String getFile() {
		return null;
	}

	public String getHeaderField(String name) throws IOException {
		return null;
	}

	public String getHeaderField(int n) throws IOException {
		return null;
	}

	public long getHeaderFieldDate(String name, long def)
			throws IOException {
		return 0;
	}

	public int getHeaderFieldInt(String name, int def) throws IOException {
		return 0;
	}

	public String getHeaderFieldKey(int n) throws IOException {
		return null;
	}

	public String getHost() {
		return null;
	}

	public long getLastModified() throws IOException {
		return 0;
	}

	public int getPort() {
		return 0;
	}

	public String getProtocol() {
		return null;
	}

	public String getQuery() {
		return null;
	}

	public String getRef() {
		return null;
	}

	public String getRequestMethod() {
		return null;
	}

	public String getRequestProperty(String key) {
		return null;
	}

	public int getResponseCode() throws IOException {
		return 200;
	}

	public String getResponseMessage() throws IOException {
		return "OK";
	}

	public String getURL() {
		return "";
	}

	public void setRequestMethod(String method) throws IOException {
		return;
	}

	public void setRequestProperty(String key, String value)
			throws IOException {
		return;
	}

	public String getEncoding() {
		return "UTF-8";
	}

	public long getLength() {
		try {
			if (is != null )
				return is.available();
			else return 0;
		} catch (IOException e) {
		}
		return 0L;
	}

	public String getType() {
		return "text/html";
	}

	public DataInputStream openDataInputStream() throws IOException {
		return new DataInputStream(new ByteArrayInputStream(html.getBytes("UTF-8")));
	}

	public InputStream openInputStream() throws IOException {
		return is;
	}

	public void close() throws IOException {
		is.close();
		return;
	}

	public DataOutputStream openDataOutputStream() throws IOException {
		return null;
	}

	public OutputStream openOutputStream() throws IOException {
		return null;
	}

This is the main code

Code:
		try
		{
			_renderingSession = RenderingSession.getNewInstance();		
			HttpConnection connection1 = new LocalHttpConn("<html>test is a test</html>");
			BrowserContent browserContent = _renderingSession.getBrowserContent(connection1, null, null);
			
			Field field = browserContent.getDisplayableContent();		
			tab1Manager.add(field);
		}
There are no errors when I run it, but the browser displays nothing and I don't get any errors. Thanks for any help.
Offline   Reply With Quote