More in this section

Forums / Developing with Sitefinity / providing data to Flash apps

providing data to Flash apps

7 posts, 0 answered
  1. Chad
    Chad avatar
    4 posts
    Registered:
    13 Jun 2007
    06 Jul 2007
    Link to this post
    We're in the process of migrating to SiteFinity from Cuyahoga and one of our major stumbling blocks is figuring out how to provide data to flash applications.

    Historically, we've accomplished this via XML.  I've noticed that several modules have RSS feeds and am researched that a bit.

    We will likely be authoring our own modules as our applications are pretty custom.
    Most sites will be complex flash applications and we will be using the CMS solely for data entry, versioning and workflow control.

    soo....  I guess my question is has anyone had any experience trying to get data to flash from a SiteFinity module?

    any help would be greatly appreciated!!
  2. Bob
    Bob avatar
    330 posts
    Registered:
    30 Dec 2016
    09 Jul 2007
    Link to this post
    Hello Chad,

    Here is a simple example on how to retrieve content:
    public string GetContentAsXml()  
    {  
        using (StringWriter stringWriter = new StringWriter())  
        {  
            XmlTextWriter xml = new XmlTextWriter(stringWriter);  
            ContentManager manager = new ContentManager("Generic_Content");  
            IList dataSource = manager.GetContent(0, 10, "Name", ContentStatus.Published, null, String.Empty);  
     
            xml.Formatting = Formatting.Indented;  
            xml.WriteStartElement("Generic_Content");  
            foreach (IContent item in dataSource)  
            {  
                xml.WriteStartElement("Item");  
                xml.WriteAttributeString("Name", (string)item.GetMetaData("Name"));  
                xml.WriteAttributeString("Author", (string)item.GetMetaData("Author"));  
                xml.WriteStartElement("Content");  
                xml.WriteValue(item.Content);  
                xml.WriteEndElement();  
                xml.WriteEndElement();  
            }  
            xml.WriteEndElement();  
            xml.Close();  
     
            return stringWriter.ToString();  
        }  
    }  
     

    You can also use RSS but the current implementation is somewhat limited and not very convenient to use. We are currently working on improving RSS support. We will provide a separate module that will allow you to manage RSS services and combine feeds form different providers.

    Sincerely yours,
    Bob
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Chad
    Chad avatar
    4 posts
    Registered:
    13 Jun 2007
    09 Jul 2007
    Link to this post
    awesomeness!
    thanks a bunch.

    the only thing i have left to figure out is where in the request's lifecycle to make the call to that function to output the xml instead of the page..
  4. Bob
    Bob avatar
    330 posts
    Registered:
    30 Dec 2016
    10 Jul 2007
    Link to this post
    Hi Chad,

    I’m not sure what your goal is and I’m not familiar with Flash either but I suppose you need to set some URL in the Flash from which the XML stream will be read. In this case you can either crate an HTTP handler or use standard .aspx and write the generated XML directly to the output stream.

    public void Page_Load(object sender, EventArgs e)  
    {  
        HttpApplication app = HttpContext.Current.ApplicationInstance;  
        app.Response.ContentType = "text/xml";  
        using (StringWriter stringWriter = new StringWriter())  
        {  
            XmlTextWriter xml = new XmlTextWriter(stringWriter);  
            ContentManager manager = new ContentManager("Generic_Content");  
            IList dataSource = manager.GetContent(0, 10, "Name", ContentStatus.Published, null, String.Empty);  
     
            xml.Formatting = Formatting.Indented;  
            xml.WriteStartElement("Generic_Content");  
            foreach (IContent item in dataSource)  
            {  
                xml.WriteStartElement("Item");  
                xml.WriteAttributeString("Name", (string)item.GetMetaData("Name"));  
                xml.WriteAttributeString("Author", (string)item.GetMetaData("Author"));  
                xml.WriteStartElement("Content");  
                xml.WriteValue(item.Content);  
                xml.WriteEndElement();  
                xml.WriteEndElement();  
            }  
            xml.WriteEndElement();  
            xml.Close();  
     
            app.Response.Write(stringWriter.ToString());  
        }  
        app.CompleteRequest();  


    Kind regards,
    Bob
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Chad
    Chad avatar
    4 posts
    Registered:
    13 Jun 2007
    10 Jul 2007
    Link to this post
    Thanks Bob!

    i made some mods to your example, i just have a bit of a different way of rendering XML.  I am however running into a few problems.

    here is the function as I've modified it:
        public void OutputContentAsXml()
        {
            XmlDocument xdMain = new XmlDocument();
            xdMain.PrependChild(xdMain.CreateXmlDeclaration("1.0", "UTF-8", "yes"));

            ContentManager manager = new ContentManager("Generic_Content");
            IList dataSource = manager.GetContent(0, 10, "Name");

            litDebug.Text = "dataSource.Count=" + dataSource.Count;

            XmlElement xeGenericContentItems = xdMain.CreateElement("genericContentItems");

            foreach (IContent item in dataSource)
            {
                XmlElement xeGenericContentItem = xdMain.CreateElement("genericContentItem");
                xeGenericContentItem.SetAttribute("name", (string) item.GetMetaData("Name"));
                xeGenericContentItem.SetAttribute("author", (string) item.GetMetaData("Author"));

                XmlElement xeContent = xdMain.CreateElement("content");
                xeContent.Value = (string) item.Content;
                xeGenericContentItem.AppendChild(xeContent);
                xeGenericContentItems.AppendChild(xeGenericContentItem);
            }
           
            xdMain.AppendChild(xeGenericContentItems);

            Response.Clear();
            Response.Write(xdMain.OuterXml);
            Response.End();
        } 


    I'm calling this against the Jobs Intrasite sample database and any line utilizing the getMetaData() method results in an 'Object Not Found' exception..

    any ideas?
  6. Thomas
    Thomas avatar
    8 posts
    Registered:
    16 May 2007
    12 Jul 2007
    Link to this post
    Bob,

    I've been playing with the ContentManager class as well, and I can't seem to instantiate it using the following code:

    ContentManager manager = new ContentManager();

    also the overloaded constructor:

    ContentManager manager = new ContentManager("Generic_Content");

    In both cases I get a NullReferenceException - Object not set to an instance of an object error.  I tried several of the other classes in the assembly and did not have this same issue.

    Thomas

  7. Bob
    Bob avatar
    330 posts
    Registered:
    30 Dec 2016
    12 Jul 2007
    Link to this post
    Hi Thomas,

    All the code looks fine and should work.
    Could you please zip and attach your log file located in App_Data folder.

    Sincerely yours,
    Bob
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
7 posts, 0 answered