2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to you under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shale.usecases.jndi;
19  
20  import javax.faces.application.Application;
21  import javax.faces.context.FacesContext;
22  import javax.faces.el.ValueBinding;
23  
24  import org.apache.commons.logging.Log;
25  import org.apache.commons.logging.LogFactory;
26  import org.apache.shale.view.AbstractViewController;
27  
28  /***
29   * <p>Test page for JNDI access use case.</p>
30   *
31   * $Id: Test.java 464373 2006-10-16 04:21:54Z rahul $
32   */
33  public class Test extends AbstractViewController {
34      
35      
36      // -------------------------------------------------------- Static Variables
37  
38  
39      /***
40       * <p>The <code>Log</code> instance for this class.</p>
41       */
42      private static final Log log = LogFactory.getLog(Test.class);
43  
44  
45      // -------------------------------------------------------------- Properties
46  
47  
48      /***
49       * <p>The calculated actual value.</p>
50       */
51      private String actual = null;
52  
53  
54      /***
55       * <p>Return the actual calculated value.</p>
56       */
57      public String getActual() {
58  
59          return actual;
60  
61      }
62  
63  
64      /***
65       * <p>Return the expected trace string for the first page, which is
66       * only rendered.</p>
67       */
68      public String getExpected() {
69  
70          return "String Value/class java.lang.String/10/class java.lang.Integer/";
71  
72      }
73  
74  
75      // -------------------------------------------------- ViewController Methods
76  
77  
78      /***
79       * <p>Calculate the actual value.</p>
80       */
81      public void prerender() {
82  
83          FacesContext context = FacesContext.getCurrentInstance();
84          Application application = context.getApplication();
85          ValueBinding vb = null;
86          StringBuffer sb = new StringBuffer();
87  
88          vb = application.createValueBinding("#{jndi['env/String']}");
89          sb.append("" + vb.getValue(context) + "/");
90          sb.append("" + vb.getType(context) + "/");
91  
92          vb = application.createValueBinding("#{jndi['env/Integer']}");
93          sb.append("" + vb.getValue(context) + "/");
94          sb.append("" + vb.getType(context) + "/");
95  
96          actual = sb.toString();
97  
98      }
99  
100 
101 }