Lien
Un lien.
Commentaires
Un fallback permet d'afficher le libellé du lien dans une balise <span> si l'url de l'attribut link est absent.
Lien sans url
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="kuik" uri="kuik" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--@elvariable id="linkViewModel" type="java.util.List<fr.kosmos.web.kore.attributes.interfaces.ILink>"--%>
<c:forEach items="${linkViewModel}" var="linkitem">
<p>
<kuik:link link="${linkitem}" />
</p>
</c:forEach>
<p>
<kuik:link link="${linkViewModel[0]}">
<kuik:icon-content icon="icon://ui/calendar" iconTitle="Title de l'icone" size="sm">
<kuik:heading title="Lien avec un body" level="4"/>
</kuik:icon-content>
</kuik:link>
</p>
| Name | Type | Required | Description |
|---|---|---|---|
| link | fr.kosmos.web.kore.attributes.interfaces.ILink | true | Un objet de type ILink. |
| current | java.lang.Boolean | false | Indique que cet élément représente l'élément courant au sein d'un conteneur ou d'un ensemble d'éléments liés. |
<%@ tag pageEncoding="UTF-8" trimDirectiveWhitespaces="true" dynamic-attributes="dynattrs" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ attribute name="link" required="true" type="fr.kosmos.web.kore.attributes.interfaces.ILink" description="Un objet de type ILink." %>
<%@ attribute name="current" required="false" type="java.lang.Boolean" description="Indique que cet élément représente l'élément courant au sein d'un conteneur ou d'un ensemble d'éléments liés." %>
<c:set var="classes" value="${pageScope.link.classes}"/>
<c:set var="attributes">
<c:forEach items="${dynattrs}" var="a">
<c:choose>
<c:when test="${a.key == 'class'}">
<c:set value="${classes} ${a.value}" var="classes"/>
</c:when>
<c:otherwise>${a.key}="${a.value}" </c:otherwise>
</c:choose>
</c:forEach>
</c:set>
<jsp:doBody var="body" />
<c:choose>
<c:when test="${not empty pageScope.link.url}">
<a href="${pageScope.link.url}"
class="${classes}"
<c:if test="${not empty pageScope.link.title}">title="${pageScope.link.title}" </c:if>
<c:if test="${not empty pageScope.link.relation}">rel="${pageScope.link.relation}" </c:if>
<c:if test="${not empty pageScope.link.target}">target="${pageScope.link.target}" </c:if>
<c:if test="${not empty pageScope.link.hrefLang}">hreflang="${pageScope.link.hrefLang}" </c:if>
<c:if test="${pageScope.current}">aria-current="page" </c:if>>
<c:choose>
<c:when test="${empty fn:trim(body)}">${pageScope.link.label}</c:when>
<c:otherwise>${body}</c:otherwise>
</c:choose>
</a>
</c:when>
<c:otherwise>
<span class="${classes}" <c:if test="${pageScope.current}">aria-current="page"</c:if>>
${pageScope.link.label}
</span>
</c:otherwise>
</c:choose>