Library overview

Internals

iPFaces form data

In the case the user wants to submit an iPFaces component value back to the server, the iPFaces framework will name the component using the “id” property of the component (which is mandatory). On submit, the iPFaces client creates a set of parameters using the element name and its value. The situation is special for checkbox and button component (derived from the html protocol). The button's value will be sent on submit only if this button was used to submit the form. The value of checkbox elements will be sent only if the checkbox is checked. In other cases, no value is sent back to the server.

There are two more attributes for input controls: the user can mark component as read only. A component marked read only shows its value in the form, but this value cannot be changed. Read only values are sent to the server on submit action. Disabled components are used to show the component's value but the user cannot manipulate the component at all, and, unlike read only components, values are not sent back to the server on submit.

How to use it?

Development of a complex iPFaces application is really simple because the simulation mode can be used. This mode is capable of transfering XML content to a HTML page, which can be displayed in a web browser. It is a helpful tool for developers who can see their iPFaces application in the browser window and they do not need a real iPhone device for main development.

Developers can build and deploy an application to the application server and browser will show them the GUI which is almost the same as a screen in an iPhone application. There is a difference in the GPS elements. A GPS field is working in a browser only as text field that can be filled by the user and GPS coordinates will be submitted. The GPS field is hidden on mobile devices, because the location of the device is detected without interaction with the user.

Form representation on the iPhone device and in a web browser

Hello world example

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HelloWorld.aspx.cs" Inherits="HelloWorld._Default" %>

<%@ Register Assembly="iPFaces.NET" Namespace="Org.IPFaces.Net.Controls" TagPrefix="ipf" %>

<ipf:Form ID="form1" runat="server">
    <ipf:Screen ID="screen1" runat="server" Title="iPFaces Form">
        <ipf:Label ID="label1" runat="server" />
    </ipf:Screen>
</ipf:Form>

This file represents the visual representation of the application.

File HelloWorld.aspx.cs wiil look like:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using Org.IPFaces.Net.Controls;
using Org.IPFaces.Net.Pages;

namespace HelloWorld
{
    public partial class _Default : Org.IPFaces.Net.Pages.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
               label1.Text="Hello World";
        }
    }
}

This file shows the functional representation of the application.

Hello world example on the iPhone device and in a web browser

More complex examples

The example published below is not complete. It only illustrates how easy it is to define forms for iPhone using iPFaces. For complete examples please visit www.ipfaces.org/content/examples.

Example: Use of location service

To obtain a user location from a mobile device use the “ipf:Gps” element. Upon submission of a form, the location data will be sent as a parameter with the selected name (gpsLocation in this example).

File Default.aspx will look like:

<%@ Page Language="C#" AutoEventWireup="true"
   CodeBehind="Default.aspx.cs"
   Inherits="Org.IPFaces.Net.Examples.GPSDistance._Default" %>

<%@ Register Assembly="iPFaces.NET"
   Namespace="Org.IPFaces.Net.Controls" TagPrefix="ipf" %>

<ipf:Form ID="DefaultForm1" runat="server">
    <ipf:Screen ID="DefaultScreen1" runat="server"
       Title="GPS Distance">
        <ipf:Image ID="iPFacesImage" runat="server"
           ImageUrl="~/Data/ipfaces.png" />
        <ipf:Label ID="DescriptionLabel" runat="server" Text="Find distance between your position and selected city." />
        <ipf:Select ID="listOfCities" runat="server"
           EnableViewState="false" Title="Distance to:"
           Icon="~/Data/distcalc.png" />
        <ipf:Gps ID="GPS" runat="server" />
        <ipf:Button ID="CalculateButton" runat="server"
           Title="Calculate" OnClick="CalculateButton_Click"
           Position="Forward" />
    </ipf:Screen>
</ipf:Form>

This file is the visual representation of the application.

File Default.aspx.cs is fairly complicated and therefore is not included. To be able to see the file or the whole example, please visit http://www.ipfaces.org/content/examples.

To see how this example will look like, look at the end of the “How to use it?”