service.xml
テーブルの詳細を含むファイルを
提供しています:
<entity name="Testimonial" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="TestimonialId" type="long" primary="true" />
<!-- UI fields -->
<column name="subject" type="String" />
<column name="area" type="String" />
<column name="username" type="String" />
<column name="email" type="String" />
<column name="photo" type="String"/>
<column name="company" type="String" />
<column name="designation" type="String" />
<!-- Audit fields -->
<column name="createdAt" type="Date" />
データベースにデータを保存するロジックを記述したJavaファイルは次のとおりです。
public void updateTesti(ActionRequest actionRequest,ActionResponse actionResponse) throws IOException, PortletException
{
String subject = ParamUtil.getString(actionRequest,"subject");
String area = ParamUtil.getString(actionRequest,"area");
String username = ParamUtil.getString(actionRequest,"username");
String email = ParamUtil.getString(actionRequest,"email");
String company = ParamUtil.getString(actionRequest,"company");
String designation = ParamUtil.getString(actionRequest,"designation");
System.out.println("Your inputs ==> " + subject + ", " + area + ","
+ username + "," + email + "," + company + "," + designation);
Testimonial T1 = new TestimonialImpl();
// set primary key
long TestimonialId = 0L;
try {
TestimonialId =
CounterLocalServiceUtil.increment(
this.getClass().getName());
} catch (SystemException e) {
e.printStackTrace();
}
T1.setTestimonialId(TestimonialId);
UploadPortletRequest uploadRequest =
PortalUtil.getUploadPortletRequest(actionRequest);
String filePath = uploadRequest.getFileName("filePath");
try{
java.io.File file = uploadRequest.getFile("filePath");
//Manage the Upload
}catch (Exception e) {
///
}
// set UI fields
T1.setSubject(subject);
T1.setArea(area);
T1.setUsername(username);
T1.setEmail(email);
T1.setCompany(company);
T1.setDesignation(designation);
T1.setPhoto(filePath);
// set audit field(s)
T1.setCreatedAt(new Date());
// insert the book using persistence api
try {
TestimonialLocalServiceUtil.addTestimonial(T1);
} catch (SystemException e) {
e.printStackTrace();
}
}
どこが間違っているのか、何が欠けているのか教えてください。
これが私のJSPコードです:
<aui:form name="fm" method="POST" action="<%= updateTestiURL.toString() %>">
<aui:input name="subject" label="Subject"/>
<aui:input type="textarea" name="area" label="your Testimonial" />
<aui:input name="username" label="Username"/>
<aui:input name="email" label="Email"/>
<aui:input type="file" label="upload your file" name="filePath" />
<aui:input name="company" label="Company"/>
<aui:input name="designation" label="Designation"/>
<aui:button type="submit" value="Save"/>