KickJava   Java API By Example, From Geeks To Geeks.

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


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.Struct;
19 import org.apache.cocoon.forms.formmodel.Widget;
20 import org.apache.commons.jxpath.JXPathContext;
21
22 /**
23  * StructJXPathBinding 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: StructJXPathBinding.java 289538 2005-09-16 13:46:22Z sylvain $
32  */

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

43     public StructJXPathBinding(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         Struct structWidget = (Struct)selectWidget(frmModel, this.widgetId);
57         super.doLoad(structWidget, 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         Struct structWidget = (Struct)selectWidget(frmModel, this.widgetId);
67         super.doSave(structWidget, jxpc);
68     }
69
70     public String JavaDoc toString() {
71         return "StructJXPathBinding [widget=" + this.widgetId + ", xpath=" + getXPath() + "]";
72     }
73 }
74
Popular Tags