InputTextarea extends standard InputTextarea with autoComplete, autoResize, remaining characters counter and theming features.
<p:growl id="growl" showSummary="true" showDetail="true" keepAlive="true" life="3000">
<p:autoUpdate/>
</p:growl>
<div class="card">
<h:form>
<h5>AutoResize</h5>
<p:inputTextarea rows="6" cols="33"/>
<h5>Remaining Chars</h5>
<p:inputTextarea rows="5" cols="30" counter="display" maxlength="10"
counterTemplate="{0} characters remaining." autoResize="false"/>
<h:outputText id="display" class="block" />
<h5>AutoComplete</h5>
<p>Following inputTextarea send a query for each word that has at least 4 characters to the complete method. Try typing "PrimeFaces".</p>
<p:inputTextarea rows="10" cols="50" completeMethod="#{inputTextareaView.completeArea}" queryDelay="750"
minQueryLength="4">
<p:ajax event="itemSelect" listener="#{inputTextareaView.onSelect}"/>
</p:inputTextarea>
</h:form>
</div>
@Named
@RequestScoped
public class InputTextareaView {
public List<String> completeArea(String query) {
List<String> results = new ArrayList<>();
if ("PrimeFaces".equals(query)) {
results.add("PrimeFaces Rocks!!!");
results.add("PrimeFaces has 100+ components.");
results.add("PrimeFaces is lightweight.");
results.add("PrimeFaces is easy to use.");
results.add("PrimeFaces is developed with passion!");
}
else {
for (int i = 0; i < 10; i++) {
results.add(query + i);
}
}
return results;
}
public void onSelect(SelectEvent<String> event) {
FacesContext facesContext = FacesContext.getCurrentInstance();
facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "select", event.getObject()));
}
}