KickJava   Java API By Example, From Geeks To Geeks.

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


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.formmodel.Widget;
19 import org.apache.commons.jxpath.JXPathContext;
20
21 /**
22  * SetAttributeJXPathBinding provides an implementation of a {@link Binding}
23  * that sets a particular attribute to a fixed value upon save.
24  * <p>
25  * NOTES: <ol>
26  * <li>This Binding does not perform any actions when loading.</li>
27  * </ol>
28  *
29  * @version CVS $Id: SetAttributeJXPathBinding.java 30932 2004-07-29 17:35:38Z vgritsenko $
30  */

31 public class SetAttributeJXPathBinding extends JXPathBindingBase {
32
33     private final String JavaDoc name;
34     private final String JavaDoc value;
35
36     /**
37      * Constructs SetAttributeJXPathBinding
38      */

39     public SetAttributeJXPathBinding(JXPathBindingBuilderBase.CommonAttributes commonAtts, String JavaDoc attName, String JavaDoc attValue) {
40         super(commonAtts);
41         this.name = attName;
42         this.value = attValue;
43     }
44
45     /**
46      * Do-Nothing implementation.
47      */

48     public void doLoad(Widget frmModel, JXPathContext jxpc) {
49         //this does nothing in the loading of things
50
}
51
52     /**
53      * Sets the attribute value on the passed JXPathContext
54      */

55     public void doSave(Widget frmModel, JXPathContext jxpc) {
56         jxpc.setValue("@" + this.name, this.value);
57         if (getLogger().isDebugEnabled())
58             getLogger().debug("done saving " + toString());
59     }
60
61     public String JavaDoc toString() {
62         return "SetAttributeJXPathBinding [attName=" + this.name + ", attValue=" + this.value + "]";
63     }
64 }
65
Popular Tags