Want to hit a rest service with clicking a button

53 Views Asked by At

I have a button on a ListGrid, for the button I have:

.addClickHandler(new ClickHandler()
            {
                @Override
                public void onClick(final ClickEvent event)
                {
                    SC.confirm("Are you sure?", new BooleanCallback()
                    {
                        @Override
                        public void execute(Boolean value)
                        {
                            if (value == null || Boolean.FALSE.equals(value))
                            {
                                event.cancel();
                                return;
                            }
                            // How do I call RS : //localhost:8080/service/task1

                        }
                    });
                }

How do I send a request to that rest service URL? the base URL is the same, they are on the same grid. The type is a @GET

1

There are 1 best solutions below

0
On

You can create RestDataSource in SmartGWT. Something like this

        final RestDataSource dataSource = new RestDataSource() {
        @Override
        protected Object transformRequest(DSRequest request) {
            request.setHttpMethod("GET"); // To set the HTTP method as "GET"
            return super.transformRequest(request);
        }
    };
    dataSource.setDataFormat(DSDataFormat.JSON); //set format
    dataSource.setFields(); // set fields
    dataSource.setDataURL("localhost:8080/service/task1");

On Click of the button call this:

dataSource.fetchData();