Announcement Announcement Module
Collapse
No announcement yet.
Bug in SpEL documentation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bug in SpEL documentation

    Hi,

    On page:

    http://static.springsource.org/sprin...pressions.html

    there is a bug.

    Any code that resembles the following:

    Code:
    EvaluationContext context = new StandardEvaluationContext();
    context.setRootObject(tesla);
    should be the following:

    Code:
    StandardEvaluationContext context = new StandardEvaluationContext();
    context.setRootObject(tesla);
    It seems that the following method:

    Code:
    void org.springframework.expression.spel.support.StandardEvaluationContext.setRootObject(Object rootObject)
    is not on the interface but is present in the concrete class.

    What was the intended design here by the way? To have it only on the concrete class? If so then how can one benefit from the use of the interface?

    Update: Actually after a while I spotted the constructor argument so that the above can simply be:

    Code:
    EvaluationContext context = new StandardEvaluationContext(tesla);
    However, the documentation can still be amended.

    Thanks.
    Last edited by Narada; Dec 25th, 2009, 03:50 PM.

  • #2
    I found another bug in the SpEL documentation.

    On this page:

    http://static.springsource.org/sprin....html#d0e11738

    Where it says:

    Code:
    String randomPhrase = 
       parser.parseExpression("random number is ${T(java.lang.Math).random()}", 
                              new TemplatedParserContext()).getValue(String.class);
    It should say:

    Code:
    String randomPhrase = 
       parser.parseExpression("random number is ${T(java.lang.Math).random()}", 
                              new TemplateParserContext()).getValue(String.class);
    In short 'Templated' should be 'Template'.

    Under which category in Jira should such bugs be reported? I didn't see one for SpEL.

    Update: Actually I realised that this is not a mistake. I mistook TemplatedParserContext for TemplateParserContext in the SpEL API. I hadn't realised that it was expected that the user define his own context here. I'm curious - how come a ready made expression templating context wasn't provided out of the box and a standard wasn't set for the prefix and suffix for templating?

    On that note is there a more succinct way of doing the following?

    Code:
        @Test
        public void testExpressionTemplating() {
            String fooBarBaz = parser.parseExpression("foo ${'foobar'.substring(3)} ${'barbaz'.substring(3)}",
                    new ParserContext() {
                        public String getExpressionPrefix() {
                            return "${";
                        }
    
                        public String getExpressionSuffix() {
                            return "}";
                        }
    
                        public boolean isTemplate() {
                            return true;
                        }
                    }).getValue(String.class);
            System.out.println(fooBarBaz);
            assertEquals("foo bar baz", fooBarBaz);
        }
    Would be nice to have a more succinct way of specifying prefix and suffix.

    Thanks.
    Last edited by Narada; Dec 26th, 2009, 03:47 PM.

    Comment


    • #3
      Narada, can you please raise some issues with your suggestions and findings? Thanks you!

      Comment


      • #4
        Done thanks.

        http://jira.springframework.org/browse/SPR-6652

        Comment

        Working...
        X