Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make server error constants be available on the GWT client #8

Open
spg opened this issue Feb 2, 2015 · 0 comments
Open

Make server error constants be available on the GWT client #8

spg opened this issue Feb 2, 2015 · 0 comments

Comments

@spg
Copy link

spg commented Feb 2, 2015

I created a BaseUploadStatus that overrides the default (Window.alert()) behavior.

public class CustomUploadStatus extends BaseUploadStatus {
    public interface FileTooLargeHandler {
        void onFileTooLarge();
    }

    private final FileTooLargeHandler fileTooLargeHandler;

    public CustomUploadStatus(
            FileTooLargeHandler fileTooLargeHandler) {
        this.fileTooLargeHandler = fileTooLargeHandler;
    }

    @Override
    public void setError(String msg) {
        setStatus(Status.ERROR);
        if (msg.startsWith("The request was rejected because its size:")) {
            fileTooLargeHandler.onFileTooLarge();
        }
    }
}

I would like to avoid the msg.startsWith("The request was rejected because its size:"). Depending on that particular string couples me too much with the contents of UploadServlet.properties.

size_limit=The request was rejected because its size: {0} KB, exceeds the maximum: {1} KB

It seems that the UploadServlet.properties file is only available on the server. It would be nice if those messages could be available to a GWT app (maybe leveraging GWT's Messages)

Or, maybe I could use a specific Status for when the uploaded file is too large?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant