Let’s assume you have 5 fields and want to display them when you click a button or enter with a shortcut.
In the Bean
you make a counter, every click on the increment button + 1. Then on inputText
you put a rendered = "bean.contador == 1"
and so on. Then make a button that when clicked picks up the counter and decreases 1.
I’d be like this:
<p:inputText size="40" rendered="ClienteBean.contador == 1" />
<p:inputText size="40" rendered="ClienteBean.contador == 2" />
<p:inputText size="40" rendered="ClienteBean.contador == 3" />
Clientebean:
private Integer contador=0;
//Get and Set's
public void adicionaCampo(){
contador++;
//Adiciona elemento na lista
}
public void removeCampo(){
contador--;
//Remove elemento da lista
}
then just call these methods on a button or else on a <p:hotkey>
.
You want to do this dynamically or with a set amount of fields?
– DiegoAugusto
Whatever, the field limit can be predefined.
– SoabTI