|
Predictions 4.10.0.0 | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Class Summary | |
---|---|
CodeTableUtil | Fetches code tables from the database upon startup. |
Enum Summary | |
---|---|
CodeTable | All code tables used in this application. |
Code Tables for the application.
This code was taken from the Fish and Chips Club with minor modifications. In the current case, there is only one code table. This may be overkill. However, in most practical apps, there will be many such code tables.
The general approach in this implementation is to treat the underlying
id (the primary key) of the Code
as being most important, and all
other items as secondary aliases for the id - the text, short form, and long form.
(Some would object to this style, since it makes underlying database identifiers more visible
than usually desired. In practice, however, this does not seem to be a significant issue.)
StartupTasks
will call
CodeTableUtil.init(ServletContext)
to initialize all items
related to Code Tables. This same method must also be called if any code table changes content.
CodeTable.getTableName()
as key.
Typically, two aspects of a Code are referenced in a form : one of the code's textual aliases is
made visible to the user, while its underlying id is always used as the value actually POSTed during form submission.
Here is an example which references a code table named 'outcomes' :
<select name="Outcome"> <c:forEach var="item" items="${outcomes}"> <option value="${item.id}">${item}</option> </c:forEach> </select>
<w:txtFlow> ... <select name="Outcome"> <c:forEach var="item" items="${outcomes}"> <option value="${item.id}">${item.text.rawString}</option> </c:forEach> </select> ... </w:txtFlow>
It is easy to forget to perform the above, especially when special characters appear infrequently. This is a pitfall of using the Code class. This pitfall appears only with multilingual apps, and when your codes includes special characters. See EscapeChars.forHTML() for the list of escaped characters. This will avoid double-escaping of special characters, which is always undesirable.
Id
for the
code - not the full Code
object. Inside the constructor, the Id is 'expanded' into a
full Code object, using CodeTable.codeFor(Id, CodeTable)
.
This style has these consequences :
Code
are always available, if needed.
|
Predictions 4.10.0.0 | ||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |