<aui:form action="<%=addStudentActionURL.toString()%>" name="studentForm" method="POST">
package com.reg;
import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
import com.reg.model.Student;
import com.reg.service.StudentLocalServiceUtil;
/**
* Portlet implementation class Regform
*/
public class Regform extends MVCPortlet {
public void addStudent(ActionRequest actionRequest,ActionResponse actionResponse) throws IOException,
PortletException, SystemException {
System.out.println("hello to this page");
long studentId;
studentId = CounterLocalServiceUtil.increment();
String firstName = ParamUtil.getString(actionRequest, "firstName");
System.out.println(firstName);
String lastName = ParamUtil.getString(actionRequest, "lastName");
String branch = ParamUtil.getString(actionRequest, "branch");
int age = (int) ParamUtil.getLong(actionRequest, "age");
String email=ParamUtil.getString(actionRequest, "email");
System.out.println(email+" yes");
Student student = null;
student = StudentLocalServiceUtil.createStudent(studentId);
student.setStudentId(studentId);
student.setFirstname(firstName);
student.setLastName(lastName);
student.setBranch(branch);
student.setAge(age);
student.setEmail(email);
StudentLocalServiceUtil.addStudent(student);
actionResponse.setRenderParameter("mvcPath",
"/html/regform/display_student.jsp");
}
public void updateStudent(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, SystemException, PortalException {
System.out.println("yes it is progress");
long studentId=ParamUtil.getLong(actionRequest, "studentId");
String firstName = ParamUtil.getString(actionRequest, "firstName");
String lastName = ParamUtil.getString(actionRequest, "lastName");
String branch = ParamUtil.getString(actionRequest, "branch");
int age = ParamUtil.getInteger(actionRequest, "age");
String email=ParamUtil.getString(actionRequest, "email");
System.out.println("update");
Student student = StudentLocalServiceUtil.getStudent(studentId);
if (student != null) {
// fill update information
student.setFirstname(firstName);
student.setLastName(lastName);
student.setBranch(branch);
student.setAge(age);
student.setEmail(email);
System.out.println("yes");
}
student = StudentLocalServiceUtil.updateStudent(student);
actionResponse.setRenderParameter("mvcPath",
"/html/regform/display_student.jsp");
}
public void deleteStudent(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortalException, SystemException {
long studentId = ParamUtil.getLong(actionRequest, "studentId");
System.out.println(studentId);
Student student = StudentLocalServiceUtil.deleteStudent(studentId);
actionResponse.setRenderParameter("mvcPath",
"/html/regform/display_student.jsp");
}
public void getStudent(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException,PortalException, SystemException {
long studentId = ParamUtil.getLong(actionRequest, "studentId");
System.out.println(studentId);
String cmd = ParamUtil.getString(actionRequest, "cmd");
Student student = StudentLocalServiceUtil.getStudent(studentId);
actionResponse.setRenderParameter("mvcPath",
"/html/regform/update_student.jsp");
}
}
Explanation:- in this above code put every jsp ,java ,service.xml and check the path of jsp file as we are using render url if the path is not correct then it will not hit the other jsp file .
The two bottom in there home and back buttom , if we click on back then the particular page should be appeared so on that pupose we have to make a individual url of two jsp file so the back buttom will work. Examine the jsp code properly and you will see when you will click on search buttom then the form will display then by clicking on back button then search option will display perhaps when you click on display buttom then display page will display and by clicking on first name then form will display then after that when you click on back button then again the previous page will open ,before copy and deploy examine the code.