Results 1 to 4 of 4

Thread: custom root scoped object in javascript controller

  1. #1
    Join Date
    May 2010
    Posts
    1

    Default 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. #2

    Default

    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

  3. #3
    Join Date
    Mar 2010
    Posts
    20

    Default

    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 at 06:57 AM.

  4. #4

    Default

    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

Posting Permissions

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