gmatthews,
what did you mean with
"You need to match the signature of any of the protected/public referenceData methods, of which there are none that just take a request object."???
I've got the same problem. I'm using an AbstractWizardFormController and my referenceData() -method seems to be ignored. The same code works in a SimpleFormController. I have Java 1.4.2_05.
Code:
class OperationAddController extends AbstractWizardFormController {
private OperationService operationService;
private WorkflowService workflowService;
public void afterPropertiesSet() throws Exception {
if (this.operationService == null)
throw new IllegalArgumentException("An OperationService is required");
if (this.workflowService == null)
throw new IllegalArgumentException("A WorkflowService is required");
}
protected void processFinish(
ActionRequest request, ActionResponse response,
Object command, BindException errors)
throws Exception {
operationService.addOperation((Operation)command);
response.setRenderParameter("action","allOperations");
}
protected void processCancel(
ActionRequest request, ActionResponse response,
Object command, BindException errors)
throws Exception {
response.setRenderParameter("action","allOperations");
}
protected void validatePage(
Object command, Errors errors, int page, boolean finish) {
if (finish) {
this.getValidator().validate(command, errors);
return;
}
Operation operation = (Operation)command;
OperationValidator operationValidator = (OperationValidator)getValidator();
switch (page) {
case 0: operationValidator.validateName(operation, errors); break;
}
}
protected Map referenceData(PortletRequest request)throws Exception {
Map retval = new HashMap();
retval.put("workflows", workflowService.getAllWorkflows());
return retval;
}
protected Object formBackingObject(PortletRequest request)throws Exception {
Operation o;
o = new Operation();
return o;
}
protected void initBinder(PortletRequest request, PortletRequestDataBinder binder)
throws Exception {
NumberFormat nf = NumberFormat.getInstance(request.getLocale());
binder.registerCustomEditor(java.lang.Integer.class,
new CustomNumberEditor(java.lang.Integer.class, nf, true));
binder.registerCustomEditor(Workflow.class, new WorkflowSupport());
binder.setAllowedFields(new String[] {"name","description","critical"});
}
protected ModelAndView renderInvalidSubmit(RenderRequest request, RenderResponse response)
throws Exception {
return null;
}
protected void handleInvalidSubmit(ActionRequest request, ActionResponse response)
throws Exception {
response.setRenderParameter("action","allOperations");
}
public void setOperationService(OperationService operationService) {
this.operationService = operationService;
}
public void setWorkflowService(WorkflowService workflowService) {
this.workflowService = workflowService;
}
}
And this is the jsp-code:
Code:
<form method="post" action="<portlet:actionURL>
<portlet:param name="action" value="addOperation"/>
<portlet:param name="_page" value="${page}"/>
<portlet:param name="workflowId" value="<%=wfId %>"/>
</portlet:actionURL>">
<table border="0" cellpadding="4">
<tr>
</tr>
<tr>
<c:choose>
<c:when test="${page == 0}" >
<th>Name</th>
<td>
<spring:bind path="operation.name">
<input type="text" name="${status.expression}" value="${status.value}"/>
<span>${status.errorMessage}</span>
</spring:bind>
</td>
</c:when>
<c:when test="${page == 1}" >
<th>Workflow:</th>
<td><spring:bind path="operation.workflow">
<select name="<c:out value="${status.expression}"/>" size="1">
<option value="0">--- bitte wählen ---</option>
<c:forEach var="workflow" items="${workflows}">
<option value='<c:out value="${workflow.id}"/>' <c:if test="${workflow.id == status.value}">selected</c:if>>
<c:out value="${workflow.name}"/>
</option>
</c:forEach>
</select>
</spring:bind>
</td>
</c:when>
</c:choose>
<tr>
<th colspan="2">
<input type="submit" name="_target${nextPage}" ${empty nextPage ? "disabled" : ""} value="Next"/>
<input type="submit" name="_finish" value="Finish"/>
<input type="submit" name="_target${prevPage}" ${empty prevPage ? "disabled" : ""} value="Previous"/>
<input type="submit" name="_cancel" value="Cancel"/>
</th>
</tr>
</table>
</form>
Thanks for your help!