Results 1 to 3 of 3

Thread: XmlViewResolver Issue

  1. #1
    Join Date
    Jun 2008
    Posts
    5

    Default XmlViewResolver Issue

    Hello,

    I am trying to use XmlViewResolver like that :

    <bean id="viewResolver" class="org.springframework.web.servlet.view.XmlVie wResolver" />

    in myApp-servlet.xml.

    The views.xml file contains the following View definition :

    <bean id="homeView" class="myapp. VelocityLayoutView" parent="baseView">
    <property name="url" value="${templates.default.layout}"/>
    <property name="main" value="${templates.home.main}"/>
    <property name="header2" value="${templates.home.header2}"/>
    <property name="footer" value="${templates.default.closing}"/>
    </bean>

    When the viewResolver tries to create the bean “homeView” it fails because it can’t resolve the property names to the actual Velocity templates and
    therefore is looking for a template e.g. named ${templates.default.layout}.

    In myApp-servlet.xml I also define the following bean for property name resolution :

    <bean id="applicationResourcePropertyConfig" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>classpath:resource.properties</value>
    <value>classpath:myApp.properties</value>
    </list>
    </property>
    <property name="searchSystemEnvironment" value="true"/>
    </bean>


    Would anyone know why the above set up is not working?


    Thank you very much,


    Savakos

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    PropertyPlaceHolderConfigurer is a BeanPostProcessor that ONLY works on the ApplicationContext it is defined in. Your views.xml isn't part of the ApplicationContext, the XmlViewResolver creates its own.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jun 2008
    Posts
    5

    Default

    Quote Originally Posted by Marten Deinum View Post
    PropertyPlaceHolderConfigurer is a BeanPostProcessor that ONLY works on the ApplicationContext it is defined in. Your views.xml isn't part of the ApplicationContext, the XmlViewResolver creates its own.

    Marten hi,

    Thank you very much for your reply.

    That was the problem indeed!


    cheers,


    savakos

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •