| <?xml version="1.0" encoding="UTF-8"?> |
| |
| <!-- |
| * 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. |
| --> |
| |
| <ui:composition template="/main.xhtml" |
| xmlns="http://www.w3.org/1999/xhtml" |
| xmlns:tc="http://myfaces.apache.org/tobago/component" |
| xmlns:ui="http://xmlns.jcp.org/jsf/facelets" |
| xmlns:f="http://xmlns.jcp.org/jsf/core"> |
| |
| <p>On this page the collapsible concept is explained for a |
| <tc:link label="Box" outcome="/content/20-component/050-container/10-box/Box.xhtml"/>.</p> |
| |
| <tc:section label="Simple Collapsible Box"> |
| <tc:form id="controller"> |
| <p>This is a simple collapsible box which open and close the content via a controller.</p> |
| <demo-highlight language="markup"><tc:button label="show" immediate="true" |
| action="\#{collapsibleBoxController.showCollapsed1}"/></demo-highlight> |
| <tc:box label="Box" collapsed="#{collapsibleBoxController.collapsed}" collapsedMode="absent"> |
| <f:facet name="bar"> |
| <tc:buttons> |
| <tc:button id="show" label="show" immediate="true" action="#{collapsibleBoxController.show}"/> |
| <tc:button id="hide" label="hide" immediate="true" action="#{collapsibleBoxController.hide}"/> |
| </tc:buttons> |
| </f:facet> |
| <tc:out id="content" value="Content"/> |
| </tc:box> |
| </tc:form> |
| </tc:section> |
| |
| <tc:section label="Full Server Request"> |
| <tc:form id="server"> |
| <p>In this example, the operaction tag is used to change the state of the boxes.</p> |
| <demo-highlight language="markup"><tc:box id="box1" label="Full Request Box 1" collapsedMode="absent"> |
| <f:facet name="bar"> |
| <tc:buttons> |
| <tc:button label="show"> |
| <tc:operation name="show" for="box1"/> |
| ...</demo-highlight> |
| <tc:box id="box1" label="Full Request Box 1" collapsedMode="absent"> |
| <f:facet name="bar"> |
| <tc:buttons> |
| <tc:button id="show1" label="show"> |
| <tc:operation name="show" for="box1"/> |
| </tc:button> |
| <tc:button id="hide1" label="hide"> |
| <tc:operation name="hide" for="box1"/> |
| </tc:button> |
| </tc:buttons> |
| </f:facet> |
| <tc:out id="content1" value="Content"/> |
| </tc:box> |
| <tc:box id="box2" label="Full Request Box 2" collapsedMode="absent"> |
| <f:facet name="bar"> |
| <tc:buttons> |
| <tc:button id="show2" label="show"> |
| <tc:operation name="show" for="box2"/> |
| </tc:button> |
| <tc:button id="hide2" label="hide"> |
| <tc:operation name="hide" for="box2"/> |
| </tc:button> |
| </tc:buttons> |
| </f:facet> |
| <tc:out id="content2" value="Content"/> |
| </tc:box> |
| </tc:form> |
| </tc:section> |
| |
| <tc:section label="Client Side"> |
| <tc:form id="client"> |
| <p>This example show a content box which could be opened and closed without a server request.<br/> |
| To render the hidden content of the box, <code>collapsedMode="hidden"</code> must be set. |
| The content is hidden by CSS display property.</p> |
| <p>Also the content contain a required input field. |
| This field will be also validated if the content is hidden.<br/> |
| To demonstrate that, leave the input field blank, hide the content and press the 'Submit'-button.</p> |
| <p>Notice the <code>omit</code> attribute of the buttons is set to avoid server request.</p> |
| <demo-highlight language="markup"><tc:box id="noRequestBox" label="No Request Box" |
| collapsed="true" collapsedMode="hidden"> |
| <tc:button label="show" omit="true"> |
| <tc:operation name="show" for="noRequestBox"/> |
| ...</demo-highlight> |
| <tc:box id="noRequestBox" label="No Request Box" collapsed="true" collapsedMode="hidden"> |
| <f:facet name="bar"> |
| <tc:buttons> |
| <tc:button id="showNoRequestBox" label="show" omit="true"> |
| <tc:operation name="show" for="noRequestBox"/> |
| </tc:button> |
| <tc:button id="hideNoRequestBox" label="hide" omit="true"> |
| <tc:operation name="hide" for="noRequestBox"/> |
| </tc:button> |
| </tc:buttons> |
| </f:facet> |
| <tc:in id="inNoRequestBox" label="Required" required="true"/> |
| </tc:box> |
| <tc:button id="submitNoRequestBox" label="Submit"/> |
| </tc:form> |
| </tc:section> |
| |
| <tc:section label="Ajax"> |
| <tc:form id="ajax"> |
| <p>Here we have the transitions <code>show</code> and <code>hide</code> with AJAX request. |
| The buttons have set <code>omit="false"</code> which is the default. |
| Also the attribute <code>immediate="true"</code> is set to execute the transition without validation.</p> |
| <p>The mode is set to <code>collapsedMode="absent"</code> (default), so the hidden content won't be rendered |
| and therefor not validated.</p> |
| <p>You can press the 'Submit'-button after hiding the blank input field. |
| The submit will be executed without validation. |
| If the content is shown and the field is empty, a violation occurs after hitting 'Submit'.</p> |
| <demo-highlight language="markup"><tc:box id="ajaxBox" label="Collapsible Box (AJAX)" collapsedMode="absent"> |
| ... |
| <tc:button label="show" immediate="true"> |
| <f:ajax execute="ajaxBox" render="ajaxBox"/> |
| <tc:operation name="show" for="ajaxBox"/> |
| ...</demo-highlight> |
| <tc:box id="ajaxBox" label="Ajax Box" collapsedMode="absent"> |
| <f:facet name="bar"> |
| <tc:buttons> |
| <tc:button id="showAjaxBox" label="show" immediate="true"> |
| <f:ajax execute="ajaxBox" render="ajaxBox"/> |
| <tc:operation name="show" for="ajaxBox"/> |
| </tc:button> |
| <tc:button id="hideAjaxBox" label="hide" immediate="true"> |
| <f:ajax execute="ajaxBox" render="ajaxBox"/> |
| <tc:operation name="hide" for="ajaxBox"/> |
| </tc:button> |
| </tc:buttons> |
| </f:facet> |
| <tc:in id="inAjaxBox" label="Required" required="true"/> |
| </tc:box> |
| <tc:button id="submitAjaxBox" label="Submit"/> |
| </tc:form> |
| </tc:section> |
| </ui:composition> |