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.flow.builder;
20  
21  import javax.el.ValueExpression;
22  import javax.faces.flow.builder.FlowCallBuilder;
23  import org.apache.myfaces.flow.FlowCallNodeImpl;
24  import org.apache.myfaces.flow.FlowImpl;
25  import org.apache.myfaces.flow.ParameterImpl;
26  import org.apache.myfaces.view.facelets.el.ELText;
27  
28  /**
29   *
30   * @since 2.2
31   * @author Leonardo Uribe
32   */
33  public class FlowCallBuilderImpl extends FlowCallBuilder
34  {
35      private FlowBuilderImpl _flowBuilder;
36      private FlowImpl _facesFlow;
37      private FlowCallNodeImpl _flowCallNode;
38  
39      public FlowCallBuilderImpl(FlowBuilderImpl flowBuilder, FlowImpl facesFlow, String flowCallNodeId)
40      {
41          this._flowBuilder = flowBuilder;
42          this._facesFlow = facesFlow;
43          this._flowCallNode = new FlowCallNodeImpl(flowCallNodeId);
44          this._facesFlow.putFlowCall(flowCallNodeId, _flowCallNode);
45      }
46  
47      @Override
48      public FlowCallBuilder flowReference(String flowDocumentId, String flowId)
49      {
50          if (ELText.isLiteral(flowDocumentId))
51          {
52              this._flowCallNode.setCalledFlowDocumentId(flowDocumentId);
53          }
54          else
55          {
56              this._flowCallNode.setCalledFlowDocumentId(_flowBuilder.createValueExpression(flowDocumentId));
57          }
58          if (ELText.isLiteral(flowId))
59          {
60              this._flowCallNode.setCalledFlowId(flowId);
61          }
62          else
63          {
64              this._flowCallNode.setCalledFlowId(_flowBuilder.createValueExpression(flowId));
65          }
66          return this;
67      }
68  
69      @Override
70      public FlowCallBuilder outboundParameter(String name, ValueExpression value)
71      {
72          this._flowCallNode.putOutboundParameter(name, new ParameterImpl(name, value));
73          return this;
74      }
75  
76      @Override
77      public FlowCallBuilder outboundParameter(String name, String value)
78      {
79          this._flowCallNode.putOutboundParameter(name, new ParameterImpl(name, 
80              this._flowBuilder.createValueExpression(value)));
81          return this;
82      }
83  
84      @Override
85      public FlowCallBuilder markAsStartNode()
86      {
87          _facesFlow.setStartNodeId(_flowCallNode.getId());
88          return this;
89      }
90      
91  }