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
Contributor
Posts: 10
Registered: ‎02-11-2010
My Device: Blackberry 9000
My Carrier: Telefonica

Launch a Web Page from an application

[ Edited ]

Hi:

 

I want to display a Web form with prefilled data from an application with no success so far. I use javscript code within a browser address bar in a PC and, when tried to do the same with Blackberry browser I failed.

 

I decided to create a small application that will do but, being a novice (less than that), I am stuck with it. I wrote the following:

 

 

import net.rim.blackberry.api.browser.*;
import java.util.*;
import java.lang.String;
import java.lang.Object;

class Sample {
public void displayPage (String actualURL) {
    actualURL = "http://sample.com/" + Calendar.DAY_OF_MONTH + "-" + Calendar.MONTH + "-" + Calendar.YEAR;}
}

 

 

When compiling I receive the following warning:

 

 

C:\Research in Motion\bin\Gastos.java:19: Warning!: method 'Sample.displayPage(String)' not invoked.

Warning!: No definition found for exported static routine: .main(String[])

Build complete.

 

So I found I did not have an entry point for my code. The thing is, I have not been able to create one. If I add one like this:

 

 

class Sample {
public void displayPage (String actualURL) {
    actualURL = "http://sample.com/" + Calendar.DAY_OF_MONTH + "-" + Calendar.MONTH + "-" + Calendar.YEAR;}
public static void main (String[] args) {}}

 I will receive the following warning:

 

C:\Research in Motion\bin\Gastos.java:19: Warning!: method 'Sample.displayPage(String)' not invoked.

 

If instead, I define my entry point like this:

 

 

class Sample {
    String actualURL = "http://sample.com/" + Calendar.DAY_OF_MONTH + "-" + Calendar.MONTH + "-" + Calendar.YEAR;
public void displayPage () {}
public static void main (String args){
    displayPage(actualURL);}}

 I receive this warning:

 

 

C:\Research in Motion\bin\Gastos.java:11: non-static variable actualURL cannot be referenced from a static context

    displayPage(actualURL);

                ^

C:\Research in Motion\bin\Gastos.java:11: displayPage() in Sample cannot be applied to (java.lang.String)

    displayPage(actualURL);

 

 

Obviously, I am somehow messing everything up.

 

Any help will be very much appreciated.

 

Regards,

 

 

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Launch a Web Page from an application

You need to instantiate your application class in you main() routine.

 

public void main(String args)

{

     Sample app = new Sample();

}

 

Also be advised that you main app class must extend Application or Uiapplicaiton, and it must enter the event dispatcher.

 

Please see the numerous sample programs that ship with the JDE.