Hello Cuba community,
I’ve come upon an issue that I’m not sure how to handle. I’ve got a URL field in an edit screen that is supposed to be converted to a clickable link in the browse screen. I’ve achieved this through help in this post. This works perfectly, except for the fact that the URL field isn’t a required field, so I’m getting null pointer exceptions when a URL isn’t available. I’ve tried working around this by checking if the URL is there or not, but I keep getting errors. This is one simple example of what I’ve tried:
@Subscribe
public void onBeforeShow(BeforeShowEvent event) {
sOPsTable.addGeneratedColumn("Video URL", newEntity ->{
if (!newEntity.getVideoUrl().isEmpty()) {
Link link = uiComponents.create(Link.class);
link.setUrl(newEntity.getVideoUrl());
link.setCaption(newEntity.getVideoUrl());
link.setTarget("_blank");
return link;
} else {
Label label = uiComponents.create(Label.class);
label.setValue("N/A");
return label;
}
});
}
Of course, it works fine if all entries have this field filled out, but I’m not sure how to get around this. I’m not sure if this is because it’s working in a lamda (which I’m not completely used to). I would really appreciate any help in getting through the NPE issue when there is no value set.
Thanks in advance!
Adam