Examples of TextProvider


Examples of com.opensymphony.xwork2.TextProvider

    }

    protected String getTranslationFromKey(String key)
    {
        Object action = getAction();
        TextProvider tp = getTextProvider(action);
        if (tp!=null)
        {   // Text Provider found
            String locale = getLocale(action).toString()
            String result = tp.getText(key);
            if (result==null)
            {
                if (log.isErrorEnabled())
                    log.error("No translation found for key=[" + key + "] on page " + getPageName() + " --> locale=" + locale);
            }
View Full Code Here

Examples of com.opensymphony.xwork2.TextProvider

     *
     * @return the message if found, otherwise the defaultMessage
     */
    public static String getText(String key, String defaultMessage, List<Object> args, ValueStack stack, boolean searchStack) {
        String msg = null;
        TextProvider tp = null;

        for (Object o : stack.getRoot()) {
            if (o instanceof TextProvider) {
                tp = (TextProvider) o;
                msg = tp.getText(key, null, args, stack);

                break;
            }
        }

        if (msg == null) {
            // evaluate the defaultMesage as an OGNL expression
            if (searchStack)
                msg = stack.findString(defaultMessage);
           
            if (msg == null) {
                // use the defaultMessage literal value
                msg = defaultMessage;
            }

            if (LOG.isWarnEnabled()) {
                if (tp != null) {
                  LOG.warn("The first TextProvider in the ValueStack ("+tp.getClass().getName()+") could not locate the message resource with key '"+key+"'");
                } else {
                  LOG.warn("Could not locate the message resource '"+key+"' as there is no TextProvider in the ValueStack.");
                }
                if (defaultMessage.equals(msg)) {
                  LOG.warn("The default value expression '"+defaultMessage+"' was evaluated and did not match a property.  The literal value '"+defaultMessage+"' will be used.");
View Full Code Here

Examples of com.opensymphony.xwork2.TextProvider

        //try to find the format on the stack
        if (format != null) {
            format = findString(format);
        }
        if (date != null) {
            TextProvider tp = findProviderInStack();
            if (tp != null) {
                if (nice) {
                    msg = formatTime(tp, date);
                } else {
                    TimeZone tz = getTimeZone();
                    if (format == null) {
                        String globalFormat = null;

                        // if the format is not specified, fall back using the
                        // defined property DATETAG_PROPERTY
                        globalFormat = tp.getText(DATETAG_PROPERTY);

                        // if tp.getText can not find the property then the
                        // returned string is the same as input =
                        // DATETAG_PROPERTY
                        if (globalFormat != null
View Full Code Here

Examples of com.opensymphony.xwork2.TextProvider

        // TODO: this should be done better
        ActionContext ac = ActionContext.getContext();
        Container cont = ac.getContainer();
        XWorkConverter xworkConverter = cont.getInstance(XWorkConverter.class);
        CompoundRootAccessor accessor = (CompoundRootAccessor) cont.getInstance(PropertyAccessor.class, CompoundRoot.class.getName());
        TextProvider prov = cont.getInstance(TextProvider.class, "system");
        boolean allow = "true".equals(cont.getInstance(String.class, "allowStaticMethodAccess"));
        OgnlValueStack aStack = new OgnlValueStack(xworkConverter, accessor, prov, allow);
        aStack.setOgnlUtil(cont.getInstance(OgnlUtil.class));
        aStack.setRoot(xworkConverter, accessor, this.root, allow);
View Full Code Here

Examples of com.opensymphony.xwork2.TextProvider

     *
     * @return the message if found, otherwise the defaultMessage
     */
    public static String getText(String key, String defaultMessage, List<Object> args, ValueStack stack, boolean searchStack) {
        String msg = null;
        TextProvider tp = null;

        for (Object o : stack.getRoot()) {
            if (o instanceof TextProvider) {
                tp = (TextProvider) o;
                msg = tp.getText(key, null, args, stack);

                break;
            }
        }

        if (msg == null) {
            // evaluate the defaultMesage as an OGNL expression
            if (searchStack)
                msg = stack.findString(defaultMessage);
           
            if (msg == null) {
                // use the defaultMessage literal value
                msg = defaultMessage;
            }

            if (LOG.isWarnEnabled()) {
                if (tp != null) {
                  LOG.warn("The first TextProvider in the ValueStack ("+tp.getClass().getName()+") could not locate the message resource with key '"+key+"'");
                } else {
                  LOG.warn("Could not locate the message resource '"+key+"' as there is no TextProvider in the ValueStack.");
                }
                if (msg.equals(defaultMessage)) {
                  LOG.warn("The default value expression '"+defaultMessage+"' was evaluated and did not match a property.  The literal value '"+defaultMessage+"' will be used.");
View Full Code Here

Examples of com.opensymphony.xwork2.TextProvider

        // TODO: this should be done better
        ActionContext ac = ActionContext.getContext();
        Container cont = ac.getContainer();
        XWorkConverter xworkConverter = cont.getInstance(XWorkConverter.class);
        CompoundRootAccessor accessor = (CompoundRootAccessor) cont.getInstance(PropertyAccessor.class, CompoundRoot.class.getName());
        TextProvider prov = cont.getInstance(TextProvider.class, "system");
        boolean allow = "true".equals(cont.getInstance(String.class, "allowStaticMethodAccess"));
        OgnlValueStack aStack = new OgnlValueStack(xworkConverter, accessor, prov, allow);
        aStack.setOgnlUtil(cont.getInstance(OgnlUtil.class));
        aStack.setRoot(xworkConverter, accessor, this.root, allow);
View Full Code Here

Examples of com.opensymphony.xwork2.TextProvider

        // TODO: this should be done better
        ActionContext ac = ActionContext.getContext();
        Container cont = ac.getContainer();
        XWorkConverter xworkConverter = cont.getInstance(XWorkConverter.class);
        CompoundRootAccessor accessor = (CompoundRootAccessor) cont.getInstance(PropertyAccessor.class, CompoundRoot.class.getName());
        TextProvider prov = cont.getInstance(TextProvider.class, "system");
        boolean allow = "true".equals(cont.getInstance(String.class, "allowStaticMethodAccess"));
        OgnlValueStack aStack = new OgnlValueStack(xworkConverter, accessor, prov, allow);
        aStack.setOgnlUtil(cont.getInstance(OgnlUtil.class));
        aStack.setRoot(xworkConverter, accessor, this.root, allow);
View Full Code Here

Examples of com.opensymphony.xwork2.TextProvider

        // TODO: this should be done better
        ActionContext ac = ActionContext.getContext();
        Container cont = ac.getContainer();
        XWorkConverter xworkConverter = cont.getInstance(XWorkConverter.class);
        CompoundRootAccessor accessor = (CompoundRootAccessor) cont.getInstance(PropertyAccessor.class, CompoundRoot.class.getName());
        TextProvider prov = cont.getInstance(TextProvider.class, "system");
        boolean allow = "true".equals(cont.getInstance(String.class, XWorkConstants.ALLOW_STATIC_METHOD_ACCESS));
        OgnlValueStack aStack = new OgnlValueStack(xworkConverter, accessor, prov, allow);
        aStack.setOgnlUtil(cont.getInstance(OgnlUtil.class));
        aStack.setRoot(xworkConverter, accessor, this.root, allow);
View Full Code Here

Examples of com.opensymphony.xwork2.TextProvider

    if (_key != null) {

      ValueStack stack = getStack();
      CompoundRoot root = stack.getRoot();
      TextProvider textProvider = null;
     
      for (Object obj : root) {
        if (obj instanceof TextProvider) {
          textProvider = (TextProvider) obj;
          break;
        }
      }

      if (textProvider != null) {
        String message = textProvider.getText(_key, _arguments);
        if (message != null) {
          try {
            writer.write(message);
          } catch (IOException e) {
            LOG.error("Could not write out tag", e);
View Full Code Here

Examples of com.opensymphony.xwork2.TextProvider

import com.opensymphony.xwork2.TextProviderFactory;

public class ResourceBundleSupport {
  public static Map<String, String> getLocaleMap(LocaleProvider localeProvider, Class<?> resourceType) {
    TextProviderFactory factory = new TextProviderFactory();
    TextProvider provider = factory.createInstance(resourceType, localeProvider);
    ResourceBundle bundle = provider.getTexts();
    Map<String, String> m = new LinkedHashMap<String, String>();
    for (Enumeration<String> en = bundle.getKeys(); en.hasMoreElements();) {
      String key = en.nextElement();
      String value = bundle.getString(key);
      m.put(key, value);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.