Button/Link
Data
Input
Miscellaneous
Multimedia
Output
Panel
Select
JSTL
Faces Core
Facelets
Extensions

Note

  • alloy:outputlink is intended to be used to render a simple <a href="...">hyperlink</a> that requests a URL via HTTP GET.
  • alloy:link is intended to be used to render a hyperlink that navigates to other JSF views via HTTP GET, or perhaps to re-render the same view with different view parameters via f:param child tags.

alloy:outputLink

OutputLink is a UIOutput component that renders an <a> element (hyperlink). Since it extends HtmlOutputLink, it supports all the features of h:outputLink.

Conversion Usage

The value attribute can be converted via the converter attribute or by specifying an f:converter type of child tag. In addition, custom user feedback can be specified via the converterMessage attribute.

Link to a map of China

Source Code

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:alloy="http://liferay.com/faces/alloy"
xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<alloy:form>
<alloy:outputLabel value="#{i18n['country']}" />
<alloy:selectOneMenu id="selectOneMenuId" value="#{outputLinkModelBean.country}">
<f:selectItems value="#{countryService.allCountries}" var="country" itemValue="#{country}"
itemLabel="#{country.countryName}" />
<f:ajax render="selectOneMenuId outputLinkId" />
<f:converter converterId="com.liferay.faces.showcase.converter.CountryConverter" />
</alloy:selectOneMenu>
<br />
<alloy:outputLink id="outputLinkId" converter="com.liferay.faces.showcase.converter.CountryGmapConverter"
target="_blank" value="#{outputLinkModelBean.country.countryId}">
<alloy:outputText value="#{i18n['link-to-a-map-of']} #{outputLinkModelBean.country.countryName}" />
</alloy:outputLink>
</alloy:form>
</ui:composition>
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@ManagedBean
@RequestScoped
public class OutputLinkModelBean {
@ManagedProperty(value = "#{countryService}")
private CountryService countryService;
// Private properties
private Country country;
public Country getCountry() {
return country;
}
public CountryService getCountryService() {
return countryService;
}
@PostConstruct
public void postConstruct() {
this.country = countryService.getAllCountries().get(0);
}
public void setCountry(Country country) {
this.country = country;
}
public void setCountryService(CountryService countryService) {
this.countryService = countryService;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@FacesConverter(value = "com.liferay.faces.showcase.converter.CountryGmapConverter")
public class CountryGmapConverter implements Converter {
// Static field must be declared volatile in order for the double-check idiom to work (requires JRE 1.5+)
private static volatile Map<Long, Country> countryMap;
@Override
public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value) {
// no-op
return null;
}
@Override
public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value) {
Country country = getCountryMap(facesContext).get(value);
String URL = "https://www.google.com/maps/place/";
try {
return URL + URLEncoder.encode(country.getCountryName(), "UTF-8");
}
catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
}
protected Map<Long, Country> getCountryMap(FacesContext facesContext) {
Map<Long, Country> countryMap = CountryGmapConverter.countryMap;
// First check without locking (not yet thread-safe)
if (countryMap == null) {
synchronized (CountryGmapConverter.class) {
countryMap = CountryGmapConverter.countryMap;
// Second check with locking (thread-safe)
if (countryMap == null) {
ELResolver elResolver = facesContext.getApplication().getELResolver();
ELContext elContext = facesContext.getELContext();
CountryService countryService = (CountryService) elResolver.getValue(elContext, null,
"countryService");
countryMap = CountryGmapConverter.countryMap = countryService.getCountryMap();
}
}
}
return countryMap;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Liferay Faces Alloy 4.1.1 + Liferay Faces Bridge Implementation 5.0.0 + Showcase Common 4.0.0 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20