1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package net.sf.beanform.util;
16
17 /***
18 * Utility class that can determine the version of Tapestry being used in the current
19 * runtime environment, providing version-specific data to the rest of the library.
20 *
21 * @author Daniel Gredler
22 */
23 public final class TapestryCompat {
24
25 private final static boolean IS_TAPESTRY_41 = isTapestry41();
26
27 final static String TAPESTRY_41_CANCEL_JS = "tapestry.form.cancel(this.form)";
28 final static String TAPESTRY_40_CANCEL_JS = "this.form.events.cancel()";
29
30 final static String TAPESTRY_41_REFRESH_JS = "tapestry.form.refresh(this.form)";
31 final static String TAPESTRY_40_REFRESH_JS = "this.form.events.refresh()";
32
33 TapestryCompat() {
34
35 }
36
37 public static String getCancelJavaScript() {
38 if( IS_TAPESTRY_41 ) return TAPESTRY_41_CANCEL_JS;
39 else return TAPESTRY_40_CANCEL_JS;
40 }
41
42 public static String getRefreshJavaScript() {
43 if( IS_TAPESTRY_41 ) return TAPESTRY_41_REFRESH_JS;
44 else return TAPESTRY_40_REFRESH_JS;
45 }
46
47 private static boolean isTapestry41() {
48 boolean isTapestry41;
49 try {
50 Class.forName( "org.apache.tapestry.IJSONRender" );
51 isTapestry41 = true;
52 }
53 catch( Throwable t ) {
54 isTapestry41 = false;
55 }
56 return isTapestry41;
57 }
58
59 }