My application has an input text that would only process the data if it has 8 characters. After that, in the managed bean, it searchs for more data in the database to add it to a list wich is displayed in the same page.
I want to reset the input text after successufuly adding the items or having an error.
I tried applying a setter and that didn't help much.
Here is the code I'm using:
Managed Bean (MajBarreSaisie)
Code: Select all
public void searchMedById() {
if (getCodeMed().length() == 8) {
med = medDAO.getById(Integer.parseInt(getCodeMed()));
if (med != null)
listeMed.add(med);
else
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage("Aucun medicament trouvé avec le code '" + getCodeMed()
+ "'"));
med = new Medicament();
setCodeMed("");
codeMed = "";
}
Code: Select all
.......//Forms data
<p:inputText id="userNameSearch" value="#{majBarreSaisie.codeMed}" >
<p:ajax event="keyup" update="meds"
listener="#{majBarreSaisie.searchMedById}" />
</p:inputText>