Examples of OgnlValueStack


Examples of com.opensymphony.xwork.util.OgnlValueStack

        // if resourceKey isn't defined either, use defaultValue
        String key = (resourceKey != null) ? resourceKey : defaultValue;

        String message = null;
        OgnlValueStack stack = TagUtils.getStack(pageContext);
        Iterator iterator = stack.getRoot().iterator();

        while (iterator.hasNext())
        {
            Object o = iterator.next();
View Full Code Here

Examples of com.opensymphony.xwork.util.OgnlValueStack

    public int doEndTag()
        throws JspException
    {
        actualName = findString( nameAttr );
        String msg = null;
        OgnlValueStack stack = getStack();
        //find the name on the valueStack, and cast it to a date
        Object dateObj = stack.findValue( actualName );

        if ( dateObj != null )
        {
            if ( dateObj instanceof Date )
            {
                date = (Date) dateObj;
            }
            else if ( dateObj instanceof Long )
            {
                Calendar cal = Calendar.getInstance();
                cal.setTimeInMillis( ( (Long) dateObj ).longValue() );
                date = cal.getTime();
            }
            else
            {
                throw new JspException( "Could not cast the requested object " + nameAttr + " to a java.util.Date" );
            }
        }

        if ( date != null && date.getTime() > 0 )
        {
            tp = findProviderInStack();

            if ( tp == null )
            {
                throw new JspException( "Could not find a TextProvider on the stack." );
            }

            if ( nice )
            {
                msg = formatTime( 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 ( globalFormat != null )
                    {
                        msg =
                            new SimpleDateFormat( globalFormat, ActionContext.getContext().getLocale() ).format( date );
                    }
                    else
                    {
                        //fall back using the xwork date format ?
                    }
                }
                else
                {
                    msg = new SimpleDateFormat( format, ActionContext.getContext().getLocale() ).format( date );
                }
            }
        }

        if ( msg != null )
        {
            try
            {
                //if we used the id attribute, we will store the formatted date
                // in the valuestack, otherwise, we write it to the
                // outputstream.
                if ( getId() == null )
                {
                    pageContext.getOut().write( msg );
                }
                else
                {
                    stack.getContext().put( getId(), msg );
                }
            }
            catch ( IOException e )
            {
                throw new JspException( e );
View Full Code Here

Examples of com.opensymphony.xwork2.ognl.OgnlValueStack

    if (messageKey == null || StringUtils.isBlank(messageKey) && StringUtils.isNotBlank(defaultValue)) {
      message = StringUtils.capitalize(defaultValue);
    }
    // the titleKey attribute is used
    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

Examples of com.opensymphony.xwork2.ognl.OgnlValueStack

   */
  @Override
  public Locale resolveLocale(HttpServletRequest request) {

    Locale result = null;
    OgnlValueStack stack = (OgnlValueStack) ActionContext.getContext().getValueStack();

    for (Object o : stack.getRoot()) {
      if (o instanceof LocaleProvider) {
        LocaleProvider lp = (LocaleProvider) o;
        result = lp.getLocale();
        break;
      }
View Full Code Here

Examples of com.opensymphony.xwork2.ognl.OgnlValueStack

        container.inject(factory);
        return factory;
    }

    private ValueStack createStubValueStack(final Map<String, Object> actual) {
        ValueStack stack = new OgnlValueStack(
                container.getInstance(XWorkConverter.class),
                (CompoundRootAccessor)container.getInstance(PropertyAccessor.class, CompoundRoot.class.getName()),
                container.getInstance(TextProvider.class, "system"), true) {
            @Override
            public void setValue(String expr, Object value) {
View Full Code Here

Examples of com.opensymphony.xwork2.ognl.OgnlValueStack

public class ValidatorSupportTest extends XWorkTestCase {

  public void testConditionalParseExpression()  throws Exception {
    ValueStack oldStack = ActionContext.getContext().getValueStack();
    try {
      OgnlValueStack stack = (OgnlValueStack) container.getInstance(ValueStackFactory.class).createValueStack();
      stack.getContext().put(ActionContext.CONTAINER, container);
      stack.getContext().put("something", "somevalue");
      ActionContext.getContext().setValueStack(stack);
      ValidatorSupport validator = new ValidatorSupport() {
        public void validate(Object object) throws ValidationException {
        }
      };
View Full Code Here

Examples of com.opensymphony.xwork2.ognl.OgnlValueStack

        container.inject(factory);
        return factory;
    }

    private ValueStack createStubValueStack(final Map<String, Object> actual) {
        ValueStack stack = new OgnlValueStack(
                container.getInstance(XWorkConverter.class),
                (CompoundRootAccessor) container.getInstance(PropertyAccessor.class, CompoundRoot.class.getName()),
                container.getInstance(TextProvider.class, "system"), true) {
            @Override
            public void setValue(String expr, Object value) {
View Full Code Here

Examples of com.opensymphony.xwork2.ognl.OgnlValueStack

        container.inject(factory);
        return factory;
    }

    private ValueStack createStubValueStack(final Map<String, Object> actual) {
        ValueStack stack = new OgnlValueStack(
                container.getInstance(XWorkConverter.class),
                (CompoundRootAccessor)container.getInstance(PropertyAccessor.class, CompoundRoot.class.getName()),
                container.getInstance(TextProvider.class, "system"), true) {
            @Override
            public void setValue(String expr, Object value) {
View Full Code Here

Examples of com.opensymphony.xwork2.ognl.OgnlValueStack

        container.inject(factory);
        return factory;
    }

    private ValueStack createStubValueStack(final Map<String, Object> actual) {
        ValueStack stack = new OgnlValueStack(
                container.getInstance(XWorkConverter.class),
                (CompoundRootAccessor) container.getInstance(PropertyAccessor.class, CompoundRoot.class.getName()),
                container.getInstance(TextProvider.class, "system"), true) {
            @Override
            public void setValue(String expr, Object value) {
View Full Code Here

Examples of com.opensymphony.xwork2.ognl.OgnlValueStack

        container.inject(factory);
        return factory;
    }

    private ValueStack createStubValueStack(final Map<String, Object> actual) {
        ValueStack stack = new OgnlValueStack(
                container.getInstance(XWorkConverter.class),
                (CompoundRootAccessor)container.getInstance(PropertyAccessor.class, CompoundRoot.class.getName()),
                container.getInstance(TextProvider.class, "system"), true) {
            @Override
            public void setValue(String expr, Object 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.