Announcement Announcement Module
No announcement yet.
Service Layer - Web Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Service Layer - Web

    I m creating a service layer in which I populate the list of transfer objects that hold the data to be displayed on the jsp. I m planning to add this service to the command object, so that I could get the list from the command object when the page is loaded. I m using JSTL to iterate through the list and display. I tried to add the service as a property to the command object. I get error creating bean error. Is it possible to add the service to the command object. If not is there a way I could get the list the service returns in the jsp.

    <bean id="asForm" class="">
            <property name="sessionForm"><value>false</value></property>
            <property name="commandName"><value>asViewElement</value></property>
            <property name="commandClass"><ref bean="asViewElement"/></property>
            <property name="validator"><ref bean="asValidator"/></property>
            <property name="formView"><value>ASPage</value></property>
            <property name="successView"><value>thankYouPage</value></property>      
    <bean id="asViewElement" class="">        
           <bean id="asService" class=""/>

  • #2

    What I understand is you need to do a dependency injection of a service object by Spring to your command object. I would rather prefer to do the same into a controller instead of command object. Anyway, wherever you want to inject it, you can do so by taking advantage of the an interface of Spring that contains a method isPropertiesSet() or isAllPropertiesSet(). I forgot the name if the interface, probably its something similar to InitializeBean. So your command object or controller object will have a property to hold the service object and a setter() for that service. Then Spring container will inject the rest if you specify in your application context file's bean declaration properly. If I get a real example, I ll let you know.