|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.web4j.model.Code
public final class Code
An item in a code table.
Here, a value in a code table is modeled with one required item (text), and four optional items (id, short form, long form, and order index). The id is optional, since for 'add' operations it is not yet specified. This class is offered as a convenience for implementing Code Tables. Applications are not required to use it.
Please see the example application for an example of one way of implementing code tables.
A code table is an informal term describing a set of related values. It resembles an enumeration. Simple examples :
SafeText
, which escapes special characters.
When rendering a Code object in a JSP, some care must be taken to ensure that
special characters are not mistakenly escaped twice.
In a single language app, it's usually safe to render a Code by simply using ${code}. This
calls toString()
, which returns escaped text, safe for direct rendering in a JSP.
In a multilingual app, however, the various translation tags (<w:txt>, <w:txtFlow>, <w:tooltip>) already escape special characters. So, if a translation tag encounters a Code somewhere its body, the Code must be in an unescaped form, otherwise it wil be escaped twice, which undesirable. In a multilingual app, you should usually render a Code using ${code.text.rawString}.
This asymmetry between single-language and many-language apps is somewhat displeasing, and
constitutes a pitfall of using this class. If desired, you could define an alternate Code class
whose toString returns a String instead of SafeText
.
Constructor Summary | |
---|---|
Code(Id aId,
SafeText aText)
As in the full constructor, but without a short description, long description, or an order index. |
|
Code(Id aId,
SafeText aText,
SafeText aShortText)
As in the full constructor, but without a long description or order index. |
|
Code(Id aId,
SafeText aText,
SafeText aShortText,
SafeText aLongText)
As in the full constructor, but without an order index. |
|
Code(Id aId,
SafeText aText,
SafeText aShortText,
SafeText aLongText,
Integer aOrderIdx)
Full constructor. |
Method Summary | |
---|---|
boolean |
equals(Object aThat)
|
Id |
getId()
Return the Id passed to the constructor. |
SafeText |
getLongText()
Return the Long Text passed to the constructor. |
Integer |
getOrderIdx()
Return the Order Index passed to the constructor. |
SafeText |
getShortText()
Return the Short Text passed to the constructor. |
SafeText |
getText()
Return the Text passed to the constructor. |
int |
hashCode()
|
String |
toString()
Returns getText() .toString(). |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Code(Id aId, SafeText aText, SafeText aShortText, SafeText aLongText, Integer aOrderIdx) throws ModelCtorException
aId
- underlying database identifier for the code value. Optional, 1..50 characters.aText
- default text for presentation to the end user. Required, 1..50 characters.aShortText
- short form for text presented to the end user. This item is useful for terse
presentation in reports, often as an abbreviation of one or two letters. Optional, 1..10 characters.aLongText
- long form for text presented to the user. For example, this may be a description
or definition of the meaning of the code. Optional, 1..200 characters.aOrderIdx
- defines the order of appearance of this item in a listing. Optional, range 1..1000.
This item is used to provide explicit control over the order of appearance of items as presented to
the user, and will often be related to an ORDER BY clause in an SQL statement.
ModelCtorException
public Code(Id aId, SafeText aText) throws ModelCtorException
ModelCtorException
public Code(Id aId, SafeText aText, SafeText aShortText) throws ModelCtorException
ModelCtorException
public Code(Id aId, SafeText aText, SafeText aShortText, SafeText aLongText) throws ModelCtorException
ModelCtorException
Method Detail |
---|
public Id getId()
public SafeText getText()
public SafeText getShortText()
public SafeText getLongText()
public Integer getOrderIdx()
public String toString()
getText()
.toString().
This is the most user-friendly form of a code, and is useful for rendering in JSPs.
toString
in class Object
public boolean equals(Object aThat)
equals
in class Object
public int hashCode()
hashCode
in class Object
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |