Hi All,
I’m working on a customization where the setRollUpImage method in our component is responsible for setting an image path. Currently, it works for most cases, but in some situations rollUpImage is null because the primary source doesn’t return a value.
I want to add a fallback so that if the current logic doesn’t return a valid image, it should use delegate.getSrc() instead - without affecting the existing functionality.
What’s the best way to modify the method so it still respects the current logic but adds this fallback?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @EthanRo5,
Have you tried this by adding a simple null or empty check after your existing logic in setRollUpImage? I appreciate if you provide us detailed code/logs to understand and resolve your issue please. Try this below reference example:
public void setRollUpImage(String rollUpImage) {
// Existing logic for setting the image
this.rollUpImage = rollUpImageFromPrimarySource();
// Fallback logic
if (StringUtils.isBlank(this.rollUpImage)) {
this.rollUpImage = delegate.getSrc();
}
}
This ensures that the fallback is only used if the primary assignment didn’t produce a valid image path.
Hi @EthanRo5,
Have you tried this by adding a simple null or empty check after your existing logic in setRollUpImage? I appreciate if you provide us detailed code/logs to understand and resolve your issue please. Try this below reference example:
public void setRollUpImage(String rollUpImage) {
// Existing logic for setting the image
this.rollUpImage = rollUpImageFromPrimarySource();
// Fallback logic
if (StringUtils.isBlank(this.rollUpImage)) {
this.rollUpImage = delegate.getSrc();
}
}
This ensures that the fallback is only used if the primary assignment didn’t produce a valid image path.
Views
Likes
Replies
Views
Likes
Replies