1 23 24 package com.sun.enterprise.tools.guiframework.event.handlers; 25 26 import com.iplanet.jato.RequestContext; 27 28 import com.sun.enterprise.tools.guiframework.view.HandlerContext; 29 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 30 31 import com.sun.web.ui.common.CCI18N; 32 33 import java.util.List ; 34 import java.util.Map ; 35 36 37 40 public class ResourceBundleHandlers { 41 42 51 public void getMessage(RequestContext reqCtx, HandlerContext handlerCtx) { 52 String key = (String )handlerCtx.getInputValue(KEY); 54 if (key == null) { 55 throw new FrameworkException("'"+KEY+ 56 "' is required by ResourceBundleMapper.getMappedSource()."); 57 } 58 59 String bundle = (String )handlerCtx.getInputValue(RESOURCE_BUNDLE); 61 if (bundle == null) { 62 bundle = handlerCtx.getViewDescriptor().getResourceBundle(); 63 } 64 if (bundle == null) { 65 throw new FrameworkException("Resource bundle was not specified!"); 66 } 67 68 CCI18N i18n = new CCI18N(reqCtx, bundle); 71 Object args = handlerCtx.getInputValue(ARGS); 73 if (args instanceof List ) { 74 args = ((List )args).toArray(); 75 } else if (args != null) { 76 args = new Object [] {args}; 77 } 78 79 handlerCtx.setOutputValue( 81 VALUE, i18n.getMessage(key, (Object [])args)); 82 } 83 84 85 88 public static final String VALUE = "value"; 89 90 93 public static final String KEY = "key"; 94 95 99 public static final String ARGS = "arguments"; 100 101 105 public static final String RESOURCE_BUNDLE = "resourceBundle"; 106 } 107 | Popular Tags |