Created
October 3, 2012 20:54
-
-
Save Chavao/3829774 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.silos.jsf.util; | |
import java.util.List; | |
import javax.faces.component.UIComponent; | |
import javax.faces.component.UIInput; | |
import javax.faces.component.UIViewRoot; | |
import javax.faces.context.FacesContext; | |
/** | |
* | |
* @author Chavão <[email protected]> | |
*/ | |
public class Form { | |
public void clearFields(String formId) { | |
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot(); | |
this.clearFields(viewRoot.findComponent(formId).getChildren()); | |
} | |
private void clearFields(List<UIComponent> elements) { | |
for(UIComponent element : elements) { | |
try { | |
((UIInput) element).resetValue(); | |
} catch (Exception e) { | |
this.clearFields(element.getChildren()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment