Reset input text after ajax callback

UI Components for JSF
Post Reply
Reaphen
Posts: 1
Joined: 22 Aug 2011, 16:32

22 Aug 2011, 16:45

Hello,
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 = "";
		} 

Form data:

Code: Select all

.......//Forms data
<p:inputText id="userNameSearch" value="#{majBarreSaisie.codeMed}" >
				<p:ajax event="keyup" update="meds"
					listener="#{majBarreSaisie.searchMedById}" />
</p:inputText>


Thanks in advance
PrimeFaces 2.2 + MyFaces 2.1.1 in Tomcat 7.0.19

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 39 guests