init.jsp
1
2
3
4
5
6
7
8
9
10
11
12
| <liferay-theme:defineObjects /> <portlet:defineObjects /> |
view.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| <!-- Migrated to Liferay 7 / Liferay DXP by Manish Kumar Jaiswal --> <%@ include file= "/init.jsp" %> <portlet:actionURL name= "autoDetailsSubmit" var = "autoDetailsSubmit" /> <aui:form action= "<%=autoDetailsSubmit%>" method= "post" name= "autoDetailsSubmit" > <!-- MANUFACTURER --> <aui:fieldset> <aui:select label= "Manufacturer" name= "manufacturer" > <aui:option label= "AUDI" /> <aui:option label= "BMW" /> <aui:option label= "GM" /> <aui:option label= "VOLVO" /> <aui:option label= "TATA" /> </aui:select> </aui:fieldset> <!-- YEAR --> <aui:fieldset> <aui:select label= "Year Of Manufactoring" name= "year" > <aui:option label= "2011" /> <aui:option label= "2012" /> <aui:option label= "2013" /> <aui:option label= "2014" /> <aui:option label= "2015" /> </aui:select> </aui:fieldset> <aui:input name= "vin" label= "VIN" /> <aui:input name= "bodystyle" label= "Bodystyle" /> <aui:input name= "model" label= "Model" /> <aui:button class = "btn btn-success" name= "Submit" type= "submit" /> </aui:form> |
details.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| <%@ include file= "init.jsp" %> <%@page import= "java.util.List" %> <%@page import= "com.autoservice.model.AutoDetails" %> <%@page import= "com.autoservice.service.AutoDetailsLocalServiceUtil" %> <%@page import= "com.liferay.portal.kernel.util.ListUtil" %> <%@page import= "javax.portlet.PortletURL" %> <liferay-portlet:renderURL varImpl= "iteratorURL" > <portlet:param name= "mvcPath" value= "/details.jsp" /> </liferay-portlet:renderURL> <liferay-ui:search-container emptyResultsMessage= "there-are-no-autodetails" headerNames= "Year,Model,VIN,Manufacturer,userId" iteratorURL= "<%=iteratorURL%>" delta= "10" deltaConfigurable= "true" > <liferay-ui:search-container-results> <% List<AutoDetails> autoDetailsList = AutoDetailsLocalServiceUtil.findAll(); results = ListUtil.subList(autoDetailsList, searchContainer.getStart(), searchContainer.getEnd()); searchContainer.setTotal(autoDetailsList.size()); searchContainer.setResults(results); %> </liferay-ui:search-container-results> <liferay-ui:search-container-row className= "AutoDetails" keyProperty= "autoDetailId" modelVar= "currentObjectAutoDetails" > <liferay-ui:search-container-column-text name= "Year" property= "year" /> <liferay-ui:search-container-column-text name= "Model" property= "model" /> <liferay-ui:search-container-column-text name= "VIN" property= "VIN" /> <liferay-ui:search-container-column-text name= "Manufacturer" property= "manufacturer" /> <liferay-ui:search-container-column-text name= "userId" property= "userId" /> </liferay-ui:search-container-row> <liferay-ui:search-iterator searchContainer= "<%=searchContainer%>" /> </liferay-ui:search-container> |
AutoDetailsPortlet.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
| package com.autodetails.portlet; import com.autoservice.model.AutoDetails; import com.autoservice.service.AutoDetailsLocalServiceUtil; import com.liferay.counter.kernel.service.CounterLocalServiceUtil; import com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet; import com.liferay.portal.kernel.theme.ThemeDisplay; import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.WebKeys; import java.io.IOException; import java.util. Date ; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.Portlet; import javax.portlet.PortletException; import javax.portlet.ProcessAction; import org.osgi.service.component.annotations.Component; @Component(immediate = true, property = { "com.liferay.portlet.display-category=category.sample" , "com.liferay.portlet.instanceable=true" , "javax.portlet.display-name=AutoDetails Portlet" , "javax.portlet.init-param.template-path=/" , "javax.portlet.init-param.view-template=/view.jsp" , "javax.portlet.resource-bundle=content.Language" , "javax.portlet.security-role-ref=power-user,user" }, service = Portlet. class ) public class AutoDetailsPortlet extends MVCPortlet { @ProcessAction(name = "autoDetailsSubmit" ) public void autoDetailsSubmit(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { System.out.println( ">>>>>>>>>>>>>>>>>>>>>Into autoDetailsSubmit" ); ParamUtil. print (actionRequest); try { AutoDetails autoDetails = AutoDetailsLocalServiceUtil .createAutoDetails(CounterLocalServiceUtil.increment()); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long userId = themeDisplay.getUserId(); autoDetails.setUserId(userId); autoDetails.setUserName(themeDisplay.getUser().getScreenName()); autoDetails.setCreateDate( new Date ()); autoDetails.setModifiedDate( new Date ()); String manufacturer = ParamUtil.getString(actionRequest, "manufacturer" ); autoDetails.setManufacturer(manufacturer); String year = ParamUtil.getString(actionRequest, "year" ); autoDetails.setYear(Integer.parseInt(year)); String vin = ParamUtil.getString(actionRequest, "vin" ); autoDetails.setVIN(vin); String bodystyle = ParamUtil.getString(actionRequest, "bodystyle" ); autoDetails.setBodystyle(bodystyle); String model = ParamUtil.getString(actionRequest, "model" ); autoDetails.setModel(model); AutoDetailsLocalServiceUtil.addAutoDetails(autoDetails); System.out.println( "---------------------SUCCESS-------------------------" ); actionResponse.setRenderParameter( "mvcPath" , "/details.jsp" ); } catch (Exception e) { e.printStackTrace(); } } } |
Download Sourcecode : AUI_FORM_IN_LIFERAY7.zip
0 comments:
Post a Comment