Hub Nexus

উন্নত করার কিছু দেখছেন? একটি পরিবর্তন প্রস্তাব করুন।

সমর্থন

প্রকাশনা: XForms · 137টির মধ্যে 41 নম্বর পাতা

Motivation

After a save, you want to display a line at the end of your form to confirm that the results have been saved to the server. You also want to notify the user of any errors after a save.

Method

We will use the submission element to save the data and return the save results. We will use the to show either a success (in green) or a failure (in red).

xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xf="http://www.w3.org/2002/xforms">;

Save Test

xmlns="" id="save-data">
form-id="unit-tests-save-test">
Dan
McCreary

xmlns="" id="save-results">

No Save Results Yet

id="save-submission" ref="instance('save-data')"
method="post" resource="http://localhost:8088/exist/rest/db/apps/grants/scripts/save.xq"
replace="instance"
instance="save-results">
ev:event="xforms-submit-done">
Save Done

ev:event="xforms-submit-error">
Save Failed

id="save-submission-see-save-results" ref="instance('save-data')"
method="post" resource="http://localhost:8088/exist/rest/db/apps/grants/scripts/save.xq" replace="instance"
instance="save-results">
ev:event="xforms-submit-done">
Save Done

ev:event="xforms-submit-error">
Save Failed

type="text/css">
.success {color: green; background-color: lightgreen;}
.failure {color: red; background-color: pink;}

ref="first-name">
First name:

ref="last-name">
Last name:

href="http://localhost:8088/exist/rest/db/apps/xforms/scripts/save.xq">Save URL
class="save-controls">
submission="save-submission" appearance="xxforms:primary" class="button-margin-top">
Save and Validate

submission="save-submission-see-save-results" class="button-margin-top">
Save See Save Results

ref="instance('save-results')/.[@code='200']">
class="success">
ref="instance('save-results')//message"/>

ref="instance('save-results')/.[@code='400']">
class="failure">
ref="instance('save-results')//message"/>

Sample XQuery

xquery version "1.0";
import module namespace config= "http://danmccreary.com/config" at "../modules/config.xqm";

declare namespace xs="http://www.w3.org/2001/XMLSchema";
declare namespace xf="http://www.w3.org/2002/xforms";
declare namespace dc="http://gov/grantsolutions/dc";

let $log := util:log-system-out('running save.xq')
(: get-data() returns the document node. We want the root node :)
let $formdata := request:get-data()/*

(: check to make sure we have valid post data :)
return
if (not($formdata))
then code="400">No Post Data
else

let save-data-collection := concat(config:app-home-collection, '/save-data')

let $form-id :=
if (exists($formdata/@code))
then $formdata/@code/string()
else
if (exists($formdata/@form-id))
then $formdata/@form-id/string()
else 'unknown-form-id'

let file-name := concat(form-id, '.xml')
let path-name := concat(save-data-collection, '/', $file-name)

let $overwrite :=
if (doc-available($path-name))
then true()
else false()

let store := xmldb:store(save-data-collection, $file-name, $formdata)

return
code="200">
{if ($overwrite)
then Document updated at {$path-name}
else New document saved to {$path-name}
}

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

যে প্রকাশনাগুলোতে আছেXForms

ভাষাEnglish

লাইসেন্স: CC BY-SA 4.0 · গৃহীত হয়েছে en.wikibooks.org

1

0

0

0

Spinner Logo

মন্তব্য

Spinner Logo
সংস্করণ: 2CC0 1.0 — public domain
The runaway star that left the Tarantula Nebula
সংস্করণ: 2CC0 1.0 — public domain
The Blackwell School, where segregation had no law behind it
সংস্করণ: 2CC0 1.0 — public domain
The Eagle Nebula, seen in the infrared
সংস্করণ: 2CC0 1.0 — public domain
The house where the Equal Rights Amendment was written
সংস্করণ: 2CC0 1.0 — public domain
The Aleutians, the forgotten front of the Second World War
সংস্করণ: 2CC0 1.0 — public domain
The Cosmic Cliffs are not cliffs