public void setObject()

in tapestry-framework/src/org/apache/tapestry/binding/ExpressionBinding.java [511:565]


    public void setObject(Object value)
    {
        initialize();

        if (_invariant)
            throw createReadOnlyBindingException(this);

        try
        {
            if (_accessor != null)
            {
                _evaluator.write(_root, _accessor, value);
            }
            else if (EXPRESSION_EVALUATION_ENABLED && _evaluator.isCompileEnabled() && _accessor == null)
            {
                //_evaluator.compileExpression(_root, _parsedExpression, _expression);
                //_accessor = _parsedExpression.getAccessor();

                if (!_writeFailed)
                {
                    // re-parse expression as compilation may be possible now that it potentially has a value
                    try
                    {
                        _evaluator.compileExpression(_root, _parsedExpression, _expression);
                        _accessor = _parsedExpression.getAccessor();
                    }
                    catch (Throwable t)
                    {
                        // ignore re-read failures as they aren't supposed to be happening now anyways
                        // and a more user friendly version will be available if someone actually calls
                        // getObject

                        // if writing fails then we're probably screwed...so don't do it again
                        if (value != null)
                            _writeFailed = true;
                    }
                }
            }
            else
            {
                _evaluator.writeCompiled(_root, _parsedExpression, value);
            }
        }
        catch (Throwable ex)
        {
            throw new BindingException(
                    Tapestry.format(
                            "ExpressionBinding.unable-to-update-expression",
                            _expression,
                            _root,
                            value),
                    this,
                    ex);
        }
    }