Selecting buttons in a RadioButtonGroup [message #1841384] |
Thu, 13 May 2021 19:39  |
Eclipse User |
|
|
|
Hi there everyone,
I have an RadioButtonGroup based on the GenderCodeType in the one day tutorial.
I am trying to select buttons in the group based on the values in an EntityDo field.
This is the code I'm using
if (employee.gender().get().equals(TEXTS.get("Male"))) {
getGenderGroup().getButtonFor(MaleCode.ID).setSelected(true);
} else if (employee.gender().get().equals(TEXTS.get("Female"))) {
getGenderGroup().getButtonFor(FemaleCode.ID).setSelected(true);
} else if (employee.gender().get().equals(TEXTS.get("X"))) {
getGenderGroup().getButtonFor(XCode.ID).setSelected(true);
}
However, I keep getting a java.lang.NullPointerException: null on each of the lines where I try to setSelected(true).
What am I doing wrong?
Cheers,
JD
|
|
|
|
Re: Selecting buttons in a RadioButtonGroup [message #1841419 is a reply to message #1841403] |
Sat, 15 May 2021 05:03  |
Eclipse User |
|
|
|
@Beat
Thanks a lot for your reply.
My GenderCodeType.java, a simple modification of the one in the one day tutorial, looks like this:
public class GenderCodeType extends AbstractCodeType<String, String> {
private static final long serialVersionUID = 1L;
public static final String ID = "Gender";
@Override
public String getId() {
return ID;
}
@Order(1000)
public static class MaleCode extends AbstractCode<String> {
private static final long serialVersionUID = 1L;
public static final String ID = "M";
@Override
protected String getConfiguredText() {
return TEXTS.get("Male");
}
@Override
public String getId() {
return ID;
}
}
@Order(2000)
public static class FemaleCode extends AbstractCode<String> {
private static final long serialVersionUID = 1L;
public static final String ID = "F";
@Override
protected String getConfiguredText() {
return TEXTS.get("Female");
}
@Override
public String getId() {
return ID;
}
}
@Order(3000)
public static class XCode extends AbstractCode<String> {
private static final long serialVersionUID = 1L;
public static final String ID = "X";
@Override
protected String getConfiguredText() {
return TEXTS.get("X");
}
@Override
public String getId() {
return ID;
}
}
}
Thanks for your suggestions on TEXTS.get(). But my code should work with the GenderCodeType.java above, I believe.
Cheers,
JD
|
|
|
Powered by
FUDForum. Page generated in 0.24828 seconds