Package com.opensymphony.xwork.util

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


    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

TOP

Related Classes of com.opensymphony.xwork.util.OgnlValueStack

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.