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  package org.apache.myfaces.custom.conversation;
20  
21  import javax.faces.component.UICommand;
22  import javax.faces.context.FacesContext;
23  import javax.faces.el.ValueBinding;
24  
25  /**
26   * base class for all the conversation components
27   * 
28   * @JSFComponent
29   *   configExcluded = "true"
30   *   tagClass = "org.apache.myfaces.custom.conversation.AbstractConversationTag"
31   *   
32   * @author imario@apache.org
33   */
34  public class AbstractConversationComponent extends UICommand
35  {
36      public static final String COMPONENT_FAMILY = "javax.faces.Component";
37  
38      private String name;
39  
40      public AbstractConversationComponent()
41      {
42          setRendererType(null);
43      }
44  
45      public String getFamily()
46      {
47          return COMPONENT_FAMILY;
48      }
49  
50      public void restoreState(FacesContext context, Object state)
51      {
52          Object[] states = (Object[]) state;
53  
54          super.restoreState(context, states[0]);
55          name = (String) states[1];
56      }
57  
58      public Object saveState(FacesContext context)
59      {
60          return new Object[]
61          {
62              super.saveState(context),
63              name
64          };
65      }
66  
67      /**
68       * the name of the conversation. Notice: required if tag not as child of startConversation tag.
69       * 
70       * @JSFProperty
71       */
72      public String getName()
73      {
74          if (name!= null)
75          {
76              return name;
77          }
78          ValueBinding vb = getValueBinding("name");
79          if( vb == null )
80          {
81              return null;
82          }
83          return (String) vb.getValue(getFacesContext());
84      }
85  
86      /**
87       * the conversation name
88       */
89      public void setName(String name)
90      {
91          this.name = name;
92      }
93  }