JSF Showcase
h:commandLink
HtmlCommandLink is a UICommand component that renders an<a>
element. The component must be a child of h:form in order to trigger the action or actionListener.
Param Usage
URL parameters can be specified via the action attribute. By specifying afaces-redirect=true
parameter in the action attribute, it will utilize the POST/REDIRECT/GET pattern.
Source Code
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> <h:form> <f:facet name="label"> <h:selectBooleanCheckbox value="#{commandModelBean.ajax}"> <f:ajax render="field" /> </h:selectBooleanCheckbox> </f:facet> <h:commandLink action="/views/component.xhtml?faces-redirect=true&componentPrefix=h&componentName=commandlink&componentUseCase=navigation&foo=1234" value="< #{i18n['back-to-navigation-with']} foo=1234"> <f:ajax disabled="#{!commandModelBean.ajax}" /> </h:commandLink> </h:form> </ui:composition>
@ManagedBean @ViewScoped public class CommandModelBean implements Serializable { // serialVersionUID private static final long serialVersionUID = 332271404377673109L; // Injections @ManagedProperty(value = "#{customerService}") private CustomerService customerService; // Private Data Members private boolean ajax; private Customer selectedCustomer; private List<Customer> customers; public List<Customer> getCustomers() { return customers; } public Customer getSelectedCustomer() { return selectedCustomer; } public boolean isAjax() { return ajax; } @PostConstruct public void postConstruct() { customers = customerService.getCustomers(0, 5); } public void setAjax(boolean ajax) { this.ajax = ajax; } public void setCustomerService(CustomerService customerService) { this.customerService = customerService; } public void setSelectedCustomer(Customer selectedCustomer) { this.selectedCustomer = selectedCustomer; } }
Liferay Faces Bridge Implementation 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20