Package com.opensymphony.xwork2

Examples of com.opensymphony.xwork2.TextProvider


    else {
      OgnlValueStack stack = (OgnlValueStack) TagUtils.getStack(pageContext);
     
      for (Object o : stack.getRoot()) {
        if (o instanceof TextProvider) {
          TextProvider tp = (TextProvider) o;
          message = tp.getText(messageKey, UNDEFINED_KEY + messageKey + UNDEFINED_KEY);
          break;
        }
      }
    }
View Full Code Here


        // 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

        //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

        return new WrapperExceptionConfig(cfg);
    }

    public void convertErrors(ActionErrors errors, Object action) {
        ValidationAware vaction = null;
        TextProvider text = null;

        if (action instanceof ValidationAware) {
            vaction = (ValidationAware)action;
        }
        if (action instanceof TextProvider) {
            text = (TextProvider)action;
        }
        // if there is no ValidationAware, it doesn't make sense to process messages
        // as there be no place to put message in
        if (vaction == null) {
            return;
        }
        for (Iterator i = errors.properties(); i.hasNext(); ) {
            String field = (String) i.next();
            for (Iterator it = errors.get(field); it.hasNext(); ) {
                ActionMessage error = (ActionMessage) it.next();
                String msg = error.getKey();
                if (error.isResource() && text != null) {
                    Object[] values = error.getValues();
                    if (values != null) {
                        msg = text.getText(error.getKey(), Arrays.asList(values));
                    } else {
                        msg = text.getText(error.getKey());
                    }
                }
                if (ActionMessages.GLOBAL_MESSAGE.equals(field)) {
                    vaction.addActionError(msg);
                } else {
View Full Code Here

    }

    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

    //  ------- Singleton getInstance -------
   
    public static TextProvider getInstance(Class clazz, LocaleProvider provider)
    {
        TextProvider instance=new TextProviderActionSupport(provider);
        if (instance instanceof ResourceBundleTextProvider)
        {
            ((ResourceBundleTextProvider) instance).setClazz(clazz);
        }
        return instance;
View Full Code Here

        // 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

        // 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

        for (Iterator iterator = getStack().getRoot().iterator();
             iterator.hasNext();) {
            Object o = iterator.next();

            if (o instanceof TextProvider) {
                TextProvider tp = (TextProvider) o;
                msg = tp.getText(actualName, defaultMessage, values, stack);

                break;
            }
        }
View Full Code Here

        //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 {
                    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

TOP

Related Classes of com.opensymphony.xwork2.TextProvider

Copyright © 2018 www.massapicom. 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.