Announcement Announcement Module
Collapse
No announcement yet.
custom root scoped object in javascript controller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • custom root scoped object in javascript controller

    Hi,
    i would use Surf WebScript to extend Java/Spring web apps.
    can i add custom root scoped object to the JavaScript controller ?
    can i integrate Surf with Hibernate ?
    thanks..

  • #2
    Hello,

    Yes the custom root objects for JavaScript and FreeMarker are all configurable. See the following config files for examples of adding your own objects:
    spring-surf-script-services-context.xml
    spring-surf-template-services-context.xml

    You can integrate Surf with Hibernate, but there is no support directly in SpringSurf, but Spring already provides several excellent helper classes to get you started in this area.

    Cheers,

    Kev

    Comment


    • #3
      How can I write the custom classes for script or template objects?

      Is there any sample I can look at, or does a particular class has to be extended?
      Last edited by psvent; Aug 21st, 2010, 06:57 AM.

      Comment


      • #4
        Yes you can write your own custom classes.

        The two context files I mentioned:
        spring-surf-script-services-context.xml
        spring-surf-template-services-context.xml
        all contain example bean definitions.

        For example, to add a JavaScript root scoped object you need to extend the 'baseScriptExtension' bean:
        Code:
           <bean id="example" parent="baseScriptExtension" class="org.mycompany.ExampleExtension">
              <property name="extensionName">
                 <value>example</value>
              </property>
           </bean>
        And the extensionName will be the identifier of your root scoped object accessible in web-tier JavaScript.
        The Java class itself should extend:
        Code:
        org.springframework.extensions.webscripts.processor.BaseProcessorExtension
        To add root objects in the FreeMarker templating model it is the same pattern:
        Code:
           <bean id="example" parent="baseTemplateExtension" class="org.yourclasspath.ExampleExtension">
              <property name="extensionName">
                 <value>example</value>
              </property>
           </bean>
        Extend the same class as above.

        Hope this helps!

        Kev

        Comment

        Working...
        X