001 // Copyright 2004, 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.tapestry.junit.mock.c11; 016 017 import org.apache.tapestry.IRequestCycle; 018 import org.apache.tapestry.html.BasePage; 019 020 /** 021 * Used to test the Select and Option elements. 022 * 023 * @author Howard Lewis Ship 024 * @since 3.0 025 */ 026 027 public abstract class SelectPage extends BasePage 028 { 029 public abstract boolean isAnimal(); 030 031 public abstract boolean isMineral(); 032 033 public abstract boolean isVegetable(); 034 035 public abstract void setAnimal(boolean animal); 036 037 public abstract void setMineral(boolean mineral); 038 039 public abstract void setVegetable(boolean vegetable); 040 041 public void formSubmit(IRequestCycle cycle) 042 { 043 StringBuffer buffer = new StringBuffer("Selections: "); 044 boolean needComma = false; 045 046 if (isAnimal()) 047 { 048 buffer.append("animal"); 049 needComma = true; 050 } 051 052 if (isVegetable()) 053 { 054 if (needComma) 055 buffer.append(", "); 056 057 buffer.append("vegetable"); 058 059 needComma = true; 060 } 061 062 if (isMineral()) 063 { 064 if (needComma) 065 buffer.append(", "); 066 067 buffer.append("mineral"); 068 069 needComma = true; 070 } 071 072 if (!needComma) 073 buffer.append("none"); 074 075 buffer.append("."); 076 077 Result result = (Result) cycle.getPage("Result"); 078 079 String message = buffer.toString(); 080 081 result.setMessage(message); 082 083 cycle.activate(result); 084 } 085 }