# CustomerControlImpl.jcs Sample

This topic inludes the source code for the CustomerControlImpl.jcs Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebApp/handlingData/complexFormBean/controls/

## Sample Source Code

`01 package handlingData.complexFormBean.controls; 02 03 import com.bea.control.*; 04 import java.util.HashMap; 05 import java.util.Map; 06 /** 07 * @jcs:jc-jar label="CustomerControl" 08 * @editor-info:code-gen control-interface="true" 09 */ 10 public class CustomerControlImpl implements CustomerControl, ControlSource 11 { 12 private boolean outcome; 13 14 /** 15 * @common:operation 16 */ 17 public Customer getCustomer(int id) 18 { 19 // In a real-life example, the control would do business logic 20 // and return data (for instance, query a database and return the query results). 21 // For the sake of the sample, the same Customer object is returned no 22 // matter what id is passed to this method. 23 return new Customer("Dean", "John"); 24 } 25 26 /** 27 * @common:operation 28 */ 29 public boolean updateCustomer(Customer customer, String couponNumber) 30 { 31 // do business logic here. For instance, add the 32 // coupon number to a database. 33 // For the sake of the sample, we return true, if the couponNumber is less than 34 // 1000; we return false if if the coupon number is equal to or greater than 1000. 35 // We also return false if the couponNumber cannot be parsed as an integer. 36 try 37 { 38 // Try to parse the String as an integer. 39 int intCoupon = Integer.parseInt(couponNumber); 40 // If the parse is successful, and if the integer is less than 1000, then return ture. 41 if(intCoupon < 1000) 42 outcome = true; 43 // If the parse is successful, and if the integer is greater than or equal to 1000, then return false. 44 else 45 outcome = false; 46 } 47 // If the String can't be parsed, then return false. 48 catch (NumberFormatException e) 49 { 50 outcome = false; 51 } 52 return outcome; 53 } 54 }`