Skip to content

Instantly share code, notes, and snippets.

@steppat
Created October 14, 2011 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steppat/1286181 to your computer and use it in GitHub Desktop.
Save steppat/1286181 to your computer and use it in GitHub Desktop.
Simples bean para um formulario JSF
package br.com.caelum.bean;
import javax.faces.component.UIForm;
/*
No faces-config.xml
<managed-bean>
<managed-bean-name>formularioBean</managed-bean-name>
<managed-bean-class>br.com.caelum.bean.FormularioBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
*/
public class FormularioBean {
private Double valor;
private UIForm form;
public UIForm getForm() {
return form;
}
public void setForm(UIForm form) {
this.form = form;
//infos sobre component tree
if(!form.getChildren().isEmpty()) {
System.out.println("Input Value: " + ((javax.faces.component.UIInput)form.getChildren().get(0)).getValue());
System.out.println("Input Submitted Value: " +((javax.faces.component.UIInput)form.getChildren().get(0)).getSubmittedValue());
System.out.println("Input Local Value: " +((javax.faces.component.UIInput)form.getChildren().get(0)).getLocalValue());
System.out.println("Validator : " +((javax.faces.component.UIInput)form.getChildren().get(0)).getValidators()[0]);
System.out.println("UICommand Expression: " +((javax.faces.component.UICommand)form.getChildren().get(1)).getActionExpression().getExpressionString());
}
}
public void mostra() {
System.out.println("metodo mostra() foi chamdo ...");
}
public Double getValor() {
return valor;
}
public void setValor(Double valor) {
this.valor = valor;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment