Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    how to create a smartGWT custom widget as jar file for use in another project

    Hi friends,

    I created a SmartGWT application that displays a remote file browser dialog (a custom widget that shows files on a remote server). The code goes something like this...
    Code:
    RemoteFileDialog rfDialog = new RemoteFileDialog("*.*, *.htm, *.cpp, *.hpp");
    rfDialog.show();
    The RemoteFileDialog is like a dialog widget which shows the contents from file system of a remote server (via GWT RPC to backend, and the backend makes a ssh connection to a remote server as specified in the remotefiledialog UI). ref: screenshot "rfb-dialog.png"

    My Objective:
    =========
    Given that this app is tested and works well, now my requirement is that, I want to distribute this as a jar file, so that other SmartGWT projects can use this as a widget.

    I am looking at a way, how to ship this component "RemoteFileDialog" as a jar file, so that any other SmartGWT web app can use it for showing a file browser. Is there any detailed document / reference which I can go through to understand fully?

    With my limited knowledge, and after googlinig some web sites, referring to smartGWT quickstart guide and enquiring with others, I followed these steps, which I am not at all sure if they are correct or they are in the right direction at all. Any help on this would be gladly appreciated :).

    #1. I created the jar file for RemoteFileDialog Widget project using this script:
    Code:
    rvnath@rvnath:~/workspace/RemoteFileBrowser$ cat makejar.sh 
    cd src
    jar cvf ../RemoteFileDialog.jar com/comviva/remotefilebrowser/client/*.java
    jar uvf ../RemoteFileDialog.jar com/comviva/remotefilebrowser/shared/*.java
    jar uvf ../RemoteFileDialog.jar com/comviva/remotefilebrowser/server/*.class
    jar uvf ../RemoteFileDialog.jar com/comviva/remotefilebrowser/*.xml
    cd ..
    jar uvf RemoteFileDialog.jar war/*
    rvnath@rvnath:~/workspace/RemoteFileBrowser$
    The above script creates a RemoteFileDialog.jar with .java files for client and shared folders and with .class files for server code, and finally includes everything from war folder of widget project.

    #2. In another smartGwt sample project, I used this jar file, with the following steps:

    2.1. Added the jar to build path via "add external jars"

    2.2. module inheritance:
    changes to gwt.xml file

    <inherits name="com.comviva.remotefilebrowser.RemoteFileBrowser"></inherits>

    2.3 Did gwtc to test if the module inherits properly. GWT compile works with no warnings or errors.

    However, when I tried to create an instance of RemoteFileDialog in the test code given below, eclipse doesn't recognize or prompt me adding the required import i.e. "com.comviva.remotefilebrowser.client.RemoteFileDialog;"
    Code:
    RemoteFileDialog rfDialog = new RemoteFileDialog("*.*, *.htm, *.cpp, *.hpp");
    rfDialog.show();
    Inspite of this, if I manually add the import statement myself, still it gives compile error at those lines.

    As a next step, I opened the build path configuration dialog and added "RemoteFileBrowser" project under "projects" tab (for "Required Projects on the Build Path". See the attached screenshot).
    After this, it started recognizing the class and I was able to compile and execute.

    The question at this point is... when I distribute RFB as a widget, I won't be sharing my project to the users of this widget, and hence the above solution won't be applicable. So, what is the correct procedure to create a proper recognizable .jar file for my widget?

    Further more, my UI widget has icon resources (for showing folder and folder loading animations), which I packed into the RemoteFileDialog.jar file. In the target application, these icons are not shown, since I get a 404 error, when the widget makes an RPC request "[WARN] 404 - GET /images/Refresh-icon-16_Over.png (127.0.0.1) 1417 bytes". One way to solve this, would be to extract the image files from my .jar file and copy them to target app's image directory (ex: webapps/<targetapp>/images).

    But this would violate the principle of providing a single .jar file to the users of the widget without any additional hassles or steps. Want to know, if there is a way of solving this.


    This is my environment, if it makes sense:
    -------------------------------------------------------------
    SmartGWT 3.0
    GWT 2.4
    Browser : Firefox 7.0.1
    Dev environment: Eclipse Indigo on Ubuntu11.10

    regards,
    RV
    Attached Files

    #2
    For the resources problem, take a look at this post.

    http://stackoverflow.com/questions/10737674/image-resources-in-shared-gwt-modules-widgets-like

    Comment


      #3
      Thanks, this is what I was looking for...

      Dear jmichelgarcia,

      Thanx for this link. I will try it out, as it answers my pertinent and relevant questions.

      Meanwhile, I have figured out that the way I was creating the widget jar file was not the proper one. The class files which are supposed to be put in jar as "com/comviva/remotefilebrowser/*.class" were being put as "/war/WEB-INF/classes/*.class". So, obviously the imported .jar file in the user gwt application was unable to deduce the imported classes.

      Now, I hope this solves all of my problems [until now] :)
      Last edited by rv_nath; 24 May 2012, 23:33. Reason: Adding progress updates to the original problem for others benefit

      Comment

      Working...
      X