[help] how to initialize a value in a wizard model?

3 posts / 0 new
Last post
atao
Offline
Joined: 10/15/2008
[help] how to initialize a value in a wizard model?

Vincent,

I have a wizard step with a date picker. I tried to set an initial value for this date (see below). But this initial value is never shown.

Is it possible to do?

Regards

Pierre

===================================

in frontend.xml

  <bean
    id="refDate"
    class="org.popsuite.framework.model.descriptor.basic.EnhancedDatePropertyDescriptor">
    <property name="name" value="refDate" />
    <property name="defaultDate" value="05/04/2009" />
  </bean>
 
  <bean
    id="getCreatePaySlipDateWizardStep"
    class="org.jspresso.framework.application.frontend.action.wizard.StaticWizardStepDescriptor"
    >
    <property name="viewDescriptor">
      <bean
        class="org.jspresso.framework.view.descriptor.basic.BasicComponentViewDescriptor">
        <property name="modelDescriptor">
          <bean
            class="org.jspresso.framework.model.descriptor.basic.BasicComponentDescriptor">
            <property name="propertyDescriptors">
              <list>
                <ref bean="refDate" />
              </list>
            </property>
          </bean>
        </property> 
      </bean>
    </property>
  </bean>

in EnhancedDatePropertyDescripto.java

/*
 * CustomEditorConfigurer is registered
 */

public class EnhancedDatePropertyDescriptor
extends BasicDatePropertyDescriptor{
   
      public void setDefaultDate(Date defaultDate) {         
        setDefaultValue(defaultDate);
      }

}

vvandens
Offline
Joined: 05/29/2008
[help] how to initialize a value in a wizard model?

Pierre,

Default values defined on property descriptors only work on entities as of now. That's why it doesn't work (could be enhanced though).

But the Wizard action has a protected method you can everride to initialize the wizard model with whatever values you need. That is actually much more powerful than values you may set through the spring context. So what you have to do is :

  • Create a subclass of the WizardAction.
  • Override the completeInitialWizardModel method, e.g. 
  @Override
protected void completeInitialWizardModel(
Map<String, Object> initialWizardModel, Map<String, Object> context) {
super.completeInitialWizardModel(initialWizardModel, context);
initialWizardModel.put("defaultDate", [your default date]);
}
  • Replace the class of your wizard action by yours in the spring context, e.g.
<bean id="createPayslipFromContractFrontAction" parent="wizardAction"
  class="your.overriden.WizardAction">
...
</bean>

This way, you can initialize arbitrary complex values in your wizard model (even with nested maps, if you work with master detail views in a wizard step).

Hope this helps,

Vincent

atao
Offline
Joined: 10/15/2008
[help] how to initialize a value in a wizard model?

Vincent,

Thanks.

Pierre