| <?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:f="http://java.sun.com/jsf/core" |
| xmlns:tc="http://myfaces.apache.org/tobago/component" |
| xmlns:ui="http://java.sun.com/jsf/facelets"> |
| |
| <p>There are two kinds of behaviors: </p> |
| <ul> |
| <li><code class="language-markup"><f:ajax/></code> send an ajax request</li> |
| <li><code class="language-markup"><tc:event/></code> do a full page reload</li> |
| </ul> |
| <p>Tag Library Documentation: |
| <tc:link label="<f:ajax/>" image="#{request.contextPath}/image/feather-leaf.png" |
| link="http://docs.oracle.com/javaee/6/javaserverfaces/2.1/docs/vdldocs/facelets/f/ajax.html"/> |
| | |
| <tc:link label="<tc:event/>" image="#{request.contextPath}/image/feather-leaf.png" |
| link="#{apiController.base}/doc/#{apiController.currentRelease}/tld/tc/event.html"/></p> |
| |
| <tc:section label="Basic examples"> |
| <p>Type a text into the input field. After leaving the input field, the given text is shown in the output field.</p> |
| <tc:section label="f:ajax"> |
| <pre><code class="language-markup"><tc:in label="Ajax Input" value="\#{behaviorController.ajax}"> |
| <f:ajax render="outAjax"/> |
| </tc:in></code></pre> |
| <tc:in label="Ajax Input" value="#{behaviorController.ajax}"> |
| <f:ajax render="outAjax"/> |
| </tc:in> |
| <tc:out id="outAjax" label="Ajax Output" value="#{behaviorController.ajax}"/> |
| </tc:section> |
| |
| <tc:section label="tc:event"> |
| <pre><code class="language-markup"><tc:in label="Event Input" value="\#{behaviorController.event}"> |
| <tc:event/> |
| </tc:in></code></pre> |
| |
| <tc:in label="Event Input" value="#{behaviorController.event}"> |
| <tc:event/> |
| </tc:in> |
| <tc:out label="Event Output" value="#{behaviorController.event}"/> |
| </tc:section> |
| </tc:section> |
| |
| <tc:section label="Change the event name"> |
| <p>It's possible to change the event name. For example if you want a double click event, change the event name to |
| <code>dblclick</code>. This is done for the following two buttons.</p> |
| |
| <pre><code class="language-markup"><tc:button label="Ajax Double Click"> |
| <f:ajax event="dblclick" render="outCounter" listener="..."/> |
| </tc:button> |
| <tc:button label="Event Double Click"> |
| <tc:event event="dblclick" actionListener="..."/> |
| </tc:button></code></pre> |
| <tc:button label="Ajax Double Click"> |
| <f:ajax event="dblclick" render="outCounter" listener="#{behaviorController.countUp}"/> |
| </tc:button> |
| <tc:button label="Event Double Click"> |
| <tc:event event="dblclick" actionListener="#{behaviorController.countUp}"/> |
| </tc:button> |
| <tc:out id="outCounter" label="Counter" value="#{behaviorController.counter}"/> |
| </tc:section> |
| |
| <tc:section label="Advanced"> |
| <p><code class="language-markup"><tc:event></code> may contain <code class="language-markup"><f:ajax></code> |
| and <code class="language-markup"><tc:operation></code> tags.</p> |
| <p>This is helpfull if the parent component cannot handle operations by itself.</p> |
| <p><tc:badge value="Important" markup="danger"/> |
| The <code>event</code> attribute of the ajax children will be ignored.</p> |
| |
| <tc:section label="Example"> |
| <p>An example can be found for |
| <tc:link label="<tc:row>" outcome="/content/20-component/080-sheet/30-event/Sheet_Event.xhtml"/> |
| Option: 'open popup on click with AJAX'.</p> |
| <pre><code class="language-markup"><tc:row> |
| <tc:event> |
| <f:ajax execute=":::popup" render=":::popup" listener="..."/> |
| <tc:operation name="show" for=":::popup"/> |
| </tc:event> |
| </tc:row></code></pre> |
| </tc:section> |
| </tc:section> |
| </ui:composition> |