RestDataSource : example XPath datasource

 RestDataSource : example XPath datasource
Ejemplo de un restdatasource mas xpath y manejo de  la respuesta con setResponseTransformHandler
public class CurrentUserDS extends RestDataSource {
    private static CurrentUserDS instance = null;

    public static User getCurrentUser() {
        if (instance == null) {
            instance = new CurrentUserDS();
          
        }
        instance.fetchData();

        return null;
    }

    private CurrentUserDS() {
        super();

        setFields(new DataSourceTextField("key", "Key"),
                new DataSourceTextField("identity", "Identity"),
                new DataSourceTextField("nickname", "Nickname"));

        setDataFormat(DSDataFormat.JSON);

        setResponseTransformHandler(new ResponseTransformHandler() {
            public void execute(DSResponse response, DSRequest request, Object data) {
                String key = XMLTools.selectObjects(data, "response/data/key").get(0).toString();
                String identity = XMLTools.selectObjects(data, "response/data/identity").get(0).toString();
                String nickName = XMLTools.selectObjects(data, "response/data/nickname").get(0).toString();

                //add logic here
            }
        });
    }
}

Comments

Popular posts from this blog

smart gwt allow only numbers in textfield

how to access the DOM gwt smartclient

question confirm sc window smartgwt - ventana de confirmacion en smartgwt