View Javadoc

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  
20  package org.apache.myfaces.custom.inputAjax;
21  
22  import java.io.IOException;
23  
24  import javax.faces.context.FacesContext;
25  import javax.faces.render.Renderer;
26  
27  import org.apache.commons.logging.Log;
28  import org.apache.commons.logging.LogFactory;
29  import org.apache.myfaces.component.html.ext.HtmlSelectOneRadio;
30  import org.apache.myfaces.custom.ajax.AjaxCallbacks;
31  import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
32  import org.apache.myfaces.custom.ajax.api.DeprecatedAjaxComponent;
33  
34  /**
35   * Extends standard selectOneRadio allowing for dynamic ajax submitting.
36   * 
37   * @JSFComponent
38   *   name = "s:selectOneRadioAjax"
39   *   class = "org.apache.myfaces.custom.inputAjax.HtmlSelectOneRadioAjax"
40   *   tagClass = "org.apache.myfaces.custom.inputAjax.HtmlSelectOneRadioAjaxTag"
41   *   
42   * User: treeder
43   * Date: Nov 10, 2005
44   * Time: 4:45:09 PM
45   */
46  public abstract class AbstractHtmlSelectOneRadioAjax extends HtmlSelectOneRadio implements DeprecatedAjaxComponent, AjaxCallbacks
47  {
48      private static final Log log = LogFactory.getLog(AbstractHtmlSelectOneRadioAjax.class);
49      public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlSelectOneRadioAjax";
50      public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.SelectOneRadioAjax";
51  
52      public AbstractHtmlSelectOneRadioAjax()
53      {
54          super();
55          setRendererType(DEFAULT_RENDERER_TYPE);
56      }
57  
58      /**
59       * Decode ajax request and apply value changes
60       *
61       * @param context
62       */
63      public void decodeAjax(FacesContext context)
64      {
65          log.debug("entering HtmlSelectOneRadioAjax.decodeAjax");
66  
67          processDecodes(context);
68          processValidators(context);
69          processUpdates(context);
70          //context.getViewRoot().processApplication(context);
71          if (log.isDebugEnabled())
72          {
73              Object valOb = this.getValue();
74              log.debug("value object after decodeAjax: " + valOb);
75          }
76      }
77  
78      public void encodeAjax(FacesContext context) throws IOException
79      {
80          //log.debug("encodeAjax in HtmlSelectManyCheckbox");
81          if (context == null) throw new NullPointerException("context");
82          if (!isRendered()) return;
83          Renderer renderer = getRenderer(context);
84  
85          if (renderer != null && renderer instanceof AjaxRenderer)
86          {
87              ((AjaxRenderer) renderer).encodeAjax(context, this);
88  
89          }
90      }
91  
92      /**
93       * Javascript method to call on successful ajax update
94       * 
95       * @JSFProperty
96       */
97      public abstract String getOnSuccess();
98  
99      /**
100      * Javascript method to call on failed ajax update
101      * 
102      * @JSFProperty
103      */
104     public abstract String getOnFailure();
105 
106     /**
107      * Javascript method to call on start of ajax update
108      * 
109      * @JSFProperty
110      */
111     public abstract String getOnStart();
112     
113 }