質問

I'm finding it hard to make JSNI work directly with Errai, take for example this code:

private static native void _createCallOut(JavaScriptObject callout)/*-{
    $wnd.hopscotch.getCalloutManager().createCallout(callout);
}-*/;

Where this JSNI is called roothing from

@PageShowing
public void onShow() {
                CallOut startCallOut = new CallOut("dashboard", Placement.RIGHT);
                startCallOut.setTitle("Take an example tour");
                startCallOut.setContent("Start by taking an example tour to see GWT-Tour in action!");
                startCallOut.setWidth(240);
                startCallOut.centerXOffset();
                startCallOut.centerArrowOffset();
                GwtTour.createCallOut(startCallOut); // Here!
}

Where this Java code, CallOut works fine if the first parameter is the ID of a DIV that is manually typed into the GWT app HTML, but if its on the page template of Errai, this will not work. Any ideas why its not working?

役に立ちましたか?

解決

The @PageShowing lifecycle method is invoked before the template has been added to the DOM. From the PageShowing JavaDoc:

Indicates that the target method should be called when the @Page widget it is a member of is about to be displayed in the navigation content panel: after the widget's @PageState fields have been updated and before it is displayed in the navigation content panel.

Try using @PageShown instead.

他のヒント

I managed to make it work instead in @PageShowing or @PageShown, but inside onAttach or the @Page:

@Override
protected void onAttach() {
      super.onAttach();
      // Works fine inside
    } 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top