RSSFeedSample.java :  » Ajax » smartgwt-2.1 » com » smartgwt » sample » showcase » client » dataintegration » xml » Java Open Source

Java Open Source » Ajax » smartgwt 2.1 
smartgwt 2.1 » com » smartgwt » sample » showcase » client » dataintegration » xml » RSSFeedSample.java
package com.smartgwt.sample.showcase.client.dataintegration.xml;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceLinkField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.sample.showcase.client.PanelFactory;
import com.smartgwt.sample.showcase.client.ShowcasePanel;

public class RSSFeedSample extends ShowcasePanel {

    private static final String DESCRIPTION = "DataSources can bind directly to simple XML documents where field values" +
            " appear as attributes or subelements.";

    public static class Factory implements PanelFactory {
        private String id;

        public Canvas create() {
            RSSFeedSample panel = new RSSFeedSample();
            id = panel.getID();
            return panel;
        }

        public String getID() {
            return id;
        }

        public String getDescription() {
            return DESCRIPTION;
        }
    }

    public Canvas getViewPanel() {
        DataSource dataSource = new DataSource();
        dataSource.setRecordXPath("//default:item");
        dataSource.setDataURL("http://rss.slashdot.org/Slashdot/slashdot");

        DataSourceTextField titleField = new DataSourceTextField("title", "Title");
        DataSourceLinkField linkField = new DataSourceLinkField("link", "URL");

        dataSource.setFields(titleField, linkField);

        ListGrid grid = new ListGrid();
        grid.setDataSource(dataSource);
        grid.setWidth100();
        grid.setHeight(300);
        grid.setAutoFetchData(true);
        return grid;
    }

    public String getIntro() {
        return DESCRIPTION;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.