Package org.fusesource.restygwt.client

Examples of org.fusesource.restygwt.client.Resource


            }
        });
    }

    protected void doJsonp() {
        Resource resource = new Resource("http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=finances&format=pdf&output=json&callback=callback");
        resource.jsonp().send(new JsonCallback() {
            public void onSuccess(Method method, JSONValue response) {
                JSONObject obj = (JSONObject) ((JSONObject) response).get("ResultSet");
                RootPanel.get().add(new Label("Search Results Available: " + obj.get("totalResultsAvailable")));
            }
View Full Code Here


        RootPanel.get().add(customButton);
    }

    private void getGreeting() {
        GreetingService service = GWT.create(GreetingService.class);
        Resource resource = new Resource(GWT.getModuleBaseURL() + "greeting-service");
        ((RestServiceProxy) service).setResource(resource);

        service.getGreeting(new OverlayCallback<Greeting>() {
            public void onSuccess(Method method, Greeting greeting) {
                RootPanel.get().add(new Label("server said: " + greeting.getGreeting()));
View Full Code Here

        });
    }

    private void getCustomGreeting(String name) {
        GreetingService service = GWT.create(GreetingService.class);
        Resource resource = new Resource(GWT.getModuleBaseURL() + "greeting-service");
        ((RestServiceProxy) service).setResource(resource);
        NameObject arg = (NameObject) JavaScriptObject.createObject();
        arg.setName(name);

        service.getCustomGreeting(arg, new OverlayCallback<Greeting>() {
View Full Code Here

        this.packageName = packageName;
    }
   
    @Override
    public void getMenuItems() {
        Resource resource = new Resource(URLBuilder.getMenuItemsURL(this.contextPath));
        resource.get().send(new SimpleTextCallback(i18n.CouldntFindMenuItems()) {
            @Override
            public void onSuccess(Method method, String response) {
                if (method.getResponse().getStatusCode() == Response.SC_OK) {
                    Map<String, List<FBMenuItem>> menuItems = helper.readMenuMap(response);
                    for (String groupName : menuItems.keySet()) {
View Full Code Here

            }
        });
    }

    public void getCurrentRoles(final FormBuilderService.RolesResponseHandler handler) {
        Resource resource = new Resource(URLBuilder.getCurrentRolesURL(this.contextPath));
        resource.get().send(new TextCallback() {
            @Override
            public void onSuccess(Method method, String response) {
                if (method.getResponse().getStatusCode() == Response.SC_OK) {
                    List<String> roles = helper.readRoles(response);
                    handler.onResponse(roles);
View Full Code Here

            }
        });
    }
   
    public void logout() {
        Resource resource = new Resource(URLBuilder.getLogoutURL(this.contextPath));
        resource.post().send(new TextCallback() {
            @Override
            public void onSuccess(Method method, String response) {
                Window.Location.reload();
            }
            @Override
View Full Code Here

        });
    }
   
    @Override
    public void getMenuOptions() {
        Resource resource = new Resource(URLBuilder.getMenuOptionsURL(this.contextPath));
        resource.get().send(new SimpleTextCallback(i18n.CouldntFindMenuOptions()) {
            @Override
            public void onSuccess(Method method, String response) {
                List<MainMenuOption> currentOptions = helper.readMenuOptions(response);
                for (MainMenuOption option : currentOptions) {
                    bus.fireEvent(new MenuOptionAddedEvent(option));
View Full Code Here

        });
    }

    @Override
    public void saveForm(final FormRepresentation form) {
        Resource resource = new Resource(URLBuilder.saveFormURL(this.contextPath, this.packageName));
        try {
            String json = FormEncodingFactory.getEncoder().encode(form);
            resource.post().text(json).send(new SimpleTextCallback(i18n.CouldntSaveForm()) {
                @Override
                public void onSuccess(Method method, String response) {
                    int code = method.getResponse().getStatusCode();
                    if (code == Response.SC_CONFLICT) {
                        bus.fireEvent(new NotificationEvent(Level.WARN, i18n.FormAlreadyUpdated()));
View Full Code Here

        }
    }

    @Override
    public void saveFormItem(FormItemRepresentation formItem, String formItemName) {
        Resource resource = new Resource(URLBuilder.saveFormItemURL(this.contextPath, this.packageName, formItemName));
        try {
            String xml = helper.asXml(formItemName, formItem);
            resource.post().xml(XMLParser.parse(xml)).send(new SimpleTextCallback(i18n.CouldntSaveFormItem()) {
                @Override
                public void onSuccess(Method method, String response) {
                    int code = method.getResponse().getStatusCode();
                    if (code == Response.SC_CONFLICT) {
                        bus.fireEvent(new NotificationEvent(Level.WARN, i18n.FormItemAlreadyUpdated()));
View Full Code Here

        }
    }

    @Override
    public void deleteForm(FormRepresentation form)  {
        Resource resource = new Resource(URLBuilder.deleteFormURL(this.contextPath, this.packageName, form.getName()));
        try {
            resource.delete().send(new RequestCallback() {
                @Override
                public void onError(Request request, Throwable exception) {
                    bus.fireEvent(new NotificationEvent(Level.ERROR, i18n.ErrorDeletingForm(""), exception));
                }
                @Override
View Full Code Here

TOP

Related Classes of org.fusesource.restygwt.client.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.