Vincent,
I need some help about wizardAction and selection from a table.
I put a button in a menu associated with a table. This button lauches a wizardAction with only one step to get a date.
As final action I use an AbstractCollectionAction instance, as I want to iterate on the selected items. See code below.
Then I get here a cast exception:
java.lang.ClassCastException: org.jspresso.framework.binding.model.ModelConnector cannot be cast to org.jspresso.framework.binding.ICollectionConnector at org.jspresso.framework.application.backend.action.AbstractCollectionAction.getModelConnector(AbstractCollectionAction.java:57) at org.popsuite.hr.backend.action.CreatePayslipForContractAction.execute(CreatePayslipForContractAction.java:24) at org.jspresso.framework.application.backend.AbstractBackendController.execute(AbstractBackendController.java:107) at org.jspresso.framework.application.frontend.controller.AbstractFrontendController.executeBackend(AbstractFrontendController.java:625) at org.jspresso.framework.application.frontend.controller.swing.DefaultSwingController.protectedExecuteBackend(DefaultSwingController.java:537) [...]
The question is: how to get the selected items in the final action?
Regards
Pierre
===================================================================
<bean
id="createPayslipFromContractFrontAction"
parent="wizardAction"
>
<property name="firstWizardStep" ref="getCreatePaySlipDateWizardStep" />
<property name="finishAction" ref="createPayslipFromContractOkFrontAction" />
</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>
<bean class="org.jspresso.framework.model.descriptor.basic.BasicDatePropertyDescriptor">
<property name="name" value="refDate" />
</bean>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
<bean
id="createPayslipFromContractOkFrontAction"
class="org.jspresso.framework.application.frontend.action.WrappingAction">
<property name="name" value="create.payslip.for.contracts" />
<property name="wrappedAction">
<bean class="org.popsuite.hr.backend.action.CreatePayslipForContractAction" />
</property>
<property
name="iconImageURL"
value="classpath:org/jspresso/framework/application/images/wizard-48x48.png" />
</bean>
public class CreatePayslipForContractAction extends AbstractCollectionAction {
public final static String DATE_REF ="dateRef";
@Override
public boolean execute(
IActionHandler actionHandler,
Map<String, Object> context) {
ICollectionConnector collectionConnector = getModelConnector(context);
if (collectionConnector == null) return false;
int[] selection = getSelectedIndices(context);
if (null == selection) return false;
Object result = context.get(ActionContextConstants.ACTION_PARAM);
Date refDate = null;
if (result != null) {
if (result instanceof Map) {
refDate = (Date) ((Map<?,?>) result).get("dateRef");
} else if (result instanceof Date) {
refDate = (Date) result;
}
}
if (null == refDate) {
refDate = new Date();
}
for (int i:selection) {
Contract contract = (Contract) collectionConnector.getChildConnector(i).getConnectorValue();
contract.createPayslips(refDate);
}
return super.execute(actionHandler, context);
}
}
