KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > forms > binding > GroupJXPathBinding


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.forms.binding;
17
18 import org.apache.cocoon.forms.formmodel.Group;
19 import org.apache.cocoon.forms.formmodel.Widget;
20 import org.apache.commons.jxpath.JXPathContext;
21
22 /**
23  * GroupJXPathBinding provides an implementation of a {@link Binding}
24  * that narrows the context towards provided childbindings.
25  * <p>
26  * NOTES: <ol>
27  * <li>This Binding assumes that the provided widget-id points to a widget
28  * that contains other widgets.</li>
29  * </ol>
30  *
31  * @version $Id$
32  */

33 public class GroupJXPathBinding extends ContextJXPathBinding {
34
35     private final String JavaDoc widgetId;
36
37     /**
38      * Constructs GroupJXPathBinding
39      * @param widgetId
40      * @param xpath
41      * @param childBindings
42      */

43     public GroupJXPathBinding(JXPathBindingBuilderBase.CommonAttributes commonAtts, String JavaDoc widgetId, String JavaDoc xpath, JXPathBindingBase[] childBindings) {
44         super(commonAtts, xpath, childBindings);
45         this.widgetId = widgetId;
46     }
47
48     public String JavaDoc getId() { return widgetId; }
49     
50     /**
51      * Narrows the scope on the form-model to the member widget-field, and
52      * narrows the scope on the object-model to the member xpath-context
53      * before continuing the binding over the child-bindings.
54      */

55     public void doLoad(Widget frmModel, JXPathContext jxpc) throws BindingException {
56         Group groupWidget = (Group)selectWidget(frmModel, this.widgetId);
57         super.doLoad(groupWidget, jxpc);
58     }
59
60     /**
61      * Narrows the scope on the form-model to the member widget-field, and
62      * narrows the scope on the object-model to the member xpath-context
63      * before continuing the binding over the child-bindings.
64      */

65     public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException {
66         Group groupWidget = (Group)selectWidget(frmModel, this.widgetId);
67         super.doSave(groupWidget, jxpc);
68     }
69
70     public String JavaDoc toString() {
71         return "GroupJXPathBinding [widget=" + this.widgetId + ", xpath=" + getXPath() + "]";
72     }
73 }
74
Popular Tags