Results 1 to 2 of 2

Thread: Service Layer - Web

  1. #1
    Join Date
    Dec 2005
    Location
    SFO, CA
    Posts
    15

    Default Service Layer - Web

    Hi,
    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.

    Code:
    <bean id="asForm" class="com.apps.business.handler.ASHandler">
            <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>
    
    <bean id="asViewElement" class="com.apps.business.view.ASViewElement">        
           <bean id="asService" class="com.apps.business.service.ASService"/>
    </bean>
    Thanks,
    Shiva

  2. #2
    Join Date
    Dec 2004
    Location
    Fremont, CA, USA
    Posts
    18

    Default

    Shiva,

    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.
    Ashik Uzzaman
    Fremont, California, USA
    http://ashikuzzaman.wordpress.com

Posting Permissions

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