-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExercises-Day1.tex
More file actions
868 lines (754 loc) · 35.9 KB
/
Exercises-Day1.tex
File metadata and controls
868 lines (754 loc) · 35.9 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
\addcontentsline{toc}{part}{Day 1: Introductions and Overview of Rice Basics}
\part*{Day 1\\
Introductions and Overview of Rice Basics}
%% \phantomsection
\addcontentsline{toc}{section}{Exercise 1: Advanced Rice Customization Patterns}
{\setlength{\baselineskip}%
{0.0\baselineskip}
\section*{\flushright Exercise 1\\Advanced Rice Customization Patterns}
\hrulefill \par}
\addcontentsline{toc}{subsection}{Description}
\subsection*{Description}
This exercise is designed to help developers explore different
patterns within Kuali Rice for development. There are many different
areas for customization within Rice itself. There are also just as
many different ways of doing the same thing. This can be confusing,
daunting, and troublesome. In this exercise, I will explore some
preferred methods for some advanced level customizations like creating
your own module within Rice or adding your own Constants to be
accessed from the webapp.
\addcontentsline{toc}{subsection}{Goals}
\subsection*{Goals}
\begin{itemize}
\item Create a custom module.
\item Create a custom DD Control class.
\item See interesting ways to customize the portal.
\item Create a custom JSP/JSTL function.
\item Create a custom JstlListener and see how that works.
\item Create custom parameters for your application-config.xml
configuration
\item Add an extension to a business object
\end{itemize}
\addcontentsline{toc}{subsection}{Creating a Custom Module}
\subsection*{1 Creating a Custom Module}
\subsection*{1.1 Browse the Rice Source Project}
\subsection*{1.2 Create a New Directory}
\includegraphics[width=\textwidth]{images/Screenshot.png}
Create a new directory in \emph{rice-src} called \emph{training}
\begin{lstlisting}[language=bash,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={Directory
creation for Linux users},frame=single,breaklines=true]
mkdir training
\end{lstlisting}
In Eclipse, Refresh your project.
\subsection*{1.3 Add the Standard Structure}
\subsubsection*{1.3.1 Create Directories}
%% eclipse screenshot here
\begin{lstlisting}[language=bash,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={Directory creation for Linux
users},frame=single,breaklines=true]
mkdir -p src/main/java/
mkdir -p src/main/resources/
mkdir -p src/main/config/
mkdir -p src/main/webapp/
mkdir -p src/test/java/
mkdir -p src/test/resources/
\end{lstlisting}
In Eclipse, Refresh your project.
\subsubsection*{1.3.1 Setup the Build Path}
In Eclipse:
\begin{enumerate}
\item Expand the training folder
\item Expand the src folder
\item Expand the main folder
\item Click your right mouse button on the java folder. A
context menu will appear.
\item Go to \textbf{Build Path} $\rightarrow$ \textbf{Use as Source
Folder}
\item Click your right mouse button on the resources folder. A
context menu will appear.
\item Go to \textbf{Build Path} $\rightarrow$ \textbf{Use as Source
Folder}
\item Expand the test folder
\item Click your right mouse button on the test/java folder. A
context menu will appear.
\item Go to \textbf{Build Path} $\rightarrow$ \textbf{Use as Source
Folder}
\item Click your right mouse button on the test/resources folder. A
context menu will appear.
\item Go to \textbf{Build Path} $\rightarrow$ \textbf{Use as Source
Folder}
\item Click your right mouse button on the training folder. A
context menu will appear.
\item Go to \textbf{Build Path} $\rightarrow$ \textbf{Configure Build
Path}
\item A dialog will appear.\\
\noindent \includegraphics[width=\textwidth]{images/Screenshot3.png}
\item Click on the \textbf{Source} tab.
\item Locate rice-1.0.3/training build path configuration by scrolling
\item Expand \textbf{training/src/main/java}
\item Double-click on \textbf{Default output folder} next to the
\textbf{Output Folder:}
\item A dialog will appear.\\
\includegraphics[width=\textwidth]{images/Screenshot4.png}
\item Toggle \textbf{Specific output folder (path relative to
'rice-1.0.3').}
\item Enter \textbf{target/classes}
\item Expand \textbf{training/src/main/resources}
\item Double-click on \textbf{Default output folder} next to the
\textbf{Output Folder:}
\item A dialog will appear.
\item Toggle \textbf{Specific output folder (path relative to
'rice-1.0.3').}
\item Enter \textbf{target/classes}
\item Expand \textbf{training/src/test/java}
\item Double-click on \textbf{Default output folder} next to the
\textbf{Output Folder:}
\item A dialog will appear.
\item Toggle \textbf{Specific output folder (path relative to
'rice-1.0.3').}
\item Enter \textbf{target/test-classes}
\item Expand \textbf{training/src/test/resources}
\item Double-click on \textbf{Default output folder} next to the
\textbf{Output Folder:}
\item A dialog will appear.
\item Toggle \textbf{Specific output folder (path relative to
'rice-1.0.3').}
\item Enter \textbf{target/test-classes}
\end{enumerate}
\subsection*{1.4 Create a pom.xml for the New Module}
\subsubsection*{1.4.1 Stub out training/pom.xml}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={training/pom.xml},frame=single,breaklines=true]
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<name>Advanced Rice Training</name>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.kuali.rice</groupId>
<artifactId>rice</artifactId>
<version>1.0.3.3</version>
</parent>
<artifactId>training</artifactId>
<packaging>war</packaging>
</project>
\end{lstlisting}
\subsubsection*{1.4.1 Add Basic Dependencies}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={training/pom.xml},frame=single,breaklines=true]
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rice-impl</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
\end{lstlisting}
\subsubsection*{1.4.2 Add the Maven Overlay Plugin}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={training/pom.xml},frame=single,breaklines=true]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<overlays>
<overlay>
<groupId>org.kuali.rice</groupId>
<artifactId>rice-web</artifactId>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>
\end{lstlisting}
\subsubsection*{1.4.2 Add the Dependency to rice-web}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={training/pom.xml},frame=single,breaklines=true]
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rice-web</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rice-web</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
</exclusion>
</exclusions>
</dependency>
\end{lstlisting}
\subsubsection*{1.4.3 Add the Tomcat Maven Plugin}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={training/pom.xml},frame=single,breaklines=true]
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>${tomcat7-maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>${driver.groupId}</groupId>
<artifactId>${driver.artifactId}</artifactId>
<version>${driver.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
\end{lstlisting}
\subsubsection*{1.4.4 Add the Jetty Maven Plugin}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={training/pom.xml},frame=single,breaklines=true]
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<dependencies>
<dependency>
<groupId>${driver.groupId}</groupId>
<artifactId>${driver.artifactId}</artifactId>
<version>${driver.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
\end{lstlisting}
\subsubsection*{1.4.5 Add the Maven Properties}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={training/pom.xml},frame=single,breaklines=true
]
<properties>
<build.environment>dev</build.environment>
<default.context.path>/\$\{project.artifactId\}--\${build.environment\}</default.context.path>
<jetty.plugin.version>7.4.5.v20110725</jetty.plugin.version>
<mysql-connector-java.version>5.1.16</mysql-connector-java.version>
<jetty.version>8.1.5.v20120716</jetty.version>
<tomcat7-maven-plugin.version>2.0-beta-1</tomcat7-maven-plugin.version>
</properties>
\end{lstlisting}
\subsubsection*{1.4.6 Add the Maven Profiles}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={training/pom.xml},frame=single,breaklines=true
]
<profiles>
<profile>
<id>mysql</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<driver.groupId>mysql</driver.groupId>
<driver.artifactId>mysql-connector-java</driver.artifactId>
<driver.version>${mysql-connector-java.version}</driver.version>
</properties>
</profile>
</profiles>
\end{lstlisting}
\subsubsection*{1.4.7 Add the Maven Plugin Repositories}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={training/pom.xml},frame=single,breaklines=true
]
<pluginRepositories>
<pluginRepository>
<id>kuali.nexus</id>
<name>Nexus Repository Manager</name>
<url>http://nexus.kuali.org/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
\end{lstlisting}
\subsubsection*{1.4.6 Install rice-web.jar}
\includegraphics[width=\textwidth]{images/Screenshot6.png}
The above is what happens at this point if you try and install. The
rice-web.jar dependency cannot be fulfilled because it does not
exist. We need to create it.
\begin{lstlisting}[language=bash,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={Maven
commands},frame=single,breaklines=true
]
cd /home/rice/workspace/rice-src/web
mvn -Dmaven.test.skip=true install
\end{lstlisting}
\begin{lstlisting}[language=bash,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={Maven
commans},frame=single,breaklines=true
]
mvn jar:jar
\end{lstlisting}
\includegraphics[width=\textwidth]{images/Screenshot7.png}
\begin{lstlisting}[language=bash,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={Maven
commands},frame=single,breaklines=true
]
mvn install:install-file -DgroupId=org.kuali.rice
-DartifactId=rice-web -Dversion=1.0.3.2 -Dpackaging=jar -Dfile=target/rice-web-1.0.3.2.jar
\end{lstlisting}
\subsection*{1.5 Add a Base Package}
In Eclipse:
\begin{enumerate}
\item Click your right mouse button on the java folder. A context menu will appear.
\item Go to \textbf{New} $\rightarrow$ \textbf{Package}
\item A dialog will appear\\
\includegraphics[width=\textwidth]{images/Screenshot9.png}
\item For Name, use \textbf{training}
\item Click Finish
\end{enumerate}
\subsection*{1.6 Create Base Spring Beans}
\subsubsection*{1.6.1 Stub out
src/main/resources/training/SpringModuleBeans.xml}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={Base
SpringModuleBeans.xml},frame=single,breaklines=true]
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
</beans>
\end{lstlisting}
\subsubsection*{1.6.1 Add the module bean with a parent}
\begin{lstlisting}[numbers=left,language=xml,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={Base
SpringBeans.xml},frame=single,breaklines=true]
<bean id="bookstoreModuleCconfiguration"
parent="bookstoreModuleConfiguration-parentBean" />
<bean id="bookstoreModuleConfiguration-parentBean" abstract="true"
class="org.kuali.rice.kns.bo.ModuleConfiguration">
<property name="namespaceCode" value="bookstore"/>
<property name="initializeDataDictionary" value="true"/>
<property name="dataDictionaryPackages">
<list>
<value>classpath:train/bookstore/bo/datadictionary/</value>
</list>
</property>
<property name="databaseRepositoryFilePaths">
<list>
<value>OJB-repository-bookstore.xml</value>
</list>
</property>
<property name="packagePrefixes">
<list>
<value>train.bookstore.bo</value>
</list>
</property>
</bean>
\end{lstlisting}
\subsubsection*{1.6.1 Add Spring datasource Configuration}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={Spring
datasource setup},frame=single,breaklines=true]
<bean id="trainingDatasource" class="org.kuali.rice.core.database.PrimaryDataSourceFactoryBean" lazy-init="true">
<property name="preferredDataSourceParams">
<list>
<value>training.datasource</value>
</list>
</property>
<property name="preferredDataSourceJndiParams">
<list>
<value>training.datasource.jndi.location</value>
</list>
</property>
<property name="serverDataSource" value="false"/>
</bean>
<bean id="trainingOjbConfigurer" class="org.kuali.rice.core.ojb.BaseOjbConfigurer">
<property name="jcdAliases">
<list>
<value>trainingDataSource</value>
</list>
</property>
<property name="metadataLocation" value="classpath:training/OJB-repository-bookstore.xml" />
</bean>
\end{lstlisting}
\subsubsection*{1.6.1 Setup platformAwareDao}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={Spring
datasource setup src/main/resources/training/OJB-repository-bookstore.xml},frame=single,breaklines=true]
<bean id="platformAwareDao" abstract="true" class="org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb">
<property name="jcdAlias" value="trainingDataSource" />
<property name="dbPlatform" ref="dbPlatform" />
</bean>
\end{lstlisting}
\subsection*{1.7 Stub Base OJB Mapping}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={Stubbed
OJB Descriptor file src/main/resources/OJB-repository-training.xml},frame=single,breaklines=true]
<descriptor-repository version="1.0">
<jdbc-connection-descriptor jcd-alias="trainingDataSource" default-connection="false" jdbc-level="3.0" eager-release="false" batch-mode="false"
useAutoCommit="0" ignoreAutoCommitExceptions="false">
<sequence-manager className="org.kuali.rice.core.ojb.ConfigurableSequenceManager">
<attribute attribute-name="property.prefix" attribute-value="datasource.ojb.sequenceManager" />
</sequence-manager>
<object-cache class="org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl" />
</jdbc-connection-descriptor>
</descriptor>
\end{lstlisting}
\addcontentsline{toc}{subsection}{Build It}
\subsection*{1.8 Build it}
\subsubsection*{1.8.1 Open a Shell to the Project Directory}
\begin{lstlisting}[basicstyle=\scriptsize,language=bash,backgroundcolor=\color{ubergray},caption={Change
directory to the project in Linux},frame=single,breaklines=true]
cd workspace/rice-src/training
\end{lstlisting}
In Eclipse, Refresh your project.
\subsubsection*{1.8.2 Go}
\begin{lstlisting}[language=bash,basicstyle=\scriptsize,backgroundcolor=\color{ubergray},caption={Maven
commands},frame=single,breaklines=true
]
cd /home/rice/workspace/rice-src/training
mvn -Dmaven.test.skip=true war:inplace
mvn -Dmaven.test.skip=true tomcat:run
\end{lstlisting}
\includegraphics[width=\textwidth]{images/Screenshot10.png}
You should see the above after starting tomcat
\includegraphics[width=\textwidth]{images/Screenshot11.png}
Browse to http://localhost:8080/rice-dev/. Then login as
quickstart. You should see the above.
\addcontentsline{toc}{subsection}{Creating a Custom Data Dictionary Control}
\subsection*{2 Creating a Custom Data Dictionary Control}
Control definitions are just Spring beans accessed via the
BusinessObjectMetadataService and the DataDictionaryService. Besides
controls, you can create or extend any aspect of the DataDictionary
including relationships, lookup definitions, and the workflow
attributes.
The core DataDictionary classes are located in
\textbf{impl/src/main/java/org/kuali/rice/kns/datadictionary/} of your
rice source code distribution.
\includegraphics[width=\textwidth]{images/Screenshot-Java - Eclipse .png}
\subsubsection*{2.1 Add a datadictionary Package to Our Module}
%% Add an eclipse screenshot
\begin{lstlisting}[basicstyle=\scriptsize,language=bash,backgroundcolor=\color{ubergray},caption={Directory creation for Linux
users},frame=single,breaklines=true]
mkdir -p training/src/main/java/training/datadictionary/control
\end{lstlisting}
\emph{In Eclipse, Refresh your project.}
\subsubsection*{2.2 Stub SuggestsBox Control in src/main/java/training/datadictionary/control}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={Stubbed
OJB Descriptor file src/main/resources/OJB-repository-training.xml},frame=single,breaklines=true]
package training.datadictionary.control;
/**
*
*/
public class SuggestsBoxDefinition extends ControlDefinitionBase {
private static final long serialVersionUID = -1L;
public SuggestsBoxDefinition() {
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return "SuggestsBoxDefinition";
}
}
\end{lstlisting}
\addcontentsline{toc}{subsection}{Creating a Custom JSTL Function}
\subsection*{3 Creating a Custom JSTL Function}
\subsubsection*{3.1 Add a web Package to Our Module}
%% Add an eclipse screenshot
\begin{lstlisting}[basicstyle=\scriptsize,language=bash,backgroundcolor=\color{ubergray},caption={Directory creation for Linux
users},frame=single,breaklines=true]
mkdir -p training/src/main/java/training/web/
\end{lstlisting}
\subsubsection*{3.2 Stub a TrainingFunctions Class in the web
Package}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=java,backgroundcolor=\color{ubergray},caption={training/web/TrainingFunctions},frame=single,breaklines=true]
package training.web;
/**
* Full of static methods for JSTL function access.
*
*/
public final class TrainingFunctions {
}
\end{lstlisting}
\subsubsection*{3.2 Add a Method that Fetches System Parameters}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=java,backgroundcolor=\color{ubergray},caption={training/web/TrainingFunctions},frame=single,breaklines=true]
...
...
import static org.kuali.rice.kns.service.KNSServiceLocator.getParameterService
public final static boolean paramExists(final String component, final String
name) {
return getParameterService().parameterExists("KR-TRN", component, name);
}
public final static String getParameter(final String component, final String
name) {
return getParameterService().getParameterValue("KR-TRN", component, name);
}
public final static List<String> getParameters(final String component, final String
name) {
return getParameterService().getParameterValues("KR-TRN", component, name);
}
public final static boolean isEnabled(final String component, final String
name) {
return getParameterService().getIndicatorParameter("KR-TRN", component, name);
}
public final static boolean isPermitted(final String permissionName) {
return
getPermissionService().hasPermission(GlobalVariables.getUserSession().getPrincipalId(),
"KR-TRN", permissionName, null);
}
\end{lstlisting}
\subsubsection*{3.3 Stub a Tag Library Definition for the Module}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={src/main/webapp/WEB-INF/tlds/trnfunc.tld
Tag Library Definition},frame=single,breaklines=true]
<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" version="2.0">
</taglib>
\end{lstlisting}
\subsubsection*{3.4 Define the Tag Library}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={src/main/webapp/WEB-INF/tlds/trnfunc.tld
Tag Library Definition},frame=single,breaklines=true]
<description>Training functions library</description>
<display-name>Training functions</display-name>
<tlib-version>1.0</tlib-version>
<short-name>fn</short-name>
<uri>http://www.kuali.org/jsp/jstl/functions</uri>
\end{lstlisting}
\subsubsection*{3.5 Add the Functions from TrainingFunctions}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={src/main/webapp/WEB-INF/tlds/trnfunc.tld
Tag Library Definition},frame=single,breaklines=true]
<function>
<description>Access System Parameters from JSTL</description>
<name>parameterExists</name>
<function-class>training.web.TrainingFunctions</function-class>
<function-signature>boolean parameterExists(java.lang.String, java.lang.String)</function-signature>
<example><c:if
test="${trn-fn:parameterExists('Document', 'ACTIVE_FILE_TYPES')}"></c:if></example>
</function>
<function>
<description>Access System Parameters from JSTL</description>
<name>getParameter</name>
<function-class>training.web.TrainingFunctions</function-class>
<function-signature>java.lang.String getParameter(java.lang.String, java.lang.String)</function-signature>
<example>${trn-fn:getParameter('Document', 'ACTIVE_FILE_TYPES')}</example>
</function>
<function>
<description>Access System Parameters from JSTL</description>
<name>getParameter</name>
<function-class>training.web.TrainingFunctions</function-class>
<function-signature>java.lang.String getParameter(java.lang.String, java.lang.String)</function-signature>
<example>${trn-fn:getParameter('Document', 'ACTIVE_FILE_TYPES')}</example>
</function>
<function>
<description>Access System Parameters from JSTL</description>
<name>isEnabled</name>
<function-class>training.web.TrainingFunctions</function-class>
<function-signature>boolean isEnabled(java.lang.String, java.lang.String)</function-signature>
<example>${trn-fn:isEnabled('Document', 'ALLOW_NEGATIVE_BALANCE_IND')}</example>
</function>
<function>
<description>Is the User Allowed a Permission</description>
<name>isPermitted</name>
<function-class>training.web.TrainingFunctions</function-class>
<function-signature>boolean isPermitted(java.lang.String, java.lang.String)</function-signature>
<example>${trn-fn:isPermitted('View Training Tab')}</example>
</function>
\end{lstlisting}
\subsubsection*{3.6 Test Yourself: What have you learned?}
Using the same examples above, add a call to \textbf{hasPermission} that
you can use to restrict a tab in the portal specifically for FO's.
\addcontentsline{toc}{subsection}{Adding to JstlConstantsInitListener}
\subsection*{3 Adding to JstlConstantsInitListener}
JstlConstantsInitListener can be found in
\textbf{impl/src/main/java/org/kuali/rice/kns/web/listener/JstlConstantsInitListener.java}
of your rice source distribution.
%% Eclipse screenshot here
\subsubsection*{3.1 Add a listener Package to Our Module}
%% Add an eclipse screenshot
\begin{lstlisting}[basicstyle=\scriptsize,language=bash,backgroundcolor=\color{ubergray},caption={Directory creation for Linux
users},frame=single,breaklines=true]
mkdir -p training/src/main/java/training/web/listener
\end{lstlisting}
\subsubsection*{3.1 Stub out a ContextListener}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=java,backgroundcolor=\color{ubergray},caption={training/web/TrainingFunctions},frame=single,breaklines=true]
package training.web.listener;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
/**
* This class is the JstlContants implementation of the ServletContextListener.
*/
public class JstlConstantsInitListener implements ServletContextListener {
}
\end{lstlisting}
\subsubsection*{3.1 Add a Constant}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=java,backgroundcolor=\color{ubergray},caption={training/web/TrainingFunctions},frame=single,breaklines=true]
package training;
import org.kuali.rice.core.util.JSTLConstants;
public class TrainingConstants extends JSTLConstants {
public static String CURRENT_PROCESS_DATE_PARAMETER = "CURRENT_PROCESS_DATE";
}
\end{lstlisting}
\subsubsection*{3.1 Add Constants to the Listener}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=java,backgroundcolor=\color{ubergray},caption={training/web/TrainingFunctions},frame=single,breaklines=true]
import training.TrainingConstants;
...
...
public void contextInitialized(ServletContextEvent sce) {
ServletContext context = sce.getServletContext();
// publish application constants into JSP app context with name "Constants"
context.setAttribute("TrainingConstants", new TrainingConstants());
}
\end{lstlisting}
\subsubsection*{3.1 Add the New InitListener to the web.xml}
The listener needs to be added to the Rice web.xml file. There is only
one web.xml file for an application. Each rice project has one. It
will be located in your project source tree at
src/main/webapp/WEB-INF/
%% Show Eclipse screenshot
In it, you will see a section with listeners that looks like:
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=java,backgroundcolor=\color{ubergray},caption={src/main/webapp/WEB-INF/web.xml},frame=single,breaklines=true]
<listener>
<listener-class>org.kuali.rice.core.web.listener.StandaloneInitializeListener</listener-class>
</listener>
<listener>
<listener-class>org.kuali.rice.kns.web.listener.JstlConstantsInitListener</listener-class>
</listener>
<listener>
<listener-class>org.kuali.rice.kns.web.listener.KualiHttpSessionListener</listener-class>
</listener>
\end{lstlisting}
Just add yours. Now when your application starts, you will be able to
access your constants from the JSP/JSTL.
\addcontentsline{toc}{section}{Exercise 2: Portal Customization}
{\setlength{\baselineskip}%
{0.0\baselineskip}
\section*{\flushright Exercise 2\\Portal Customization}
\hrulefill \par}
\addcontentsline{toc}{subsection}{Description}
\subsection*{Description}
Besides a middleware framework and API, Rice supplies a reference
implementation portal with administrative focused user
interfaces. Most institutions will want to customize this to fit their
users and their functional needs. That will involve some modification
at just about any level. This exercise explores advanced techniques
for portal customization
\addcontentsline{toc}{subsection}{Goals}
\subsection*{Goals}
\begin{itemize}
\item Learn new ways to use javascript to communicate with SOA
\item How to creatively add functionality and rich user interface
design to the Kuali Portal
\end{itemize}
\addcontentsline{toc}{subsection}{1 Add a new Tab Restricted by Permission}
\subsection*{1 Add a New Tab Restricted by Permission}
\subsection*{1.1 Create a Training Tab}
In \textbf{web/src/main/webapp/WEB-INF/tags/rice-portal/}, create a
file called \textbf{trainingTab.tag} with the following
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={web/src/main/webapp/WEB-INF/tags/rice-portal/trainingTab.tag},frame=single,breaklines=true]
<%--
Copyright 2007-2009 The Kuali Foundation
Licensed under the Educational Community License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.opensource.org/licenses/ecl2.php
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ include file="/rice-portal/jsp/sys/riceTldHeader.jsp"%>
<td class="content" valign="top">
<trainingChannel:training />
</td>
\end{lstlisting}
\subsubsection*{1.2 Create a Training Channel}
Create the directory
\textbf{web/src/main/webapp/WEB-INF/tags/rice-portal/channel/training/}. Then
add the following \textbf{training.tag} to it.
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={web/src/main/webapp/WEB-INF/tags/rice-portal/trainingTab.tag},frame=single,breaklines=true]
<%--
Copyright 2007-2009 The Kuali Foundation
Licensed under the Educational Community License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.opensource.org/licenses/ecl2.php
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%>
<%@ include file="/rice-portal/jsp/sys/riceTldHeader.jsp"%>
<channel:portalChannelTop channelTitle="Training" />
<div class="body">
<ul class="chan">
<li><portal:portalLink displayTitle="true" title="Rule Attribute" url="${ConfigProperties.kr.url}/lookup.do?businessObjectClassName=org.kuali.rice.kew.rule.bo.RuleAttribute&docFormKey=88888888&returnLocation=${ConfigProperties.application.url}/portal.do&hideReturnLink=true" /></li>
</ul>
</div>
<channel:portalChannelBottom />
\end{lstlisting}
\subsubsection{1.3 Add to training.tag usage for isPermitted}
\addcontentsline{toc}{subsection}{2 Add Fancy Tooltips to Channel Content}
\subsection*{2 Add Tooltips to Channels}
\subsubsection*{2.1 Include Bootstrap}
Add the following to the \textbf{src/main/webapp/kr/WEB-INF/jsp/tldHeader.jsp}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={web/src/main/webapp/WEB-INF/tags/rice-portal/trainingTab.tag},frame=single,breaklines=true]
<link href="${ConfigurationProperties.application.url}/kr/css/bootstrap.css" rel="stylesheet">
<link href="${ConfigurationProperties.application.url}/kr/css/bootstrap-responsive.css" rel="stylesheet">
<link href="${ConfigurationProperties.application.url}/kr/scripts/google-code-prettify/prettify.css"
rel="stylesheet">
<script src=""${ConfigurationProperties.application.url}/kr/scripts/jquery.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/google-code-prettify/prettify.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-transition.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-alert.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-modal.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-dropdown.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-scrollspy.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-tab.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-tooltip.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-popover.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-button.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-collapse.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-carousel.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-typeahead.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/bootstrap-affix.js"></script>
<script src=""${ConfigurationProperties.application.url}/kr/scripts/application.js"></script>
\end{lstlisting}
\subsubsection*{2.1 Add Portal Link}
Add the following to the \textbf{src/main/webapp/WEB-INF/tags/rice-portal/channel/training/training.tag}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=xml,backgroundcolor=\color{ubergray},caption={web/src/main/webapp/WEB-INF/tags/rice-portal/trainingTab.tag},frame=single,breaklines=true]
<li id="popover1"><a href="#">Some Document</a></li>
\end{lstlisting}
\subsubsection*{2.3 Popover javascript and Fetch Help URL}
\begin{lstlisting}[basicstyle=\scriptsize,numbers=left,language=java,backgroundcolor=\color{ubergray},caption={web/src/main/webapp/WEB-INF/tags/rice-portal/trainingTab.tag},frame=single,breaklines=true]
<script>
$('#popover1').popover({ trigger : 'hover',
content: function() {
var helpUrl = '${ConfigurationProperties.application.url}/kr/help.do?methodToCall=getDocumentHelpText&documentTypeName=IdentityManagementPersonDocument'
var retval = ''
$.get(sliderurl, function(data) {
retval = data;
return data;
})
return retval;
}})
</script>
\end{lstlisting}
\newpage
{\setlength{\baselineskip}%
{0.0\baselineskip}
\section*{Notes}
\hrulefill \par}