1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.custom.inputAjax;
20
21 import java.io.IOException;
22
23 import javax.faces.context.FacesContext;
24 import javax.faces.render.Renderer;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28 import org.apache.myfaces.component.html.ext.HtmlInputText;
29 import org.apache.myfaces.custom.ajax.AjaxCallbacks;
30 import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
31 import org.apache.myfaces.custom.ajax.api.DeprecatedAjaxComponent;
32
33 /**
34 * Extends standard inputText allowing for dynamic ajax submitting.
35 *
36 * @JSFComponent
37 * name = "s:inputTextAjax"
38 * class = "org.apache.myfaces.custom.inputAjax.HtmlInputTextAjax"
39 * tagClass = "org.apache.myfaces.custom.inputAjax.HtmlInputTextAjaxTag"
40 *
41 * User: treeder
42 * Date: Oct 28, 2005
43 * Time: 7:48:57 PM
44 */
45 public abstract class AbstractHtmlInputTextAjax extends HtmlInputText implements DeprecatedAjaxComponent, AjaxCallbacks
46 {
47 private static final Log log = LogFactory.getLog(AbstractHtmlInputTextAjax.class);
48 public static final String COMPONENT_TYPE = "org.apache.myfaces.InputTextAjax";
49 public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.InputTextAjax";
50
51 /**
52 * Decode ajax request and apply value changes
53 *
54 * @param context
55 */
56 public void decodeAjax(FacesContext context)
57 {
58 log.debug("entering HtmlInputTextAjax.decodeAjax");
59
60 processDecodes(context);
61 processValidators(context);
62 processUpdates(context);
63 //context.getViewRoot().processApplication(context);
64 if (log.isDebugEnabled())
65 {
66 Object valOb = this.getValue();
67 log.debug("value object after decodeAjax: " + valOb);
68 }
69
70 }
71
72 public void encodeAjax(FacesContext context) throws IOException
73 {
74 log.debug("encodeAjax in HtmlInputTextAjax");
75 if (context == null) throw new NullPointerException("context");
76 if (!isRendered()) return;
77 Renderer renderer = getRenderer(context);
78 if (renderer != null && renderer instanceof AjaxRenderer)
79 {
80 ((AjaxRenderer) renderer).encodeAjax(context, this);
81
82 }
83 }
84
85 /**
86 * Javascript method to call on successful ajax update
87 *
88 * @JSFProperty
89 */
90 public abstract String getOnSuccess();
91
92 /**
93 * Javascript method to call on failed ajax update
94 *
95 * @JSFProperty
96 */
97 public abstract String getOnFailure();
98
99 /**
100 * Javascript method to call on start of ajax update
101 *
102 * @JSFProperty
103 */
104 public abstract String getOnStart();
105
106 /**
107 * Whether to show an ok button before sending update.
108 *
109 * @JSFProperty
110 * defaultValue = "false"
111 */
112 public abstract Boolean getShowOkButton();
113
114 /**
115 * Test for button
116 *
117 * @JSFProperty
118 */
119 public abstract String getOkText();
120
121 /**
122 * Whether to show cancel button
123 *
124 * @JSFProperty
125 * defaultValue = "true"
126 */
127 public abstract Boolean getShowCancelButton();
128
129 /**
130 * Text for cancel
131 *
132 * @JSFProperty
133 */
134 public abstract String getCancelText();
135
136 /**
137 * StyleClass for the input field where the error occures.
138 * Useful if there is only one messages area for a few inputTextAjax fields
139 *
140 * @JSFProperty
141 */
142 public abstract String getErrorStyleClass();
143
144 /**
145 * Style for the input field where the error occures. Useful if there is
146 * only one messages area for a few inputTextAjax fields
147 *
148 * @JSFProperty
149 */
150 public abstract String getErrorStyle();
151
152 }