Skip to content

Commit

Permalink
2323 focus is not visible over linking banner (#2599)
Browse files Browse the repository at this point in the history
Closes #2323
  • Loading branch information
lbownik authored Dec 4, 2024
1 parent 46a96b9 commit d8ecd6b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
import javax.inject.Named;
import java.io.IOException;
import java.util.List;
import java.util.logging.Logger;

/**
* Responsible for displaying messages and banners across the dataverse.
*/
@SuppressWarnings("serial")
@ViewScoped
@Named("MessagesAndBannersFragment")
public class MessagesAndBannersFragment implements java.io.Serializable {

private static final Logger logger = Logger.getLogger(MessagesAndBannersFragment.class.getCanonicalName());

@EJB
private DataverseTextMessageServiceBean textMessageService;

Expand All @@ -34,17 +32,19 @@ public class MessagesAndBannersFragment implements java.io.Serializable {


public List<String> textMessages(Long dataverseId) {
return textMessageService.getTextMessagesForDataverse(dataverseId, dataverseSession.getLocaleCode());
return textMessageService.getTextMessagesForDataverse(dataverseId,
dataverseSession.getLocaleCode());
}

public List<ImageWithLinkDto> banners(Long dataverseId) {
return bannerDAO.getBannersForDataverse(dataverseId, dataverseSession.getLocaleCode());
return bannerDAO.getBannersForDataverse(dataverseId,
dataverseSession.getLocaleCode());
}

public void redirect(String link) throws IOException {

if (!link.startsWith("http")) {
link = "http://" + link;
link = "http://".concat(link);
}
FacesContext.getCurrentInstance().getExternalContext().redirect(link);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public List<String> getTextMessagesForDataverse(Long dataverseId, String localeC
public List<DataverseTextMessage> fetchAllTextMessagesForDataverse(long dataverseId) {
return em.createQuery("select dtm FROM DataverseTextMessage as dtm " +
"join fetch DataverseLocalizedMessage " +
"where dtm.dataverse.id = :dataverseid")
"where dtm.dataverse.id = :dataverseid",
DataverseTextMessage.class)
.setParameter("dataverseid", dataverseId)
.getResultList();
}
Expand All @@ -136,7 +137,8 @@ public List<DataverseTextMessage> fetchAllTextMessagesForDataverse(long datavers
public List<DataverseTextMessage> fetchTextMessagesForDataverseWithPaging(long dataverseId, int firstResult, int maxResult) {
return em.createQuery("select dtm FROM DataverseTextMessage as dtm " +
"join fetch DataverseLocalizedMessage " +
"where dtm.dataverse.id = :dataverseid order by dtm.id DESC ")
"where dtm.dataverse.id = :dataverseid order by dtm.id DESC ",
DataverseTextMessage.class)
.setParameter("dataverseid", dataverseId)
.setFirstResult(firstResult)
.setMaxResults(maxResult)
Expand Down
10 changes: 7 additions & 3 deletions dataverse-webapp/src/main/webapp/text-messagesAndBanners.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:p="http://primefaces.org/ui">
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">

<!--@elvariable id="dataverse" type="edu.harvard.iq.dataverse.persistence.dataverse.Dataverse"-->
<c:set var="messages" value="#{MessagesAndBannersFragment.textMessages(dataverse.id)}"/>
Expand All @@ -19,8 +20,11 @@

<ui:repeat value="#{banners}" var="banner">
<div class="p-col">
<h:commandLink target="_blank" disabled="#{banner.link == null}" action="#{MessagesAndBannersFragment.redirect(banner.link)}">
<p:graphicImage style="display: block ;margin-left: auto; margin-right: auto; padding: 2px;"
<h:commandLink style="display: block;"
target="_blank"
disabled="#{banner.link == null}"
action="#{MessagesAndBannersFragment.redirect(banner.link)}">
<p:graphicImage style="display: block ;margin-left: auto; margin-right: auto; padding: 2px;"
stream="false"
value="#{banner.image}"
alt="#{bundle['header.banner.alt']} #{banner.link != null ? bundle['opensInNewTab'] : ''}"
Expand Down

0 comments on commit d8ecd6b

Please sign in to comment.