Created
June 27, 2015 15:49
-
-
Save chingovan/f5f75c45571a09a78faa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.blogspot.chingovan.tutorial.database; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import javax.portlet.ActionRequest; | |
import javax.portlet.ActionResponse; | |
import com.blogspot.chingovan.tutorial.database.model.Student; | |
import com.blogspot.chingovan.tutorial.database.service.StudentLocalServiceUtil; | |
import com.liferay.counter.service.CounterLocalServiceUtil; | |
import com.liferay.portal.kernel.exception.SystemException; | |
import com.liferay.portal.kernel.util.ParamUtil; | |
import com.liferay.util.bridges.mvc.MVCPortlet; | |
/** | |
* Portlet implementation class Database | |
*/ | |
public class Database extends MVCPortlet { | |
public void addStudent(ActionRequest actionRequest, ActionResponse actionResponse) throws SystemException { | |
String code = ParamUtil.getString(actionRequest, "code"); | |
String fullName = ParamUtil.getString(actionRequest, "fullName"); | |
Date birthday = ParamUtil.getDate(actionRequest, "birthday", new SimpleDateFormat("yyyy-MM-dd")); | |
boolean gender = ParamUtil.getBoolean(actionRequest, "gender"); | |
String address = ParamUtil.getString(actionRequest, "address"); | |
Student student = StudentLocalServiceUtil.createStudent(CounterLocalServiceUtil.increment()); | |
student.setCode(code); | |
student.setFullName(fullName); | |
student.setBirthday(birthday); | |
student.setGender(gender); | |
student.setAddress(address); | |
StudentLocalServiceUtil.addStudent(student); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment