1 package com.openedit.modules.banner; 2 3 import java.util.Random ; 4 5 import com.openedit.WebPageRequest; 6 7 8 public class BannerModule { 9 10 Random fieldRandom; 11 12 public Random getRandom() 13 { 14 if (fieldRandom == null) 15 { 16 fieldRandom = new Random (); 17 } 18 return fieldRandom; 19 } 20 21 public void setRandom(Random inRandom) 22 { 23 fieldRandom = inRandom; 24 } 25 26 public void randomNumber(WebPageRequest inReq ) throws Exception 27 { 28 String toplimit = inReq.getCurrentAction().getChildValue("toplimit"); 29 if ( toplimit == null) 30 { 31 toplimit = "3"; 32 } 33 int topmost = Integer.parseInt(toplimit); 34 int num = getRandom().nextInt(topmost); 35 num++; 38 inReq.putPageValue( "bannernumber",String.valueOf( num ) ); 39 } 40 } 41 | Popular Tags |