formcontrols.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. <html xmlns="http://www.w3.org/1999/xhtml"
  2. xmlns:xf="http://www.w3.org/2002/xforms"
  3. xmlns:ev="http://www.w3.org/2001/xml-events"
  4. xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  5. <head>
  6. <title>Form Controls</title>
  7. <xf:model>
  8. <xf:instance xmlns="" id="document">
  9. <data>
  10. <if/>
  11. <reqflag>true</reqflag>
  12. <req/>
  13. <notreq/>
  14. <roflag>true</roflag>
  15. <ro>Read-only data</ro>
  16. <notro>Read-write data</notro>
  17. <relflag>true</relflag>
  18. <rel/>
  19. <notrel/>
  20. <con>100</con>
  21. <reqcon></reqcon>
  22. <notcon/>
  23. <conflag>true</conflag>
  24. <date>2010-01-01</date>
  25. <time>00:00:00</time>
  26. <!-- If Z is left out below we get funny behavior - TODO: Investigate! -->
  27. <datetime>2010-01-01T00:00:00</datetime>
  28. <sel1>One</sel1>
  29. <sel/>
  30. <pw/>
  31. <dTableFilter>1000000</dTableFilter>
  32. <dTableEditIndex>1</dTableEditIndex>
  33. <dTableRepeatIndex>1</dTableRepeatIndex>
  34. <dTable>
  35. <row>
  36. <name>One</name>
  37. <price>10</price>
  38. <quantity>100</quantity>
  39. <code>B525</code>
  40. <country>FI</country>
  41. <quality>good</quality>
  42. </row>
  43. <row>
  44. <name>Two</name>
  45. <price>20</price>
  46. <quantity>200</quantity>
  47. <code>D234</code>
  48. <country>GB</country>
  49. <quality>avg</quality>
  50. </row>
  51. <row>
  52. <name>Three</name>
  53. <price>30</price>
  54. <quantity>300</quantity>
  55. <code>F987</code>
  56. <country>US</country>
  57. <quality>fine</quality>
  58. </row>
  59. </dTable>
  60. </data>
  61. </xf:instance>
  62. <xf:instance xmlns="" id="template">
  63. <template>
  64. <row>
  65. <name>Product Name</name>
  66. <price>0</price>
  67. <quantity>0</quantity>
  68. <code>A000</code>
  69. <country>FI</country>
  70. <quality>avg</quality>
  71. </row>
  72. </template>
  73. </xf:instance>
  74. <xf:bind nodeset="/data/reqflag" type="xsd:boolean" />
  75. <xf:bind nodeset="/data/roflag" type="xsd:boolean" />
  76. <xf:bind nodeset="/data/relflag" type="xsd:boolean" />
  77. <xf:bind nodeset="/data/conflag" type="xsd:boolean" />
  78. <xf:bind nodeset="/data/con" type="xsd:integer" />
  79. <xf:bind nodeset="/data/reqcon" type="xsd:integer" />
  80. <xf:bind nodeset="/data/date" type="xsd:date" />
  81. <xf:bind nodeset="/data/time" type="xsd:time" />
  82. <xf:bind nodeset="/data/datetime" type="xsd:dateTime" />
  83. <xf:bind nodeset="/data/req" required="boolean-from-string(/data/reqflag)" />
  84. <xf:bind nodeset="/data/ro" readonly="boolean-from-string(/data/roflag)" />
  85. <xf:bind nodeset="/data/rel" relevant="boolean-from-string(/data/relflag)" />
  86. <xf:bind nodeset="/data/con" constraint="not(boolean-from-string(/data/conflag)) or (/data/con < 100 and /data/con mod 10 = 0)" />
  87. <xf:bind nodeset="/data/reqcon" constraint="not(boolean-from-string(/data/conflag)) or (/data/reqcon < 100 and /data/reqcon mod 10 = 0)" />
  88. <xf:bind nodeset="/data/reqcon" required="true()" />
  89. <xf:submission id="sub1" method="get" action="http://www.example.com/submit.asp"/>
  90. </xf:model>
  91. </head>
  92. <body>
  93. <xf:switch appearance="full">
  94. <xf:label>Form Control</xf:label>
  95. <xf:case id="intro">
  96. <xf:label>Introduction</xf:label>
  97. <p>This form is used for demonstrating Xfolite form controls.</p>
  98. <p>Please select a form control.</p>
  99. </xf:case>
  100. <xf:case id="tabs">
  101. <xf:label>Tabs</xf:label>
  102. <xf:switch appearance="compact">
  103. <xf:label>Compact Switch</xf:label>
  104. <xf:case id="tab11">
  105. <xf:label>Tab 1</xf:label>
  106. <p>Tab 1 content</p>
  107. </xf:case>
  108. <xf:case id="tab12">
  109. <xf:label>Tab 2</xf:label>
  110. <p>Tab 2 content</p>
  111. </xf:case>
  112. <xf:case id="tab13">
  113. <xf:label>Tab 3</xf:label>
  114. <p>Tab 3 content</p>
  115. </xf:case>
  116. </xf:switch>
  117. <xf:switch appearance="full">
  118. <xf:label>Full Switch</xf:label>
  119. <xf:case id="tab21">
  120. <xf:label>Tab 1</xf:label>
  121. <p>Tab 1 content</p>
  122. </xf:case>
  123. <xf:case id="tab22">
  124. <xf:label>Tab 2</xf:label>
  125. <p>Tab 2 content</p>
  126. </xf:case>
  127. <xf:case id="tab23">
  128. <xf:label>Tab 3</xf:label>
  129. <p>Tab 3 content</p>
  130. </xf:case>
  131. </xf:switch>
  132. </xf:case>
  133. <xf:case id="select1">
  134. <xf:label>Select1</xf:label>
  135. <xf:select1 ref="/data/sel1" appearance="minimal">
  136. <xf:label>Minimal Select1</xf:label>
  137. <xf:item>
  138. <xf:label>One</xf:label>
  139. <xf:value>One</xf:value>
  140. </xf:item>
  141. <xf:item>
  142. <xf:label>Two</xf:label>
  143. <xf:value>Two</xf:value>
  144. </xf:item>
  145. <xf:item>
  146. <xf:label>Three</xf:label>
  147. <xf:value>Three</xf:value>
  148. </xf:item>
  149. </xf:select1>
  150. <xf:select1 ref="/data/sel1" appearance="compact">
  151. <xf:label>Compact Select1</xf:label>
  152. <xf:item>
  153. <xf:label>One</xf:label>
  154. <xf:value>One</xf:value>
  155. </xf:item>
  156. <xf:item>
  157. <xf:label>Two</xf:label>
  158. <xf:value>Two</xf:value>
  159. </xf:item>
  160. <xf:item>
  161. <xf:label>Three</xf:label>
  162. <xf:value>Three</xf:value>
  163. </xf:item>
  164. </xf:select1>
  165. <xf:select1 ref="/data/sel1" appearance="full">
  166. <xf:label>Full Select1</xf:label>
  167. <xf:item>
  168. <xf:label>One</xf:label>
  169. <xf:value>One</xf:value>
  170. </xf:item>
  171. <xf:item>
  172. <xf:label>Two</xf:label>
  173. <xf:value>Two</xf:value>
  174. </xf:item>
  175. <xf:item>
  176. <xf:label>Three</xf:label>
  177. <xf:value>Three</xf:value>
  178. </xf:item>
  179. </xf:select1>
  180. <xf:select1 ref="/data/sel1" appearance="tabs">
  181. <xf:label>Tabs Select1</xf:label>
  182. <xf:choices> <!-- We use choices element here just to see that it does not cause a bug -->
  183. <!-- Choices element is not really supported though, they are just ignored -->
  184. <xf:item>
  185. <xf:label>One</xf:label>
  186. <xf:value>One</xf:value>
  187. </xf:item>
  188. <xf:item>
  189. <xf:label>Two</xf:label>
  190. <xf:value>Two</xf:value>
  191. </xf:item>
  192. <xf:item>
  193. <xf:label>Three</xf:label>
  194. <xf:value>Three</xf:value>
  195. </xf:item>
  196. </xf:choices>
  197. </xf:select1>
  198. </xf:case>
  199. <xf:case id="select">
  200. <xf:label>Select</xf:label>
  201. <xf:select ref="/data/sel" appearance="minimal">
  202. <xf:label>Minimal/Compact Select</xf:label>
  203. <xf:item>
  204. <xf:label>One</xf:label>
  205. <xf:value>One</xf:value>
  206. </xf:item>
  207. <xf:item>
  208. <xf:label>Two</xf:label>
  209. <xf:value>Two</xf:value>
  210. </xf:item>
  211. <xf:item>
  212. <xf:label>Three</xf:label>
  213. <xf:value>Three</xf:value>
  214. </xf:item>
  215. <xf:item>
  216. <xf:label>Four</xf:label>
  217. <xf:value>Four</xf:value>
  218. </xf:item>
  219. <xf:item>
  220. <xf:label>Five</xf:label>
  221. <xf:value>Five</xf:value>
  222. </xf:item>
  223. <xf:item>
  224. <xf:label>Six</xf:label>
  225. <xf:value>Six</xf:value>
  226. </xf:item>
  227. <xf:item>
  228. <xf:label>Seven</xf:label>
  229. <xf:value>Seven</xf:value>
  230. </xf:item>
  231. </xf:select>
  232. <xf:select ref="/data/sel" appearance="full">
  233. <xf:label>Full Select</xf:label>
  234. <xf:item>
  235. <xf:label>One</xf:label>
  236. <xf:value>One</xf:value>
  237. </xf:item>
  238. <xf:item>
  239. <xf:label>Two</xf:label>
  240. <xf:value>Two</xf:value>
  241. </xf:item>
  242. <xf:item>
  243. <xf:label>Three</xf:label>
  244. <xf:value>Three</xf:value>
  245. </xf:item>
  246. <xf:item>
  247. <xf:label>Four</xf:label>
  248. <xf:value>Four</xf:value>
  249. </xf:item>
  250. <xf:item>
  251. <xf:label>Five</xf:label>
  252. <xf:value>Five</xf:value>
  253. </xf:item>
  254. <xf:item>
  255. <xf:label>Six</xf:label>
  256. <xf:value>Six</xf:value>
  257. </xf:item>
  258. <xf:item>
  259. <xf:label>Seven</xf:label>
  260. <xf:value>Seven</xf:value>
  261. </xf:item>
  262. </xf:select>
  263. </xf:case>
  264. <xf:case id="table">
  265. <xf:label>Table</xf:label>
  266. <xf:switch>
  267. <xf:case id="view">
  268. <xf:select1 ref="dTableFilter" appearance="minimal">
  269. <xf:label>Filter with max price</xf:label>
  270. <xf:item>
  271. <xf:label>10</xf:label>
  272. <xf:value>10</xf:value>
  273. </xf:item>
  274. <xf:item>
  275. <xf:label>20</xf:label>
  276. <xf:value>20</xf:value>
  277. </xf:item>
  278. <xf:item>
  279. <xf:label>30</xf:label>
  280. <xf:value>30</xf:value>
  281. </xf:item>
  282. <xf:item>
  283. <xf:label>40</xf:label>
  284. <xf:value>40</xf:value>
  285. </xf:item>
  286. <xf:item>
  287. <xf:label>50</xf:label>
  288. <xf:value>50</xf:value>
  289. </xf:item>
  290. <xf:item>
  291. <xf:label>None</xf:label>
  292. <xf:value>1000000</xf:value>
  293. </xf:item>
  294. </xf:select1>
  295. <!--
  296. <xf:output ref="dTableRepeatIndex">
  297. <xf:label value="concat('RepeatIndex (out of ',count(instance('document')/dTable/row), ')')"/>
  298. </xf:output>
  299. -->
  300. <table id="mytable" appearance="selectable">
  301. <caption>Product Catalog</caption>
  302. <!--
  303. Dependency calculation does not work with repeat index, so we need this workaround
  304. if we want to adjust dynamically to the selection (e.g. to show some more details on selected item).
  305. At the moment it is not needed.
  306. -->
  307. <!--
  308. <xf:action ev:event="xforms-select">
  309. <xf:setvalue ref="dTableRepeatIndex" value="index('trepeat')"/>
  310. </xf:action>
  311. -->
  312. <thead>
  313. <tr>
  314. <th>Name</th><th>Price</th><th>Lot size</th>
  315. <th>Code</th><th>Producer</th><th>Quality</th>
  316. </tr>
  317. </thead>
  318. <tbody id="trepeat" repeat-nodeset="dTable/row[price &lt;= instance('document')/dTableFilter]">
  319. <tr>
  320. <td><xf:output ref="name"/></td>
  321. <td><xf:output ref="price"/></td>
  322. <td><xf:output ref="quantity"/></td>
  323. <td><xf:output ref="code"/></td>
  324. <td><xf:output ref="country"/></td>
  325. <td><xf:output ref="quality"/></td>
  326. </tr>
  327. </tbody>
  328. </table>
  329. <table appearance="layout">
  330. <tr><td>
  331. <xf:trigger>
  332. <xf:label>Add Before</xf:label>
  333. <xf:action ev:event="DOMActivate">
  334. <xf:insert
  335. origin="instance('template')/row"
  336. context="instance('document')/dTable"
  337. nodeset="row"
  338. at="index('trepeat')"
  339. position="before"
  340. />
  341. </xf:action>
  342. </xf:trigger>
  343. </td>
  344. <td>
  345. <xf:trigger>
  346. <xf:label>Add After</xf:label>
  347. <xf:action ev:event="DOMActivate">
  348. <xf:insert
  349. origin="instance('template')/row"
  350. context="instance('document')/dTable"
  351. nodeset="row"
  352. at="index('trepeat')"
  353. position="after"
  354. />
  355. </xf:action>
  356. </xf:trigger>
  357. </td>
  358. </tr>
  359. <tr>
  360. <td>
  361. <xf:trigger id="editbutton">
  362. <xf:label>Edit</xf:label>
  363. <xf:action ev:event="DOMActivate">
  364. <xf:setvalue ref="dTableEditIndex" value="index('trepeat')"/>
  365. <xf:toggle case="edit"/>
  366. <xf:setfocus control="editstart"/>
  367. </xf:action>
  368. </xf:trigger>
  369. </td>
  370. <td>
  371. <xf:trigger>
  372. <xf:label>Delete</xf:label>
  373. <xf:action ev:event="DOMActivate">
  374. <xf:delete context="instance('document')/dTable" nodeset="row" at="index('trepeat')"/>
  375. </xf:action>
  376. </xf:trigger>
  377. </td>
  378. </tr>
  379. </table>
  380. </xf:case>
  381. <xf:case id="edit">
  382. <xf:group ref="dTable/row[number(instance('document')/dTableEditIndex)]">
  383. <xf:input id="editstart" ref="name">
  384. <xf:label>Name</xf:label>
  385. </xf:input>
  386. <xf:input ref="price">
  387. <xf:label>Price</xf:label>
  388. </xf:input>
  389. <xf:input ref="quantity">
  390. <xf:label>Lot Size</xf:label>
  391. </xf:input>
  392. <xf:input ref="code">
  393. <xf:label>Code</xf:label>
  394. </xf:input>
  395. <xf:select1 ref="country" appearance="compact">
  396. <xf:label>Producer</xf:label>
  397. <xf:item>
  398. <xf:label>Great Britain</xf:label>
  399. <xf:value>GB</xf:value>
  400. </xf:item>
  401. <xf:item>
  402. <xf:label>Finland</xf:label>
  403. <xf:value>FI</xf:value>
  404. </xf:item>
  405. <xf:item>
  406. <xf:label>United States</xf:label>
  407. <xf:value>US</xf:value>
  408. </xf:item>
  409. <xf:item>
  410. <xf:label>Sweden</xf:label>
  411. <xf:value>SWE</xf:value>
  412. </xf:item>
  413. </xf:select1>
  414. <xf:select1 ref="quality" appearance="compact">
  415. <xf:label>Quality</xf:label>
  416. <xf:item>
  417. <xf:label>Poor</xf:label>
  418. <xf:value>poor</xf:value>
  419. </xf:item>
  420. <xf:item>
  421. <xf:label>Average</xf:label>
  422. <xf:value>avg</xf:value>
  423. </xf:item>
  424. <xf:item>
  425. <xf:label>Good</xf:label>
  426. <xf:value>good</xf:value>
  427. </xf:item>
  428. <xf:item>
  429. <xf:label>Fine</xf:label>
  430. <xf:value>fine</xf:value>
  431. </xf:item>
  432. </xf:select1>
  433. <xf:trigger>
  434. <xf:label>Done</xf:label>
  435. <xf:action ev:event="DOMActivate">
  436. <xf:toggle case="view"/>
  437. <xf:setfocus control="editbutton"/>
  438. </xf:action>
  439. </xf:trigger>
  440. </xf:group>
  441. </xf:case>
  442. </xf:switch>
  443. </xf:case>
  444. <xf:case id="date">
  445. <xf:label>Date</xf:label>
  446. <xf:input ref="date">
  447. <xf:label>Date input</xf:label>
  448. </xf:input>
  449. <xf:input ref="time">
  450. <xf:label>Time input</xf:label>
  451. </xf:input>
  452. <xf:input ref="datetime">
  453. <xf:label>DateTime input</xf:label>
  454. </xf:input>
  455. <xf:output ref="date">
  456. <xf:label>Date as string</xf:label>
  457. </xf:output>
  458. <xf:output ref="time">
  459. <xf:label>Time as string</xf:label>
  460. </xf:output>
  461. <xf:output ref="datetime">
  462. <xf:label>DateTime as string</xf:label>
  463. </xf:output>
  464. </xf:case>
  465. <xf:case id="password">
  466. <xf:label>Password</xf:label>
  467. <xf:secret ref="pw">
  468. <xf:label>Password Input</xf:label>
  469. </xf:secret>
  470. <xf:output ref="pw">
  471. <xf:label>Password in cleartext</xf:label>
  472. </xf:output>
  473. <p>(Cleartext updates only after focus moves away from input)</p>
  474. </xf:case>
  475. <xf:case id="required">
  476. <xf:label>Required</xf:label>
  477. <xf:input ref="reqflag">
  478. <xf:label>Required flag</xf:label>
  479. </xf:input>
  480. <xf:input ref="req">
  481. <xf:label>Required field</xf:label>
  482. </xf:input>
  483. <xf:input ref="notreq">
  484. <xf:label>Normal field</xf:label>
  485. </xf:input>
  486. <xf:submit submission="sub1">
  487. <xf:label>Submit Now</xf:label>
  488. </xf:submit>
  489. </xf:case>
  490. <xf:case id="readonly">
  491. <xf:label>Read-Only</xf:label>
  492. <xf:input ref="roflag">
  493. <xf:label>Read-only flag</xf:label>
  494. </xf:input>
  495. <xf:input ref="ro">
  496. <xf:label>Read-only field</xf:label>
  497. </xf:input>
  498. <xf:input ref="notro">
  499. <xf:label>Normal field</xf:label>
  500. </xf:input>
  501. </xf:case>
  502. <xf:case id="relevant">
  503. <xf:label>Relevant</xf:label>
  504. <xf:input ref="relflag">
  505. <xf:label>Relevant flag</xf:label>
  506. </xf:input>
  507. <xf:input ref="rel">
  508. <xf:label>Relevant field</xf:label>
  509. </xf:input>
  510. <xf:input ref="notrel">
  511. <xf:label>Normal field</xf:label>
  512. </xf:input>
  513. </xf:case>
  514. <xf:case id="constraint">
  515. <xf:label>Constraint</xf:label>
  516. <xf:input ref="conflag">
  517. <xf:label>Constraint flag</xf:label>
  518. </xf:input>
  519. <xf:input ref="con">
  520. <xf:label>Constraint field (&lt; 100 &amp; multiple of 10)</xf:label>
  521. <xf:alert value="if(. < 100,'','Value must be less than 100!')"/>
  522. <xf:alert value="if(. mod 10 = 0,'','Value must be a multiple of 10!')"/>
  523. </xf:input>
  524. <xf:input ref="reqcon">
  525. <xf:label>Required constraint field (&lt; 100 &amp; multiple of 10)</xf:label>
  526. <xf:alert value="if(. < 100,'','Value must be less than 100!')"/>
  527. <xf:alert value="if(. mod 10 = 0,'','Value must be a multiple of 10!')"/>
  528. </xf:input>
  529. <xf:input ref="notcon">
  530. <xf:label>Normal field</xf:label>
  531. </xf:input>
  532. <xf:output ref="reqcon">
  533. <xf:label>No alerts in output</xf:label>
  534. </xf:output>
  535. </xf:case>
  536. </xf:switch>
  537. </body>
  538. </html>