suite4.net.FormDatabase Documentation

IForm.SerializeToSwfXml Method (Object, WebLoaderAlert)

Serializes the current IForm, an instance of a business object and a WebLoaderAlert to an XML string. The XML is processed by the WebLoader component to dynamically draw a form and display the business object's values in a Macromedia Flash form.

[Visual Basic]
Function SerializeToSwfXml( _
   ByVal dataSource As Object, _
   ByVal webLoaderAlert As WebLoaderAlert _
) As String
[C#]
string SerializeToSwfXml(
   object dataSource,
   WebLoaderAlert webLoaderAlert
);

Parameters

dataSource
The business object instance to be serialized.
webLoaderAlert
A WebLoaderAlert that is to be displayed by the WebLoader.

Return Value

An XML string representing the IForm and an associated business object instance.

Remarks

Example

The following example demonstrates how to serialize an IForm and display an alert to the user.

C# sample

using System;
using System.Collections;
using suite4.net.FormDatabase;
using suite4.net.Sample;
namespace suite4.net.Web.Sample
{
    public class FormServer : System.Web.Services.WebService
    {
        [System.Web.Services.WebMethod]
        public string SerializeForm(string formName)
        {
            string                    projectFileName;
            IForm                        form;
            IProject                project;
            ArrayList                employees;
            WebLoaderAlert    webLoaderAlert;

            projectFileName = this.Server.MapPath("\\sample")  "\\sample.fspj";
            project = Project.LoadFromFile(projectFileName);
            if(project != null)
            {
                form = project.GetForm(formName);
                if(form != null)
                {
                    employees = new ArrayList();
                    employees.Add("Anne Dodsworth");
                    employees.Add("Laura Callahan");
                    employees.Add("Robert King");
                    form.SetComponentValue("lstEmployees", "Items", employees);
                    webLoaderAlert = new WebLoaderAlert();
                    webLoaderAlert.Title = "Select an employee";
                    webLoaderAlert.Message = "Please select an employee\nto see the employee details.";
                    return form.SerializeToSwfXml(null, webLoaderAlert);
                }
                else
                {
                    webLoaderAlert = new WebLoaderAlert();
                    webLoaderAlert.Title = "Failed to load form";
                    webLoaderAlert.Message = "Can't find form "  formName;
                    return webLoaderAlert.SerializeToSwfXml();
                }
            }
            else
            {
                webLoaderAlert = new WebLoaderAlert();
                webLoaderAlert.Title = "Failed to load project";
                webLoaderAlert.Message = "Can't find project\n"  projectFileName;
                return webLoaderAlert.SerializeToSwfXml();
            }
        }
    }
}
            

VB.Net sample
Imports System
Imports System.Collections
Imports suite4.net.FormDatabase
Imports suite4.net.Sample
Namespace suite4.net.Web.Sample
    Public Class FormServer
     Inherits System.Web.Services.WebService
        <System.Web.Services.WebMethod> _
        Public Function SerializeForm(ByVal formName As String) As String
            Dim projectFileName As String
            Dim form As IForm
            Dim project As IProject
            Dim employees As ArrayList
            Dim webLoaderAlert As WebLoaderAlert

            projectFileName = Me.Server.MapPath("\\sample")  "\\sample.fspj"
            project = Project.LoadFromFile(projectFileName)
            If Not project Is Nothing Then
                form = project.GetForm(formName)
                If Not form Is Nothing Then
                    employees = New ArrayList()
                    employees.Add("Anne Dodsworth")
                    employees.Add("Laura Callahan")
                    employees.Add("Robert King")
                    form.SetComponentValue("lstEmployees", "Items", employees)
                    webLoaderAlert = New WebLoaderAlert()
                    webLoaderAlert.Title = "Select an employee"
                    webLoaderAlert.Message = "Please select an employee\nto see the employee details."
                    Return form.SerializeToSwfXml(Nothing,webLoaderAlert)
                Else
                    webLoaderAlert = New WebLoaderAlert()
                    webLoaderAlert.Title = "Failed to load form"
                    webLoaderAlert.Message = "Can't find form "  formName
                    Return webLoaderAlert.SerializeToSwfXml()
                End If
            Else
                webLoaderAlert = New WebLoaderAlert()
                webLoaderAlert.Title = "Failed to load project"
                webLoaderAlert.Message = "Can't find project\n"  projectFileName
                Return webLoaderAlert.SerializeToSwfXml()
            End If
        End Function
    End Class
End Namespace

            

See Also

IForm Interface | suite4.net.FormDatabase Namespace | IForm.SerializeToSwfXml Overload List