portal:inputSearch

InputSearch is a UIInput component that renders a text field and optional button for submitting search criteria.

Général Usage

The value attribute can be bound to a model bean property via EL.

The buttonLabel attribute controls the label of the button.

The placeholder attribute (HTML5-only) controls the text of the hint that appears in the text field before the user enters a value.

Source Code

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:portal="http://liferay.com/faces/portal"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets">

	<h:form>
		<h:messages globalOnly="true" layout="table" />
		<portal:inputSearch actionListener="#{inputSearchBacking.searchActionListener}"
			buttonLabel="#{i18n['submit-search']}" placeholder="#{i18n['enter-your-search-here']}"
			 value="#{inputSearchBacking.searchText}" />
	</h:form>
	<h:outputText id="modelValue" value="#{inputSearchBacking.searchText}" />

</ui:composition>
@ManagedBean
@RequestScoped
public class InputSearchBacking {

	private static final Logger logger = LoggerFactory.getLogger(InputSearchBacking.class);

	private String searchText;

	public String getSearchText() {
		return searchText;
	}

	public void searchActionListener(ActionEvent actionEvent) {

		FacesContext facesContext = FacesContext.getCurrentInstance();
		PhaseId phaseId = facesContext.getCurrentPhaseId();
		logger.debug("searchActionListener: phaseId=[{0}]", phaseId.toString());

		String phaseName = phaseId.toString();
		FacesMessage facesMessage = new FacesMessage("The searchActionListener method was called during the " +
				phaseName + " phase of the JSF lifecycle.");
		facesContext.addMessage(null, facesMessage);
	}

	public void setSearchText(String searchText) {
		this.searchText = searchText;
	}
}
Liferay Faces Bridge Implementation 5.0.0 + Liferay Faces Portal 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20