Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple displayed text from property value #298

Open
ghost opened this issue Dec 27, 2020 · 0 comments
Open

Decouple displayed text from property value #298

ghost opened this issue Dec 27, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 27, 2020

The following code works great when the displayed value exactly maps to the stored value:

// Combobox, Single Selection, with ObservableList
ObservableList resolutionItems = FXCollections.observableArrayList(Arrays.asList(
  "1024x768", "1280x1024", "1440x900", "1920x1080")
);
ObjectProperty resolutionSelection = new SimpleObjectProperty<>("1024x768");
Setting.of("Resolution", resolutionItems, resolutionSelection);

This is analogous to the following HTML:

<select name="resoolution">
    <option value="1024x768">1024x768</option>
    <option value="1280x1024">1280x1024</option>
    <option value="1440x900">1440x900</option>
    <option value="1920x1080">1920x1080</option>
</select>

HTML permits changing the displayed value and computed value independently:

<select name="resoolution">
    <option value="1">1024x768</option>
    <option value="2">1280x1024</option>
    <option value="3">1440x900</option>
    <option value="4">1920x1080</option>
</select>

Updated documentation showing how this is possible would be useful. For example, with Locale objects, we might want to display the value of "Simplified Chinese (China)" (from locale.getDisplayName()) to the user while the value the application will store is zh-Hans-CN, which can construct a Locale object fairly easily (e.g., Locale.forLanguageTag(...)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants