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

Correct behaviour of CheckBoxController with values #59

Merged
merged 3 commits into from
Jul 12, 2017

Conversation

danielgruber
Copy link
Contributor

When passing a array of values, CheckboxController was having wrong. Now it's doing like SelectionController

@@ -132,7 +140,7 @@ public void refresh(CheckBox checkbox, int index) {
Set<Object> modelValues = retrieveModelValues();
checkbox.setChecked(
modelValues.contains(
areValuesDefined() ? checkbox.getText() : index
!areValuesDefined() ? checkbox.getText() : values[index]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the exact issue you're trying to solve? The current behavior is already the same as SelectionController as far as I can tell.

The current implementation is based on the documented behavior (see comments in the constructor). Specifically, if the useItemsAsValues param that is passed in to the constructor is false, the CheckBoxController will represent the selected fields using the 0-based index (as in integer). When you want to read the values in your UI, you can perform the index-to-value mapping if needed.

Let me know if I'm missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, basically the problem is that my values are not my text of the checkbox, since sometimes I might have a checkbox with value a and translated title of a. I see your point that the 0-based index muss be supported, so I updated the PR

@danielgruber
Copy link
Contributor Author

Update PR, is it now ok? :)

Copy link
Owner

@dkharrat dkharrat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense now. Thanks for the fix!

@dkharrat dkharrat merged commit d252e92 into dkharrat:master Jul 12, 2017
@dkharrat
Copy link
Owner

Note that I've released version 0.4.2 that includes your fix.

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

Successfully merging this pull request may close these issues.

None yet

2 participants