Online Expert Day - HPE Data Storage - Live Now
April 24/25 - Online Expert Day - HPE Data Storage - Live Now
Read more
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

SWB Mozilla JDK Applet behaviour on VMS

SOLVED
Go to solution
Richard J Maher
Trusted Contributor

SWB Mozilla JDK Applet behaviour on VMS

Hi,

Can someone please clarify what VMS Secure Web Browser would pass back to JavaScript when an Applet Method returns an object of type java.lang.String?

Firefox returns a java.lang.String object (including all its Java methods) but Internet Explorer returns a JavaScript.DOM.String (including all its JavaScript methods) but what does SWB do? (And why :-)

If both FF and SWB are Mozilla-based then I'd imagine they both behave the same way, but has anyone seen it written down somewhere (perhaps on Sun's website?) as to what *should* happen?

Cheers Richard Maher

FYI the following is posted in comp.lang.java.programmer and comp.lang.javascript: -

"Richard Maher" wrote: -
> Hi,
>
> The following is a huge variance in behaviour between Firefox and Internet
> Explorer (that I think I'm seeing) when it comes to what is returned to the
> JavaScript when a Java Applet method has been invoked. If someone could
> explain why this may be, or if there is something that could be done at the
> Applet end to make the behaviour consistent between the browsers, that would
> be great. The issue is this: -
>
> I use 'chan = document.getElementById("CornuCopiae");' to setup the
> JavaScript variable 'chan' to reference my applet class and then proceed to
> invoke various methods such as 'msgQue = chan.getString(0,queNameLen);' In
> this case the getString() method returns queNameLen bytes (31) from a socket
> stream starting at offset zero. So far everything is peachy and both IE and
> FF have returned String objects containing the appropriate 31 bytes; the
> problem is that IE has returned a JavaSCRIPT String object and FF has
> returned a java.lang.String object.
>
> With IE I then proceed to trim my msgQue JavaScript VARiable with
> msgQue.rTrim() and it works great, but when I try the same thing with FF I
> get "Unable to convert JavaScript value /^\$+/ to java value of type char"
> which confuses the hell out of me! (especially when the trim() method
> appears to work normally)
>
> rTrim() is defined as per the JavaScript FAQ: -
>
> String.prototype.rTrim =
> function()
> {
> return this.replace(/\s+$/,'');
> }
>
> So after re-reading the error message a few times, and getting another one
> that complains that some other method doesn't occur in java.lang.String, I
> start testing a few things (like startsWith()) and discover that FF gives me
> an in tact java.lang.String object complete with all its methods (but won't
> honour my JS prototyping) but IE does some massaging and transforms the java
> object to a javascipt object before handing it over. Error "Object does not
> support property or method". Does that sound about right to everyone else?
>
> If truth be told, I'd have to say I much prefer the FF version but how then
> can I cast the j.l.String object as a standard JavaScript so that my script
> code can work with it as any other JavaScript string? (VAR normalPlease =
> fromApplet renders normalPlease as a java.lang.String object. [Even though
> the construct says its a String function native code])
>
> As always, all helpful advice and experiences appreciated.
>
> Cheers Richard Maher
>
>
3 REPLIES
Bojan Nemec
Honored Contributor
Solution

Re: SWB Mozilla JDK Applet behaviour on VMS

Richard,

Try to convert the msgQue variable to an javascript String. You can do that with:

msgQue = msgQue + "";

The "" is an empty string. This will probably work on both browsers.

Another way is to rewrite the rTrim function:


String.prototype.rTrim =
function()
{
return (this + "").replace(/\s+$/,'');
}


Bojan
Richard J Maher
Trusted Contributor

Re: SWB Mozilla JDK Applet behaviour on VMS

Hi Bojan,

Thanks for the reply; as usual you're a bloody marvel, and the change to the prototype worked. I had gotten around the problem via the convenient select list array that I was using: - options[n] = new Option(msgQue,msgQue); options[n].text.rTrim(); but your method is obviously more generic and robust.

Just another example of Browser Life's rich tapestry I suppose :-)

So where do I send your Tier3 Hobbyist License and kit to? (DEMO example now supports Firefox and (in the continued absence of IPSec) SSL if you STUNNEL the Tier3 servers. You know you want a piece o' that!)

Cheers Richard Maher
Bojan Nemec
Honored Contributor

Re: SWB Mozilla JDK Applet behaviour on VMS

Richard,

You can contact me by mail: bojan at alba dot si

Cheers
Bojan