| <?xml version="1.0"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <!-- This file is similar to form1_template_action.xml. They differ in group layout, |
| form's action attribute (to use continuations) and, this one is a dynamic form |
| template that changes the 'contacts' repeater layout depending on its size --> |
| <page xmlns:ft="http://apache.org/cocoon/forms/1.0#template" |
| xmlns:fi="http://apache.org/cocoon/forms/1.0#instance" |
| xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"> |
| |
| <!-- Import the macros that define CForms template elements --> |
| <jx:import uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/> |
| <h4 class="samplesGroup">Widget sampler (Flowscript)</h4> |
| <title>Sample form</title> |
| <content> |
| <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST"> |
| <div style="width: 90%; margin: 10px 50px 50px 50px;"> |
| <!-- group with tabs. Each of the children of <items> will constitute a tab --> |
| <fi:group> |
| <fi:styling type="choice"/> |
| <fi:label>Choose a panel: </fi:label> |
| <fi:state> |
| <ft:widget id="tab-state"/> |
| </fi:state> |
| |
| <fi:items> |
| <!-- group with automatic two-column layout --> |
| <fi:group> |
| <fi:label>String fields</fi:label> |
| <fi:styling layout="columns"/> |
| <fi:items> |
| <ft:widget id="email"/> |
| <ft:widget id="birthdate"/> |
| <ft:widget id="timestamp"/> |
| <ft:widget id="fourchars" fi:list-type="listbox" fi:listbox-size="4"> |
| <!-- particular styling for the enumeration |
| <fi:styling list-type="llistbox" listbox-size="4"/--> |
| </ft:widget> |
| </fi:items> |
| </fi:group> |
| |
| <fi:group> |
| <fi:label>Number fields</fi:label> |
| <fi:styling layout="columns"/> |
| <fi:items> |
| <ft:widget id="number1"/> |
| <ft:widget id="number2"/> |
| <ft:widget id="account"/> |
| <ft:widget id="cowheight"> |
| <fi:styling list-type="radio"/> |
| </ft:widget> |
| </fi:items> |
| </fi:group> |
| |
| <fi:group> |
| <fi:styling layout="columns"/> |
| <fi:label>Boolean fields</fi:label> |
| <fi:items> |
| <ft:widget id="somebool"/> |
| </fi:items> |
| </fi:group> |
| |
| <fi:group> |
| <fi:styling layout="columns"/> |
| <fi:label>Multivalue fields</fi:label> |
| <fi:items> |
| <ft:widget id="drinks"> |
| <fi:styling list-type="double-listbox"> |
| <fi:available-label>Available drinks</fi:available-label> |
| <fi:selected-label>Your selection</fi:selected-label> |
| </fi:styling> |
| </ft:widget> |
| <ft:widget id="freemv"/> |
| </fi:items> |
| </fi:group> |
| </fi:items> |
| </fi:group> |
| |
| <p>Checkout the <a href="form1">form1 action page</a> for another way of formatting panels</p> |
| |
| <fi:group> |
| <fi:styling layout="columns"/> |
| <fi:items> |
| <ft:widget id="visa"/> |
| <ft:widget id="ipaddress"/> |
| <ft:widget id="altbirthdate"/> |
| <ft:widget id="altbirthdate2"/> |
| <ft:widget id="dieselprice"/> |
| </fi:items> |
| </fi:group> |
| |
| <!-- manual layout of fields, without use of a fi:group --> |
| <ft:widget-label id="contacts"/><br/> |
| <ft:repeater-size id="contacts"/> |
| <table border="1"> |
| <tr> |
| <th><ft:repeater-widget-label id="contacts" widget-id="firstname"/></th> |
| <th><ft:repeater-widget-label id="contacts" widget-id="lastname"/></th> |
| <th><ft:repeater-widget-label id="contacts" widget-id="phone"/></th> |
| <th><ft:repeater-widget-label id="contacts" widget-id="email"/></th> |
| <th><ft:repeater-widget-label id="contacts" widget-id="birthdate"/></th> |
| <th><ft:repeater-widget-label id="contacts" widget-id="select"/></th> |
| </tr> |
| <jx:choose> |
| <jx:when test="${widget.getChild('contacts').getSize() == 0}"> |
| <tr><td colspan="6" align="center"><em>There are no contacts to display</em></td></tr> |
| </jx:when> |
| <jx:otherwise> |
| <!-- The contents of the repeater-widget element is a template that will |
| be applied to each row in the repeater. --> |
| <ft:repeater-widget id="contacts"> |
| <tr> |
| <td><ft:widget id="firstname"/></td> |
| <td><ft:widget id="lastname"/></td> |
| <td><ft:widget id="phone"/></td> |
| <td><ft:widget id="email"/></td> |
| <td><ft:widget id="birthdate"/></td> |
| <td><ft:widget id="select"/></td> |
| </tr> |
| </ft:repeater-widget> |
| </jx:otherwise> |
| </jx:choose> |
| <tr> |
| <td colspan="6"> |
| <ft:widget id="addtwocontacts"/> |
| <ft:widget id="addcontact"/> |
| <jx:if test="${widget.getChild('contacts').getSize() > 0}"> |
| <ft:widget id="removecontacts"/> |
| <br/> |
| <small>Hint: remove all contacts to see how dynamic form templates can change |
| their layout depending on widget values</small> |
| </jx:if> |
| </td> |
| </tr> |
| </table> |
| <input type="submit"/> |
| </div> |
| </ft:form-template> |
| <p> |
| <a href="./">Back to Forms samples</a> |
| </p> |
| </content> |
| </page> |