@@ -235,7 +235,7 @@ public Result handle(ActionContext context) throws Exception {
235235 }
236236
237237 context .attribute ("reflected_handler" , this );
238- if (null != templateContext ) {
238+ if (null != templateContext && context . state (). isHandling () ) {
239239 context .templateContext (templateContext );
240240 }
241241 preventDoubleSubmission (context );
@@ -456,7 +456,7 @@ private Object controllerInstance(ActionContext context) {
456456 private void initCacheParams () {
457457 CacheFor cacheFor = method .getAnnotation (CacheFor .class );
458458 cacheSupport = null == cacheFor ? CacheSupportMetaInfo .disabled () : CacheSupportMetaInfo .enabled (
459- new CacheKeyBuilder (cacheFor , method .getName ()),
459+ new CacheKeyBuilder (cacheFor , S . concat ( controllerClass . getName (), "." , method .getName () )),
460460 cacheFor .value (),
461461 cacheFor .supportPost ()
462462 );
@@ -604,7 +604,7 @@ public NotFound notFoundOnMethod(String message) {
604604
605605 private boolean checkTemplate (ActionContext context ) {
606606 if (!context .state ().isHandling ()) {
607- // we don't check template on interceptors
607+ //we don't check template on interceptors
608608 return false ;
609609 }
610610 Boolean hasTemplate = context .hasTemplate ();
@@ -879,20 +879,31 @@ protected void releaseResources() {
879879
880880 private static class CacheKeyBuilder extends $ .F1 <ActionContext , String > {
881881 private String [] keys ;
882- private final String methodName ;
882+ private final String base ;
883883
884- CacheKeyBuilder (CacheFor cacheFor , String methodName ) {
885- this .methodName = methodName ;
884+ CacheKeyBuilder (CacheFor cacheFor , String actionPath ) {
885+ this .base = base ( actionPath ) ;
886886 this .keys = cacheFor .keys ();
887887 }
888888
889+ private String base (String actionPath ) {
890+ S .Buffer buffer = S .newBuffer ();
891+ String [] sa = actionPath .split ("\\ ." );
892+ for (String s : sa ) {
893+ buffer .append (s .charAt (0 ));
894+ }
895+ buffer .append (actionPath .hashCode ());
896+ return buffer .toString ();
897+ }
898+
889899 @ Override
890900 public String apply (ActionContext context ) throws NotAppliedException , Osgl .Break {
891901 TreeMap <String , String > keyValues = keyValues (context );
892- S .Buffer buffer = S .newBuffer (methodName );
902+ S .Buffer buffer = S .newBuffer (base );
893903 for (Map .Entry <String , String > entry : keyValues .entrySet ()) {
894904 buffer .append ("-" ).append (entry .getKey ()).append (":" ).append (entry .getValue ());
895905 }
906+ buffer .append (context .userAgent ().isMobile () ? "M" : "B" );
896907 return buffer .toString ();
897908 }
898909
0 commit comments