Skip to main content

LMAppletserver in Glassfish

LMAppletserver is a toolkit for automatic deployment of java classes (or jars) to your browser, and an rpc library for easily calling methods on the server. The intention is to enable effective code reuse between the client and the server, and not have to repackage the classes for the client. Also a way of calling server methods - that is to give the feeling of coding "directly on the server".

Download the example project from sourceforge.net:

http://sourceforge.net/project/downloading.php?group_id=142974&use_mirror=osdn&filename=SimplestLMAppletserverProject.zip&2731151

unzip SimplestLMAppletserverProject.zip

cd SimplestLMAppletserverProject

ant

To deploy the application to Glassfish:

asadmin deploydir simplelmapp.war

Open in your browser:

http://localhost:8080/simplelmapp/

And see the hello world applet...

The applet shows a message that is obtained by calling a business method on the server, using the RPC features of LMAppletserver. This is what happens in the applet:

HelloWorldBeanIF helloObj = (HelloWorldBeanIF)AppletServiceClientProxy.newInstance(HelloWorldBeanIF.class);
add(new JLabel(helloObj.sayHello()));

And on the server:

public class HelloWorldBean implements HelloWorldBeanIF {

public String sayHello() {
return "Hello world!";
}

}

See? Calling server methods using LMAppletServer clients is really simple .. :)

Comments

Popular posts from this blog

Angular components not reloading on route change

Spent a long time wondering why route changes caused strange effects on my component, and found out that it was because my component wasn't reloading at all. I had this assumption that when a route parameter changed (e.g. /projects/1 changed to /projects/2 ) the component for the route would be reloaded. But this is not the default behaviour of the Angular router. The default behaviour of the Angular router is to reuse the route if the configuration is the same (and not reload the component). But we can override this by providing a RouteReuseStrategy to our @NgModule: providers: [ { provide: RouteReuseStrategy, useClass: AARouteReuseStrategy } ] The full custom implementation of the RouteReuseStrategy will then be like this (and it's the shouldReuseRoute method that changes the behaviour so that the component is reloaded on route parameter change): export class AARouteReuseStrategy extends RouteReuseStrategy { shouldDetach(route: ActivatedRou...

Using Angular i18n translation strings outside templates

As of today in Angular 6 i18n is only available in the templates. So what if we want to use translated messages programatically and outside templates? I still use the component template html file to declare the message to be translated, but by obtaining the TemplateRef ViewChild in the component typescript file I can get the translated messages from typescript. <ng-template #boardInvitationEmailBody let-organization="organization" let-url="url"> <ng-container i18n>You have been invited to join the board portal for</ng-container> {{organization}}. <ng-container i18n> Please follow the link to: </ng-container> {{url}} </ng-template> So in the typescript code i can now call the createEmailBodyTranlated text method to get the translated text for use outside the template. @ViewChild('boardInvitationEmailBody') boardInvitationEmailBody: TemplateRef ; createEmailBodyTranslatedText(org...

Using GIT for offline web app syncing and storage

Offline web applications, progressive web apps (PWA) using service workers for being available offline also needs a way to sync changes with the server. Mostly we store data in JSON documents, and we could identify changes per line - which is something GIT is excellent at. So how could we make the browser a GIT client? I've been working on this for some months now, and compiled libgit2 to webassembly using emscripten - and it turns out to work very well. Some video demos: Cloning a repository: https://youtu.be/rcBluzpUWE4 Merging of file changes: https://youtu.be/xfGrMwLy_tw The project is here: https://github.com/fintechneo/angular-git-filebrowser