KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > wap > renderkit > wml > FormRenderer


1 /*
2  * Copyright 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.myfaces.wap.renderkit.wml;
17
18 import java.util.Map JavaDoc;
19
20 import javax.faces.component.UIComponent;
21 import javax.faces.component.UIForm;
22 import javax.faces.context.FacesContext;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.myfaces.wap.renderkit.Attributes;
27 import org.apache.myfaces.wap.renderkit.WmlRenderer;
28
29
30 /**
31  * @author <a HREF="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author: matzew $)
32  * @version $Revision: 1.1 $ $Date: 2004/12/30 09:37:26 $
33  * $Log: FormRenderer.java,v $
34  * Revision 1.1 2004/12/30 09:37:26 matzew
35  * added a new RenderKit for WML. Thanks to Jirí Žaloudek
36  *
37  */

38 public class FormRenderer extends WmlRenderer {
39     private static Log log = LogFactory.getLog(FormRenderer.class);
40     
41     /** Creates a new instance of FormRenderer */
42     public FormRenderer() {
43         super();
44         log.debug("created object " + this.getClass().getName());
45     }
46     
47     public void encodeBegin(FacesContext context, UIComponent component) throws java.io.IOException JavaDoc {
48         log.debug("encodeBegin(" + component.getId() + ")");
49         if (context == null || component == null) {
50             throw new NullPointerException JavaDoc();
51         }
52         if (!component.isRendered()) return;
53     }
54     
55     public void encodeChildren(FacesContext context, UIComponent component) throws java.io.IOException JavaDoc {
56         log.debug("encodeChildren(" + component.getId() + ")");
57         if (context == null || component == null) {
58             throw new NullPointerException JavaDoc();
59         }
60     }
61     
62     public void encodeEnd(FacesContext context, UIComponent component) throws java.io.IOException JavaDoc {
63         log.debug("encodeEnd(" + component.getId() + ")");
64         if (context == null || component == null) {
65             throw new NullPointerException JavaDoc();
66         }
67         if (!component.isRendered()) return;
68
69         // write state marker
70
context.getApplication().getViewHandler().writeState(context);
71     }
72     
73     
74     public void decode(FacesContext context, UIComponent component) {
75         log.debug("decode(" + component.getId() + ")");
76         if (component == null ) throw new NullPointerException JavaDoc();
77         
78         Map JavaDoc params = context.getExternalContext().getRequestParameterMap();
79         
80         if (params.containsKey(component.getClientId(context) + Attributes.POSTFIX_SUBMITED)){
81             ((UIForm)component).setSubmitted(true);
82             log.debug("form submited");
83         }
84         else{ ((UIForm)component).setSubmitted(false);
85              log.debug("form not submited");
86         }
87         
88         /* TODO: correct the Duplicate component ID bug */
89         //context.getViewRoot().setTransient(true);
90
}
91     
92     
93     
94 }
95
Popular Tags