I could able to get data from page 1 to page 2 using the modified controller as below:
Code:
public class EditSocialGroupController extends AbstractWizardFormController {
private RegistrationService regService;
public void setRegService(RegistrationService regService) {
this.regService = regService;
}
public EditSocialGroupController() { }
@Override
protected Object formBackingObject(PortletRequest request) throws Exception {
//return super.formBackingObject(arg0);
SocialGroup sg = new SocialGroup();
return sg;
}
@Override
protected void onBind(PortletRequest request, Object command, BindException errors) throws Exception {
SocialGroup sg = (SocialGroup) command;
System.out.println("Entering EditSocialGroupController -> onBind");
String sgName = request.getParameter("sgObjArr");
if(( sgName == null) || ("".equalsIgnoreCase(sgName.trim())) || ("-1".equalsIgnoreCase(sgName.trim()))) {
errors.rejectValue("sgName", "required.socialGroupName");
} else {
SocialGroup sg1 = regService.getSocialGroup(sgName);
sg.setSgDesc(sg1.getSgDesc());
sg.setSgId(sg1.getSgId());
sg.setSgName(sg1.getSgName());
System.out.println("sgId -----------> " + sg.getSgId());
System.out.println("sgName -----------> " + sg.getSgName());
System.out.println("sgDesc -----------> " + sg.getSgDesc());
}
System.out.println("Leaving EditSocialGroupController -> onBind");
}
@Override
protected void validatePage(Object request, Errors errors, int page) {
//super.validatePage(arg0, arg1, arg2);
if(page == 1) {
System.out.println("Entered page == 1 EditSocialGroupController -> validatePage");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "sgName", "required.socialGroupName");
}
}
@Override
protected void processFinish(ActionRequest request, ActionResponse response, Object command, BindException errors) throws Exception {
//super.processFinish(arg0, arg1, arg2, arg3);
System.out.println("Entered EditSocialGroupController -> processFinish ==============================");
SocialGroup sg = (SocialGroup) command;
regService.updateSocialGroup(sg);
}
@Override
protected void processCancel(ActionRequest arg0, ActionResponse arg1, Object arg2, BindException arg3) throws Exception {
//super.processCancel(arg0, arg1, arg2, arg3);
System.out.println("Entered EditSocialGroupController -> processCancel ==============================");
}
@Override
protected Map referenceData(PortletRequest request, int page) throws Exception {
//return super.referenceData(arg0, arg1);
System.out.println("Entering EditSocialGroupController -> referenceData");
Registration regObj = (Registration) getPortletContext().getAttribute("regObj");
SocialGroup[] sgArr = regService.getSocialGroups(regObj);
Map referenceData = new HashMap();
referenceData.put("sgObjArr",sgArr);
System.out.println("Leaving EditSocialGroupController -> referenceData");
return referenceData;
}
}
Now i've a new problem.
In the second JSP, i've two buttons ..... 'Update Data' and 'Cancel'. Whenever i click on any of the buttons, i get a HTTP Status 404 error .... page not found error. The page it's referring is -> /spring-portlet-sample/WEB-INF/jsp/editSocialGroupDetails.jsp.
Here is my editSocialGroupDetails.jsp.
Code:
<h2>Edit Social Group</h2>
<br>
<font size="2.5">Fields marked with asterisk (<font color="red">*</font>) are mandatory. <br><br>
</font>
<form:form commandName="sgObj" method="post" enctype="application/x-www-form-urlencoded">
<br>
<font color="red"><form:errors path="sgName" /></font>
<br>
<br>
<table border="0" cellpadding="4">
<tr>
<td class="label"> <font color="red">*</font> Group Name:</td>
<td><form:input path="sgName" /></td>
</tr>
<tr>
<td class="label"> Description:</td>
<td><form:textarea path="sgDesc" rows="8" cols="50" /></td>
</tr>
<tr align="center">
<td colspan="1"><input type="submit" name="_finish" value="Update Social Group" /></td>
<td colspan="1"><input type="submit" name="_cancel" value="Cancel" /></td>
</tr>
</table>
</form:form>
When i click either 'Update Social Group' or Cancel button, it's not going to controller .. i mena ... it's not calling controllers processFinish or processCancel methods.
Can somebody help me in this regard. IT will be a GREAT help to me.
THank you.