Announcement

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

    Javascript integration

    Hi

    I build my web application using SmartGwt for graphic.

    Now I found this http://slideshow.triptracker.net/ fantastic script for add a Photogallery to my application.

    The problem is I cannot find the correct way to do this. My first try was.

    Code:
    		ScriptInjector.fromUrl("http://slideshow.triptracker.net/slide.js").setCallback(
    				  new Callback<Void, Exception>() {
    					     public void onFailure(Exception reason) {
    					       Window.alert("Script load failed.");
    					     }
    					    public void onSuccess(Void result) {
    					      Window.alert("Script load success.");
    					     }
    					  }).inject();

    and then call this method:

    Code:
     
    	native static void example(String p) /*-{
    	 	
    		 $wnd.viewer = new $wnd.PhotoViewer();
                     $wnd.viewer.add(p)
    		 $wnd.viewer.show(0);
    
    	}-*/;
    this did not give any error but the photogallery appears BEHIND my Entry Point Layout, so it's not possible to use it.

    Now I'm trying to refer to the main layout from Javasript, to run the script on that. Is this possible?

    I've tried with

    Code:
     foo.getElement().getId();
    but it returns me something like

    isc_VLayout_0_wrapper

    that the Javascript refuses

    then I tried foo.getDOM.getId();

    isc_1

    same story.




    Can someone tell me the way to do this?

    Thank You.

    #2
    Read the DOM Integration overview in the docs.

    Comment


      #3
      Thank You for your answer. After read it I look at the document you refer.

      Meanwhile, a friend of mine, linked me this page. I thinked it could work so I try this work around:

      Code:
      DOMUtil.setID(this, "external");
      example(DOMUtil.getID(this), "imagereference");
      changing example method this way

      Code:
      native static void example(String id,String p) /*-{
      	 	
      		 $wnd.$('#'+id).viewer = new $wnd.PhotoViewer();
                       $wnd.$('#'+id).viewer.add(p)
      		 $wnd.$('#'+id).viewer.show(0);
      
      	}-*/;
      But this give me this error:


      Code:
      example(Ljava/lang/String;)([string: 'external']): $ is not defined

      I check with in the page, the external 'div' of my layout has the id="external"

      So, why this wont work?


      thank you again :)

      Comment


        #4
        Don't use that approach. Use the approaches explained in the DOM Integration topic.

        Comment


          #5
          Hi. Thank you for your answer. I've worked on the suggested approach, but without success.

          I choose to use another workaround I'll leave here for someone could have my same problem:

          Since it's a overlay problem I edited the script changing the zIndex of generated widgets. Worked


          Thank's again and goodbye.

          Comment

          Working...
          X