1 15 package org.apache.tapestry.wap.quiz; 16 17 import org.apache.tapestry.IRequestCycle; 18 import org.apache.tapestry.form.IPropertySelectionModel; 19 import org.apache.tapestry.form.StringPropertySelectionModel; 20 import org.apache.tapestry.wml.Deck; 21 22 33 34 public abstract class Home extends Deck 35 { 36 37 public static final IPropertySelectionModel LEVEL_MODEL = new StringPropertySelectionModel 38 (new String [] { Global.EASY_LEVEL, Global.MEDIUM_LEVEL, Global.HARD_LEVEL }); 39 40 public void start(IRequestCycle cycle) 41 { 42 Global global = (Global) getGlobal(); 43 global.initialize(cycle); 44 Visit visit = (Visit) getVisit(); 45 String level = getLevel(); 46 int questionSet = global.getQuestionSet(level); 47 String username = getUsername(); 48 if (username == null || "".equals(username)) 49 username = "newcomer"; 50 visit.initialize(username, level, questionSet, global.getNumberOfQuestions(questionSet)); 51 Quiz quizDeck = (Quiz) cycle.getPage("Quiz"); 52 quizDeck.setQuestionNumber(0); 53 quizDeck.fetch(); 54 cycle.activate(quizDeck); 55 } 56 57 public abstract String getUsername(); 58 public abstract void setUsername(String username); 59 60 public abstract String getLevel(); 61 public abstract void setLevel(String level); 62 } 63 | Popular Tags |