Estou tentando fazer um contador de caracteres restantes no <h:inputTextArea>
1 - Primefaces é mandatório neste caso?
2- Como faria o método charactersRemaining
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:jsf="http://xmlns.jcp.org/jsf">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>testarea</title>
</h:head>
<h:body>
<h1>JSF 2 textarea example</h1>
<h:form>
<table>
<tr>
<td valign="top">Address :</td>
<td>
<h:inputTextarea value="#{user.address}" rows="10" id="textarea" cols="30" />
<h:inputTextarea id="tweet" style="width: 400px;" value="#{user.address}">
<f:ajax event="keydown" render="charactersRemaining"/>
<f:ajax event="keyup" render="charactersRemaining"/>
</h:inputTextarea>
<h:outputText id="charactersRemaining"
value="#{user.charactersRemaining}"/> characters left
</td>
</tr>
</table>
<h:commandButton value="Submit" action="user" />
</h:form>
</h:body>
</html>
package com.marcel.model;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import java.io.Serializable;
@ManagedBean(name="user")
@SessionScoped
public class UserBean implements Serializable {
private String address;
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String charactersRemaining() {
return ;
}
}