View difference between Paste ID: f0YLU5a6 and qZN21kQP
SHOW: | | - or go back to the newest paste.
1
@Named("adminBatchBean")
2
@ViewScoped
3
public class AdminBatchBean implements Serializable {
4
	
5
	@Inject
6
	private BatchGateway batchGateway;
7
	@Inject
8
	private CourseGateway courseGateway;
9
10
11
	public List<Course> getCourses() {
12
		return courseGateway.getCourses(school);
13
	}
14
}
15
16
17
@Stateful
18-
@Named("batchGateway")
18+
19-
public class BatchGateway extends BaseGateway<Batch> {
19+
@Named("courseGateway")
20-
	public List<Batch> getBatches(@Current School school) {
20+
public class CourseGateway extends BaseGateway<Course> {
21
	public List<Course> getCourses(@Current School currentSchool) {
22-
		CriteriaQuery<Batch> query = builder.createQuery(Batch.class);
22+
23-
		Root<Batch> b = query.from(Batch.class);
23+
		CriteriaQuery<Course> query = builder.createQuery(Course.class);
24
		Root<Course> c = query.from(Course.class);
25-
				builder.equal(
25+
26-
						b.get(Batch_.classTimingGroup).get(
26+
27-
								ClassTimingGroup_.school), school),
27+
				builder.equal(c.get(Course_.school), currentSchool),
28-
				builder.equal(b.get(Batch_.deleted), Boolean.FALSE) };
28+
				builder.isFalse(c.get(Course_.deleted)) };
29
30
		query.where(predicates);
31
		return em.createQuery(query).
32
				setHint("javax.persistence.cache.retrieveMode", CacheRetrieveMode.BYPASS).
33
				setHint("javax.persistence.cache.storeMode", CacheStoreMode.BYPASS).
34
				getResultList();
35
	}
36
37
}
38
39
<?xml version="1.0" encoding="UTF-8"?>
40
41
<html xmlns="http://www.w3.org/1999/xhtml"
42
	xmlns:h="http://java.sun.com/jsf/html"
43
	xmlns:f="http://java.sun.com/jsf/core"
44
	xmlns:ui="http://java.sun.com/jsf/facelets"
45
	xmlns:p="http://primefaces.org/ui">
46
47
<ui:composition template="/template/new_admin_layout.xhtml">
48
	<ui:define name="content">
49
		<h:form prependId="false" id="growlForm">
50
			<p:growl id="growl" showDetail="false" />
51
		</h:form>
52
		<h:form id="dataForm" prependId="false">
53
			<p:panel id="courseDataPanel"
54
				visible="#{adminBatchBean.dataVisible}"
55
				style="margin-top:50px;">
56
				<p:dataTable id="courseDataList" value="#{adminBatchBean.courses}" var="course"
57
					emptyMessage="#{messages.message_empty_guardian}"
58
					resizableColumns="false" paginator="true"
59
					paginatorTemplate=" {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
60
					rowsPerPageTemplate="5,10,25,50" rows="10"
61
					style="text-align:center;">
62
					<f:facet name="Header">
63
						<h:outputText value="#{messages.header_course}" />
64
					</f:facet>
65
66
					<p:column id="courseCodeColumn" filterBy="#{course.code}"
67
						headerText="#{messages.label_course_code}">
68
						<h:outputText value="#{course.code}" />
69
					</p:column>
70
71
					<p:column id="courseNameColumn" filterBy="#{course.courseName}"
72
						headerText="#{messages.label_course_name}">
73
						<h:outputText value="#{course.courseName}" />
74
					</p:column>
75
76
					<p:column headerText="#{messages.header_edit}" style="width:50px">
77
						<p:commandLink id="btnEdit" title="Edit"
78
							styleClass="ui-icon ui-icon-pencil"
79
							update=":dataForm :courseForm:coursePanel :batchForm:batchPanel :dataForm:courseDataPanel">
80
							<f:setPropertyActionListener
81
								target="#{adminBatchBean.selectedCourse}" value="#{course}" />
82
							<f:setPropertyActionListener
83
								target="#{adminBatchBean.dataVisible}" value="false" />
84
							<f:setPropertyActionListener
85
								target="#{adminBatchBean.courseFormVisible}" value="true" />
86
						</p:commandLink>
87
					</p:column>
88
89
					<p:column headerText="#{messages.header_delete}" style="width:50px">
90
						<p:commandLink id="btnDelete" title="Delete"
91
							styleClass="ui-icon ui-icon-trash"
92
							oncomplete="deleteDialog.show()">
93
							<f:setPropertyActionListener
94
								target="#{adminBatchBean.selectedBatch}" value="#{batch}" />
95
						</p:commandLink>
96
					</p:column>
97
98
					<p:column headerText="Add" style="width:50px">
99
						<p:commandLink id="btnAdd" title="Add Lesson"
100
							styleClass="ui-icon ui-icon-circle-plus"
101
							update=":dataForm :batchForm:batchPanel :dataForm:courseDataPanel :subjectForm:subjectPanel">
102
							<f:setPropertyActionListener
103
								target="#{adminBatchBean.selectedCourse}" value="#{course}" />
104
							<f:setPropertyActionListener
105
								target="#{adminBatchBean.dataVisible}" value="false" />
106
							<f:setPropertyActionListener
107
								target="#{adminBatchBean.formVisible}" value="false" />
108
							<f:setPropertyActionListener
109
								target="#{adminBatchBean.subjectFormVisible}" value="true" />
110
						</p:commandLink>
111
					</p:column>
112
				</p:dataTable>
113
			</p:panel>
114
		</h:form>
115
	</ui:define>
116
</ui:composition>
117
</html>