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..
Printable View
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..
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
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?
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:
And the extensionName will be the identifier of your root scoped object accessible in web-tier JavaScript.Code:<bean id="example" parent="baseScriptExtension" class="org.mycompany.ExampleExtension">
<property name="extensionName">
<value>example</value>
</property>
</bean>
The Java class itself should extend:
To add root objects in the FreeMarker templating model it is the same pattern:Code:org.springframework.extensions.webscripts.processor.BaseProcessorExtension
Extend the same class as above.Code:<bean id="example" parent="baseTemplateExtension" class="org.yourclasspath.ExampleExtension">
<property name="extensionName">
<value>example</value>
</property>
</bean>
Hope this helps!
Kev