次の NULL 指向のメソッドはすべて、 で宣言されていますAbstractSingleSelectChoice
(オンラインの JavaDoc を参照してください)。これは、 のスーパークラスですDropDownChoice
。コンポーネントで関連するString
値を定義したり、プロパティに基づいてフォーマットされたメッセージを使用したりできます。メソッドを確認して、それらがどのように機能するかを理解してから、実装例をニーズに合ったものに置き換えます。
/**
* Returns the display value for the null value.
* The default behavior is to look the value up by
* using the key retrieved by calling: <code>getNullValidKey()</code>.
*
* @return The value to display for null
*/
protected String getNullValidDisplayValue() {
String option =
getLocalizer().getStringIgnoreSettings(getNullValidKey(), this, null, null);
if (Strings.isEmpty(option)) {
option = getLocalizer().getString("nullValid", this, "");
}
return option;
}
/**
* Return the localization key for the nullValid value
*
* @return getId() + ".nullValid"
*/
protected String getNullValidKey() {
return getId() + ".nullValid";
}
/**
* Returns the display value if null is not valid but is selected.
* The default behavior is to look the value up by using the key
* retrieved by calling: <code>getNullKey()</code>.
*
* @return The value to display if null is not valid but is
* selected, e.g. "Choose One"
*/
protected String getNullKeyDisplayValue() {
String option =
getLocalizer().getStringIgnoreSettings(getNullKey(), this, null, null);
if (Strings.isEmpty(option)) {
option = getLocalizer().getString("null", this, CHOOSE_ONE);
}
return option;
}
/**
* Return the localization key for null value
*
* @return getId() + ".null"
*/
protected String getNullKey() {
return getId() + ".null";
}