• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Cocoa-Java] WebView and HTML string how to ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Cocoa-Java] WebView and HTML string how to ?


  • Subject: Re: [Cocoa-Java] WebView and HTML string how to ?
  • From: Andy Lee <email@hidden>
  • Date: Fri, 8 Jul 2005 03:39:10 -0400

On Jul 7, 2005, at 3:48 AM, Yvon Thoraval wrote:
Hey all,

i'm able to build and run a WebView from a Cocoa-Java app using an external URL by :
<code>
NSSelector selector=new NSSelector("takeStringURLFrom",new Class []{NSTextField.class});
NSApplication.sharedApplication().sendActionToTargetFromSender (selector,browserView,urlField);
</code>


but, in my case, i don't have any URL nor file because the html string is generated "on the fly" fram database dats.

someone said i have to use :
[[myWebView mainFrame] loadHTMLString:myHTMLString baseURL:[NSURL
fileURLWithPath:@"/path/to/base"];

but, at present time, i'm unable to transalate Obj-C code into java one.

There is no Java API for WebKit, so you won't be able to do a direct translation. It would be nice to simply say:


myWebView.mainFrame().loadHTMLStringBaseURL(myHTMLString, myBaseURL);

...but you can't.

I haven't used Cocoa Java myself, but I'm *guessing* you can achieve want you want using NSSelector. For example, you have a reference to an object you know is a WebView, and you want to send it a "mainFrame" message. It looks like you could do it like this:

Object myWebFrame = NSSelector.invoke("mainFrame", null, myWebView, null);

This part of the job is relatively simple because "mainFrame" doesn't take any arguments. The rest of the job should look familiar if you've used reflection in Java.

Note that the Objective-C expression

    [[myWebView mainFrame]
        loadHTMLString:myHTMLString
        baseURL:[NSURL fileURLWithPath:@"/path/to/base"]];

(which I've indented for clarity) contains three messages:

* A "mainFrame" message, which takes no arguments, is sent to myWebView, which is presumably an instance of WebView. It returns an instance of WebFrame.

* A "fileURLWithPath:" message (note the colon) is sent to the *class* NSURL, and returns an *instance* of NSURL.

* A "loadHTMLString:baseURL:" message is sent to the WebFrame that was obtained earlier. Note this message name has *two* colons. It takes two arguments, and its return type is void.

I haven't used Cocoa Java myself, so I may be missing things... maybe someone else can correct me or expand on these notes.

Good night!

--Andy

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: [Cocoa-Java] WebView and HTML string how to ?
      • From: Yvon Thoraval <email@hidden>
References: 
 >[Cocoa-Java] WebView and HTML string how to ? (From: Yvon Thoraval <email@hidden>)

  • Prev by Date: Re: Intercepting Click in Background of Table View
  • Next by Date: Re: Intercepting Click in Background of Table View
  • Previous by thread: [Cocoa-Java] WebView and HTML string how to ?
  • Next by thread: Re: [Cocoa-Java] WebView and HTML string how to ?
  • Index(es):
    • Date
    • Thread