Etwas zu verbessern? Schlag eine Änderung vor.
Motivation
Forms frequently need to display fields that are not editable by the user. The following program demonstrates this feature.
This is done in XForms using a binding and a style sheet.
A single field (or group of fields) can be marked as read-only with a single bind statement. For example, suppose you had a set of fields related to shipping supplies to remote staff in your IT department. The billing address could not be changed, only who an item was shipped to.
The following single line in the model would make all of the sub-elements of BillToAddress read-only:
nodeset="/PurchaseOrders/BillToAddress" readonly="true()" />
Note that because of CSS, all the fields under this binding will be marked read-only. This is one good reason you may want to logically group read-only data elements in an application.
Sample Program
XHTML XForm
xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms">
Demonstration of Read-Only Binding
rel="stylesheet" type="text/css" href="table-form.css" />
xmlns="" src="PurchaseOrder.xml" />
nodeset="/PurchaseOrder/BillToAddress" readonly="true()" />
ref="/PurchaseOrder/BillToAddress">
class="box-label">Billing Address :
ref="OrganizationName">
Organization Name:
ref="LocationStreetFullText">
Street:
ref="LocationStreetFullText2">
/>
ref="LocationCityName">
City:
ref="LocationStateName">
State:
ref="LocationPostalID">
Postal Code:
ref="/PurchaseOrder/ShipToAddress">
class="box-label">Shipping Address :
ref="PersonName">
Person Name:
ref="LocationStreetFullText">
Street:
ref="LocationStreetFullText2">
/>
ref="LocationCityName">
City:
ref="LocationStateName">
State:
ref="LocationPostalID">
Postal Code:
Sample Instance Data (PurchaseOrder.xml)
xmlns="">
MegaCorp IT Dept.
123 Main St.
Mailstop 47
Anytown
Minnesota
55123
John Jones
123 Main Street SE
Apartment 123
Anytown
Minnesota
55123
XForms tabular layout stylesheet (table-form.css)
/* a stylesheet for tabular XForms input field alignment */
@namespace xf url("http://www.w3.org/2002/xforms");
/* give the input form labels and the fieldset legend a bold sans-serif font */
label {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: small;
}
xf|group {
border: black solid 2px;
padding: 5px;
width: 300px;
}
/* the labels are right-aligned in a 150px wide column */
xf|input xf|label {
width: 150px;
margin: 3px;
text-align: right;
}
/* the input values are left aligned */
xf|value {
text-align: left;
}
/* vertical area between input boxes */
input {
margin: .2em;
}
/* each input is a row in the group table */
xf|input {
display: table-row;
}
/* each label within an input is a cell in the input row */
xf|input xf|label {
display: table-cell;
}
/* each value (pseudo-element) is also a cell in the input row */
xf|input::value {
display: table-cell;
}
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.
In diesen PublikationenXForms
Lizenz: CC BY-SA 4.0 · Bearbeitet nach en.wikibooks.org
1
0
0
0

Kommentare






