From 068b189000f22d1dd4227ce354db3f55d25449b1 Mon Sep 17 00:00:00 2001 From: Roar Date: Fri, 17 Apr 2026 00:58:09 +0200 Subject: [PATCH] Updated CharityPageController Added reference to CharityLogo fx:id and dynamically sets the image to the logoBlob of the charity, or a placeholder image if the logoBlob is null. --- .../controller/CharityPageController.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java index 81d6f4b..c5669e1 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java @@ -1,9 +1,14 @@ package ntnu.systemutvikling.team6.controller; +import java.io.ByteArrayInputStream; +import java.util.Objects; + import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.control.TextField; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; import ntnu.systemutvikling.team6.controller.components.LoaderScene; import ntnu.systemutvikling.team6.models.Charity; @@ -18,6 +23,8 @@ public class CharityPageController { @FXML private Label CharityName; + @FXML private ImageView CharityLogo; + @FXML public void initialize() {} @@ -39,6 +46,17 @@ public void setCharity(Charity charity) { CharityDescription.setText(charity.getDescription()); CharityName.setText(charity.getName()); + + if (this.charity.getLogoBlob() != null) { + ByteArrayInputStream logoByteStream = new ByteArrayInputStream(this.charity.getLogoBlob()); + Image CharityLogoImage = new Image(logoByteStream); + this.CharityLogo.setImage(CharityLogoImage); + } else { + String placeholderImagePath = + Objects.requireNonNull(getClass().getResource("/images/leggTilBilde.jpg")).toExternalForm(); + Image placeholderImage = new Image(placeholderImagePath); + this.CharityLogo.setImage(placeholderImage); + } } /**