Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-738

Use ObjectFactory in velocityManager for setting webwork.velocity.contexts

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • WW 2.0, WW 2.1, WW 2.1.1, WW 2.1.2, WW 2.1.3, WW 2.1.4, WW 2.1.5, WW 2.1.6, WW 2.1.7
    • WW 2.2
    • XML Configuration
    • None

    Description

      This would allow chained context's to be able to be loaded from spring or other object factorys.

      It is a simple one line change in the init() method:

      FROM:

      VelocityContext velocityContext = (VelocityContext)
      ObjectFactory.getObjectFactory().buildBean(Class.forName(classname));

      TO:

      VelocityContext velocityContext = (VelocityContext)
      ObjectFactory.getObjectFactory().buildBean(classname);

      e.g. don't do Class.forName. Let the object factory figure it out.

      after this toolbox like things can be wired in.

      e.g

      <bean id="springToolboxContext"
      class="org.apache.velocity.VelocityContext" >
      <constructor-arg>
      <map>
      <entry key="dateTool">
      <ref bean="dateTool"/>
      </entry>
      </map>
      </constructor-arg>
      </bean>

      <bean id="dateTool" class="org.apache.velocity.tools.generic.DateTool"/>

      Matthew Payne

      Attachments

        Activity

          People

            sutter2k Matthew Payne
            sutter2k Matthew Payne
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: