1 2 3 27 28 package jsp2.examples.simpletag; 29 30 import javax.servlet.jsp.JspException ; 31 import javax.servlet.jsp.tagext.JspFragment ; 32 import javax.servlet.jsp.tagext.SimpleTagSupport ; 33 import java.util.HashMap ; 34 import java.io.IOException ; 35 36 40 public class ShuffleSimpleTag extends SimpleTagSupport { 41 private JspFragment fragment1; 42 private JspFragment fragment2; 43 private JspFragment fragment3; 44 45 public void doTag() throws JspException , IOException { 46 switch( (int)(Math.random() * 6) ) { 47 case 0: 48 fragment1.invoke( null ); 49 fragment2.invoke( null ); 50 fragment3.invoke( null ); 51 break; 52 case 1: 53 fragment1.invoke( null ); 54 fragment3.invoke( null ); 55 fragment2.invoke( null ); 56 break; 57 case 2: 58 fragment2.invoke( null ); 59 fragment1.invoke( null ); 60 fragment3.invoke( null ); 61 break; 62 case 3: 63 fragment2.invoke( null ); 64 fragment3.invoke( null ); 65 fragment1.invoke( null ); 66 break; 67 case 4: 68 fragment3.invoke( null ); 69 fragment1.invoke( null ); 70 fragment2.invoke( null ); 71 break; 72 case 5: 73 fragment3.invoke( null ); 74 fragment2.invoke( null ); 75 fragment1.invoke( null ); 76 break; 77 } 78 } 79 80 public void setFragment1( JspFragment fragment1 ) { 81 this.fragment1 = fragment1; 82 } 83 84 public void setFragment2( JspFragment fragment2 ) { 85 this.fragment2 = fragment2; 86 } 87 88 public void setFragment3( JspFragment fragment3 ) { 89 this.fragment3 = fragment3; 90 } 91 } 92 | Popular Tags |