xforms: an application platform · xforms: an application platform jaakko kangasharju xforms...
TRANSCRIPT
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
XForms: An Application PlatformApplications and Services in Internet 2009 (4 cr)
Jaakko [email protected]
Futurice Ltd.
Autumn 2009
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 1 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Outline
1 XForms Structures
2 An XForms Application
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 2 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Outline
1 XForms StructuresModel-View-ControllerXForms ElementsDynamism in XForms
2 An XForms Application
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 3 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
XForms Structure
• An XForms application has two parts• Form controls provide user input capabilities• Instance data contains the actual input data
• Form controls linked to appropriate parts of instance
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 4 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Outline
1 XForms StructuresModel-View-ControllerXForms ElementsDynamism in XForms
2 An XForms Application
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 5 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Model-View-Controller (MVC) Architecture
• Requirement: Easy adaptation to different devices⇒ Separate user interface from logic
• Three components:• Model holds all state• View provides the user interface• Controller allows user actions to change model
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 6 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
MVC Components
Model
View
Controller
User
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 7 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
MVC in XForms
• In XForms, MVC components map as follows:• Model is a (hidden) template filled in with instance data• View consists of the form controls as presented to the user• Controller consists of the form controls bound to the
instance• Controls are specified abstractly to permit same document
to be used everywhere
• So what is the point of MVC here?
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 8 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
MVC in XForms
• In XForms, MVC components map as follows:• Model is a (hidden) template filled in with instance data• View consists of the form controls as presented to the user• Controller consists of the form controls bound to the
instance• Controls are specified abstractly to permit same document
to be used everywhere• So what is the point of MVC here?
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 8 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Model-View Separation
• Despite abstraction, sometimes different views are needed• Model should be separable from view
• Model often has pre-defined structure• Not always sensible to force UI to mirror structure
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 9 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Outline
1 XForms StructuresModel-View-ControllerXForms ElementsDynamism in XForms
2 An XForms Application
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 10 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Basics
• Model represented by element• Contains , , , possibly
and actions• Model referenced through model and ref or bind
attributes• XPath used to address items in the instance
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 11 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
XForms Example
ISBN
Book title
Author name
First
Last
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 12 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Example Rendering
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 13 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Controls
• XForms defines several types of controls• Common attributes: appearance, navigation attributes• Common child elements: , , ,
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 14 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Text Input Controls
• Basic text input: element• Multi-line text with element• element for passwords• Data typing: Element type used to style control (calendar,
checkbox, . . . )• Data typing: XML Schema patterns and facets to restrict
valid values
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 15 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Choice Input Controls
• element to make multiple choices (list withcheckboxes)
• to make a single choice (radio buttons)• to select from a sequential range (slider)• and can allow free-form entry or not
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 16 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Triggers and Submission
• element like a button: used to initiate actionsin response to user input
• Contains element and events that triggeractions
• Often responds to generic DOMActivate event• element basically a special-purpose trigger• Binds to element of
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 17 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Other Controls
• element shows values from instance data• Can use references or calculation• element allows uploading content• Binary content sent embedded in XML document,
encoded as text• Should support acquiring data from peripherals
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 18 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Grouping
• element used to enclose groups of controls• Semantic information intended for rendering
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 19 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Repetition
• Some instance data has repetitive structure (in XMLSchema, maxOccurs > 1)
• element allows showing this to user• Binds to a node set and repeats content for each item in
the set• Corresponding attributes when host language does not
permit XForms elements (e.g., XHTML )
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 20 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Step-by-Step Filling
• Sometimes complete form is large and consists ofindependent areas
• element defines multiple mutually exclusive elements
• element inside changes rendered case
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 21 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Outline
1 XForms StructuresModel-View-ControllerXForms ElementsDynamism in XForms
2 An XForms Application
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 22 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Event Handling
• Standard XML Events handling: capture, arrival, bubbling• Pre-defined elements for handling, no scripting• Pre-defined handlers picked based on experience with
scripted HTML forms• Certain user actions trigger event sequences
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 23 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Event Types
• Four kinds of XForms eventsInitialization When XForms processor initializedInteraction When user navigates through formNotification When user acts on form
Error When something wrong happens
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 24 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Modifying Instance Structure
• Controls only allow values to be changed, not structure• Especially repetitive items need structure changes• and elements provided for this• Not usable for generic modification, only homogeneous
lists• element can be used to set inserted element’s
content
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 25 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Binding
• The element can express properties dynamically,based on instance data
• Additional constraints: Presence, types, predicates• Relevancy: Whether part of the model is currently
applicable• Not the same as hidden cases: Non-relevant data not even
submitted• Can be used to replace some XML Schema processing
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 26 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Calculation
• The calculate attribute of allows computation• Can use any XPath expression + additional XForms
functions• Not replaceable with XML Schema (but is with
Schematron)• Drawbacks of scripting apply
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 27 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Outline
1 XForms Structures
2 An XForms Application
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 28 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Forms for Shopping Cart
• Let’s continue with the shopping cart. . .• Primary form: Cart itself• Another form: On each item page• Checkout process with forms too
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 29 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Embedding XForms in XHTML
• Use XHTML pages with embedded XForms• Note: Cannot use HTML!
• Model goes into document head• Controls go into document body, interspersed with regular
XHTML
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 30 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Model for Item
w013Fancy Widget16.751false
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 31 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Form for Item
How many?
Giftwrap?
Add to cart
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 32 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Item Page
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 33 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Model for Cart
ltc
w012Widget12.005
false
...
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 34 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Form for Cart: Table Skeleton
Shopping Cart
ItemPriceQuantityGiftwrap
...
Total price (in €)
Shipping costs (in €)
Checkout
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 35 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Form for Cart: Table Body
Remove
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 36 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Cart Page
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 37 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Model for Checkout
Finland
Visa
112008
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 38 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Form for Checkout: Skeleton
Address
...
Forward
Credit card
...
Back
Confirm
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 39 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Form for Checkout: Dispatch
Name
Address
Country
FinlandFinland
SwedenSweden
UKUK
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 40 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Checkout Page: Dispatch
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 41 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Form for Checkout: Payment
Card type
VisaVisa
MastercardMastercard
Cardholder name
Card number
Expiry
Month
Year
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 42 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
XFormsStructuresModel-View-Controller
XForms Elements
Dynamism in XForms
An XFormsApplication
Checkout Page: Payment
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 43 / 44
-
XForms: AnApplication
Platform
JaakkoKangasharju
Lecture Over
Have a good week!
Jaakko Kangasharju (Futurice Ltd.) XForms: An Application Platform Autumn 2009 44 / 44
XForms StructuresModel-View-ControllerXForms ElementsDynamism in XForms
An XForms ApplicationFinal Slide