KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > woody > binding > SimpleRepeaterJXPathBindingBuilder


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.woody.binding;
17
18 import org.apache.cocoon.woody.util.DomHelper;
19 import org.w3c.dom.Element JavaDoc;
20
21 /**
22  * A simple repeater binding that will replace (i.e. delete then re-add all) its
23  * content.
24  * <pre>
25  * &lt;wb:simple-repeater
26  * id="contacts"
27  * parent-path="contacts"&gt;
28  * &lt;<em>... child bindings ...</em>
29  * &lt;/wb:simple-repeater&gt;
30  * </pre>
31  *
32  * @author <a HREF="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
33  * @version CVS $Id: SimpleRepeaterJXPathBindingBuilder.java 30932 2004-07-29 17:35:38Z vgritsenko $
34  */

35 public class SimpleRepeaterJXPathBindingBuilder
36     extends JXPathBindingBuilderBase {
37
38     public JXPathBindingBase buildBinding(Element JavaDoc bindingElem,
39         JXPathBindingManager.Assistant assistant) throws BindingException {
40         try {
41             CommonAttributes commonAtts =
42                 JXPathBindingBuilderBase.getCommonAttributes(bindingElem);
43
44             String JavaDoc repeaterId = DomHelper.getAttribute(bindingElem, "id");
45             String JavaDoc parentPath = DomHelper.getAttribute(
46                     bindingElem, "parent-path");
47             String JavaDoc rowPath = DomHelper.getAttribute(bindingElem, "row-path");
48             boolean clearOnLoad = DomHelper.getAttributeAsBoolean(
49                     bindingElem, "clear-before-load", true);
50             boolean deleteIfEmpty = DomHelper.getAttributeAsBoolean(
51                     bindingElem, "delete-parent-if-empty", false);
52
53             JXPathBindingBase[] childBindings =
54                 assistant.makeChildBindings(bindingElem);
55
56             return new SimpleRepeaterJXPathBinding(commonAtts, repeaterId,
57                     parentPath, rowPath, clearOnLoad, deleteIfEmpty,
58                     new ComposedJXPathBindingBase(
59                             JXPathBindingBuilderBase.CommonAttributes.DEFAULT,
60                             childBindings));
61         } catch (BindingException e) {
62             throw e;
63         } catch (Exception JavaDoc e) {
64             throw new BindingException(
65                     "Error building repeater binding defined at " +
66                     DomHelper.getLocation(bindingElem), e);
67         }
68     }
69 }
70
Popular Tags