Skip to content

Commit

Permalink
Updated CharityPageController
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
roaraf committed Apr 18, 2026
1 parent 92aaac5 commit 068b189
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -18,6 +23,8 @@ public class CharityPageController {

@FXML private Label CharityName;

@FXML private ImageView CharityLogo;

@FXML
public void initialize() {}

Expand All @@ -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);
}
}

/**
Expand Down

0 comments on commit 068b189

Please sign in to comment.