Announcement Announcement Module
Collapse
No announcement yet.
[WebFlow 1.x] How can i init assosiations ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [WebFlow 1.x] How can i init assosiations ?

    Hi,

    how can i init my form object's assosiations , using webflow 1.x ?

    My Way :

    // bean config
    <bean id="registrationDataFormAction" class="org.springframework.webflow.action.FormActi on">

    <property name="formObjectName" value="registrationFormBean"/>
    <property name="formObjectClass" value="com.company.pos.web.beans.RegistrationFormB ean"/>
    <property name="formObjectScope" value="REQUEST"/>
    <property name="validator" ref="registrationFormValidator"/>

    </bean>

    // Flow config
    <view-state id="registrationForm" view="customerData">

    <render-actions>
    <action bean="registrationDataFormAction" method="setupForm"></action>
    </render-actions>

    <transition on="submit" to="successData">
    <action bean="registrationDataFormAction" method="bindAndValidate"></action>
    </transition>

    </view-state>

    that's my way. But com.company.pos.web.beans.RegistrationFormBean has many associations. I must set them, before the validators run, but how ?

    Best regards.

  • #2
    Well that is the responsibility of the RegistrationFormBean, simply do i tthere.

    Comment


    • #3
      Firstly thanks for your reply.
      I could create required objects in constructor of my Bean, as u said, that is the responsibility of RegistrationFormBean, than it would be absolutely silly to use spring framework, if i create the objects, using "new", isn't it ?

      Couldn't we use setter injection for that RegistrationFormBean class and let the spring wire all of the required associations ?
      For example :

      I could configure my beans :
      <bean id ="RegistrationFormBean" class="com.mycompany.beans.RegistrationFormBean" scope="request">
      <property name="customerData" ref="customerDataBean"/>
      <property name="addressData" ref="addressDataBean"/>
      </bean>
      <bean name="customerDataBean" class="com.mycompany.beans.CustomerDataBean"/>
      <bean name="addressDataBean" class="com.mycompany.beans.AddressDataBean"/>

      If i could have a way to wire RegistrationFormBean to FormAction bean.
      <bean id="registrationDataFormAction" class="org.springframework.webflow.action.FormActi on">

      <!-- <property name="formObjectName" value="registrationFormBean"/>
      <property name="formObjectClass" value="com.company.pos.web.beans.RegistrationFormB ean"/>
      <property name="formObjectScope" value="REQUEST"/>-->

      <!-- is there any property like formObject ? i have searched in JavaDocs, bur no result... -->
      <property name="formObject" ref="registrationFormBean"/>
      <property name="validator" ref="registrationFormValidator"/>
      </bean>

      Thanks !

      Comment


      • #4
        I could create required objects in constructor of my Bean, as u said, that is the responsibility of RegistrationFormBean, than it would be absolutely silly to use spring framework, if i create the objects, using "new", isn't it ?
        No it isn't. Why do people think that you need to wire everything with spring including the kitchen sink?! Spring is for wiring all the infrastructure components, add some AOP and to provide easy integration with enterprise services.

        But it is not (at least I wouldn't recommend it) to model and inject your business classes.

        Also if you would do it that way you would have 1 instance of your 'RegistrationFormBean'. No imagine 30 people registering at once........

        Comment

        Working...
        X