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

For more information, please explore the Attic.

Coverage Report - org.apache.shale.examples.test.dialog.basic.Popup
 
Classes in this File Line Coverage Branch Coverage Complexity
Popup
0%
0/20
N/A
1
 
 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  
  * $Id: Popup.java 469357 2006-10-31 03:28:36Z rahul $
 18  
  */
 19  
 
 20  
 package org.apache.shale.examples.test.dialog.basic;
 21  
 
 22  
 import javax.faces.context.FacesContext;
 23  
 import javax.faces.el.ValueBinding;
 24  
 
 25  
 import org.apache.shale.dialog.Constants;
 26  
 import org.apache.shale.dialog.DialogContext;
 27  
 
 28  
 /**
 29  
  * <p>Event handlers for the "PopUp" dialog.</p>
 30  
  */
 31  0
 public class Popup {
 32  
     
 33  
 
 34  
     /**
 35  
      * <p>Cancel the popup dialog.</p>
 36  
      */
 37  
     public String cancel() {
 38  
 
 39  
         // Do not copy anything back to our parent dialog's data
 40  0
         return "cancelled";
 41  
 
 42  
     }
 43  
 
 44  
 
 45  
     /**
 46  
      * <p>Refresh the list of cities for the currently selected state.</p>
 47  
      */
 48  
     public String refresh() {
 49  
 
 50  
         // The act of updating our selected state is all we need to do
 51  0
         return null;
 52  
 
 53  
     }
 54  
 
 55  
 
 56  
     /**
 57  
      * <p>Set up the data for this dialog.</p>
 58  
      */
 59  
     public String setup() {
 60  
 
 61  
         // Import the currently selected state from our parent dialog
 62  0
         FacesContext context = FacesContext.getCurrentInstance();
 63  0
         ValueBinding vb = context.getApplication().createValueBinding("#{dialog.parent.data.state}");
 64  0
         String state = (String) vb.getValue(context);
 65  
 
 66  
         // Set the currently selected state into our dialog data
 67  0
         DialogContext dcontext = (DialogContext)
 68  
           context.getApplication().getVariableResolver().
 69  
           resolveVariable(context, Constants.CONTEXT_BEAN);
 70  0
         PopupData data = (PopupData) dcontext.getData();
 71  0
         data.setState(state);
 72  
 
 73  
         // Proceed to the first page of the popup
 74  0
         return "success";
 75  
 
 76  
     }
 77  
 
 78  
 
 79  
     /**
 80  
      * <p>Select the row corresponding to this button.</p>
 81  
      */
 82  
     public String select() {
 83  
 
 84  
         // Identify the selected row from the table
 85  0
         FacesContext context = FacesContext.getCurrentInstance();
 86  0
         City city = (City)
 87  
           context.getApplication().getVariableResolver().
 88  
           resolveVariable(context, "city");
 89  
 
 90  
         // Copy relevant values back to our parent dialog's data
 91  0
         ValueBinding vb = null;
 92  0
         vb = context.getApplication().createValueBinding("#{dialog.parent.data.city}");
 93  0
         vb.setValue(context, city.getCity());
 94  0
         vb = context.getApplication().createValueBinding("#{dialog.parent.data.state}");
 95  0
         vb.setValue(context, city.getState());
 96  0
         vb = context.getApplication().createValueBinding("#{dialog.parent.data.zipCode}");
 97  0
         vb.setValue(context, city.getZipCode());
 98  
 
 99  
         // Exit the dialog now that we have copied back the relevant values
 100  0
         return "finished";
 101  
 
 102  
     }
 103  
 
 104  
 
 105  
 }