Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to call a java fuction from html page and getting the result back in java class

And yes i have tested with you code,it needs two clicks for the javascript function gets called for the first time

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to call a java fuction from html page and getting the result back in java class

if it is a simple html file with only button n text,its working,but if its a heavy html file with css and other js file,it doesnt work on the first go.I have put alert also inside javascript method,which gets called for the first time.That means from javascript method is being called,but interesting.test which i am calling after alert doesnt work for the first time.May be blackberry browserfield taking time to load?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to call a java fuction from html page and getting the result back in java class

Sorry I am getting mixed messages from your responses.

 

You seem to say that the test does not work first time in one post and then in the next post say it does because it is simple, but complicated (heavy) Javascript processing does not. 

 

This is an important distinction.  If it never works first time, then that suggests a problem with your setup.  If it works first time in simple cases but not in complicated cases, then this suggests a loading or timing problem as you suggest.

 

If in fact it does work first time for the simple case, then I think we have resolved that the interaction between Java and Javascript is established.  In which case you should ask this question in the forum specific to html processing here:

 

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/bd-p/browser_dev

 

I would suggest in your testing you put an alert both before and after your call to Java. 

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to call a java fuction from html page and getting the result back in java class

Yes i have put alert statement before and after,so before alert works fine,but interesting.test doesnt work,2nd time when i click before,interesing.test and after alert all works

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to call a java fuction from html page and getting the result back in java class

Raise this in the other forum.

 

But you need to confirm that this happens only in the case of complicated html. 

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to call a java fuction from html page and getting the result back in java class

I have figured out the problem,its not about complicated HTML,rather navigation problem.When i load a complicated html as the index page,my Javascript works fine.Say i have two htmls,pageA & pageB,javascript on page a works at the first go.Now when i click a link on pageA and pageB loads,where again some js functions are there,than in pageB i need to click twice before getting that js function to execute.So my question is that while navigating to new html pages,do i need to make new instances of browserfield n browserconfig?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to call a java fuction from html page and getting the result back in java class

"So my question is that while navigating to new html pages,do i need to make new instances of browserfield n browserconfig?"

 

No.

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to call a java fuction from html page and getting the result back in java class

But its not working without two clicks if the javascript call is in the 2nd html page

Developer
Posts: 436
Registered: ‎06-22-2010
My Device: na
My Carrier: blackberry developer

Re: how to call a java fuction from html page and getting the result back in java class

I have verified with two htmls 

<html>
<div id='label1'></div>  <div id='label2'>
        <input type="button"  value="Proceed"  onclick="window.location.href = 'index.html'; " />
      </div></body></html>

 This is html one,which clicking on proceed button,it will go to page 2,which have javascript function.

<html>
<script language='JavaScript'> function myfun() { interesting.test(); return false; } function message2(m){alert(m);} </script><body>this is test html<b>bold text </b><a href='' onclick='return myfun()'>link</a><div id='label1'></div>  <div id='label2'>
        <input type="button"  value="Proceed" href='' onclick="return myfun()" />
      </div></body></html>

 Now it needs two times click on the LINK hyperlink to execute the native browserField.executeScriptEngine.Strange though,you can test this scenario in your environment if you have time.

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to call a java fuction from html page and getting the result back in java class

I am busy atm, hopefully someone else can test.

 

I suggest you ask thisquestion on the other forum too.