Ext.form.field.File not working with gwt2.8.0-rc2 (with gwt2.8.0-beta1 it works)

72 views
Skip to first unread message

Teletin Alin

unread,
Sep 1, 2016, 11:59:41 AM9/1/16
to GWT Contributors
Hi all,

I have a problem with an upload button which sends the selected file to a servlet and takes some action on servlet response.
This is the code:

//all ESExtXXX or ExtXXX from following code are wrapped javascript with jsinterop
                ESExtCreateParams uploadPanelParams = new ESExtCreateParams();
uploadPanelParams.setWidth(60);
uploadPanelParams.setHeight(24);
uploadPanelParams.setLayout("fit");
ExtFormPanel panelForm = (ExtFormPanel) ESExt.create("Ext.form.Panel", uploadPanelParams);

ESExtCreateParams loadButtonParams = new ESExtCreateParams();
loadButtonParams.setButtonText("LoadJsonFile");
loadButtonParams.setAutoHeight(true);
// loadButtonParams.setAutoWidth(true);
loadButtonParams.setHideLabel(true);
loadButtonParams.setButtonOnly(true);
loadButtonParams.setFlex(1);
ExtFormFile loadButton = (ExtFormFile) ESExt.create("Ext.form.field.File", loadButtonParams);
loadButton.addListener("change", new ESStandardFunction() {

@Override
public void exec() {
ExtFormBasic basicForm = panelForm.getForm();

JsOptions options = new JsOptions();
options.setUrl("urlToMyServlet");
options.setMethod("POST");
options.setWaitMsg("Please wait...");
options.setFileUpload(true);
options.setSuccess(new JsSubmitFunction() {

@Override
public void exec(ExtFormBasic basic, ExtFormSubmit action) {
JavaScriptObject result = action.getResult();
useJsonData(JsonUtils.stringify(result));
loadButton.reset();
}
});
options.setFailure(new JsSubmitFunction() {

@Override
public void exec(ExtFormBasic basic, ExtFormSubmit action) {
loadButton.reset();
}
});

basicForm.submit(options);
}
});

panelForm.add(loadButton);

This panelForm is added to a ext toolbar which is used in a GWT app.

As I saw, I can choose a file to upload, that file goes to my servlet, my servlet does its job, but the bold code(functions from on success or on failure) is not called. It should be called when servlet response is returned.
I do have in the result a json containing "success" : true or false.

This code works with gwt2.8.0-beta1 but not with gwt2.8.0-rc1 or rc2.

Any suggestions?

Thank you,
AlinT.

Thomas Broyer

unread,
Sep 1, 2016, 12:10:17 PM9/1/16
to GWT Contributors
Do you pass --generateJsInteropExports to GWT? I think that's now required for @JsFunction⋅s to be callable from JS.

Jens

unread,
Sep 1, 2016, 1:38:50 PM9/1/16
to GWT Contributors

Do you pass --generateJsInteropExports to GWT? I think that's now required for @JsFunction⋅s to be callable from JS.

You don't need --generateJsInteropExports to make @JsFunction work, that would be bad. Just verified it using RC2 and event listener on button element.

But you need --generateJsInteropExports now if anything in the above code is a non-native JsType. In Beta1 it worked accidentally in SDM without the flag.

-- J.



Teletin Alin

unread,
Sep 2, 2016, 3:26:10 AM9/2/16
to GWT Contributors
I do have generateJsInteropExports flag in my pom:

 <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>${gwt.maven.plugin.version}</version> <-- version is 2.8.0-rc2-patched -->
        <configuration>
          <source>${java.version}</source> <-- version is 1.8 -->
          <target>${java.version}</target>
          <strict>true</strict>
          <style>${gwt.style}</style>

          <extraJvmArgs>-Xmx2048m -Xss1024k -XX:MaxPermSize=256m</extraJvmArgs>
          <hostedWebapp>${webappDirectory}</hostedWebapp>
          <superDevMode>true</superDevMode>
          <generateJsInteropExports>true</generateJsInteropExports>
          <runTarget>Project.html</runTarget>
          <module>com.example.project.TestProject</module>
          <mode>htmlunit</mode>
        </configuration>
        <executions>
          <execution>
            <id>compile</id>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>run</id>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
          <execution>
            <id>test</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <includes>**/GwtTestSuite*.java</includes>
            </configuration>
          </execution>
        </executions>
      </plugin>

and JsSubmitFunction definition is:

@JsFunction
@FunctionalInterface
public interface JsSubmitFunction {
void exec(ExtFormBasic basic, ExtFormSubmit action);
}

Other thing: I get no error neither in browser console nor in eclipse..

Thank you
Reply all
Reply to author
Forward
0 new messages