0

What I am trying to do is giving user option to upload a GWT composite

As user upload a java class (which is some layout with GWT widgets) , Our application will displays that layout.

lets says its LoginPageView.java class .

Now what i do is , After uploading I place the class in some Client package, so the class is now com.test.client.LoginPageView.java

Now to open this class and show the layout , I have to do

    LoginPageView loginView = new LoginPageView();

    RootPanel().get().add(loginView );

and it will display the uploaded layout.

But I dont know the name of the class as it was added at run time , so the loading of the class will be at run time, But how will that be possible at CLIENT side.

Is there any way .

thanks

1 Answer 1

2

GWT compiles Java code into JavaScript. This happens before the app is deployed. A user's browser reads the JavaScript file from the server and executes it.

Now, if a user supplies you with a new LoginPage Java class, you need to copy this class into your project in Eclipse (for example), run GWT compiler to create all new permutations, deploy the new code to the server, and ask your user to load the app again.

If a second user gives you a different LoginPage class, you will have to create a different version of your app just for this user, or add both LoginPage classes to your project, and somehow decide which of them to serve to each user. This is possible but the size of your project will keep growing with each new custom class that you add to it.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks , but even after that , how will i open the loginPage class at run time , how will i achieve this : LoginPageView loginView = new LoginPageView(); RootPanel().get().add(loginView ); ... what will be the code instead of this above one , coz this will be happening at the run time , and instead of this LoginPageView , user can add anything , which need to open itself , when the application will load again (as u said)
if it was at server side i could use class.forname . to load a class at run time , but not sure if there's any way in GWT client side to load a class at run time
As Andrei just said in his answer, no, there isn't. GWT has to already know about the classes, it can't create new JS at runtime from server code.
There is no "Java" at runtime, only JavaScript. You can get HTML + JavaScript from a user and inject them at runtime, but that would be very insecure.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.