olá, galera
o que estou tentando fazer é o seguinte: criar um commandButton que valide e submeta um h:form que não seja seu parent da mesma forma como se esse h:form fosse seu parent. Isto é, quando um commandButton dentro de um h:form é pressionado, o JSF processa as validações desse h:form e, se as validações estiverem ok, executa o seu método action, caso as validações não estejam ok, o método não é chamado, e as mensagens de erro são renderizadas, etc. Preciso fazer esse mesmo processo, mas a partir de um commandButton que não é filho desse h:form.
será alguém poderia dar uma dica?
valeu
estou usando: mojarra 2.0.4, primefaces 2.2.1, GlassFish 3.1
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<p:panel id="panel">
<p:growl/>
<h:form id="frm0">
<p:panel header="frm">
<p:commandButton id="bto01" value="bto01" action="#{beanTest.doAction}" //bto01 deve submeter o frm01. Se a validação falhar não deve chamar doAction(), e nem apagar os valores válidos, da mesma forma que faria bto02 (abaixo)
oncomplete="frm01.submit()" update="panel"/>
</p:panel>
</h:form>
<p/>
<h:form id="frm01">
<p:panel header="frm01">
<h:panelGrid columns="2">
<h:outputText value="text01 "/>
<h:inputText id="text1" value="#{beanTest.text01}" required="true" requiredMessage="txt01 vazio"/>
<h:outputText value="text02 "/>
<h:inputText id="text2" value="#{beanTest.text02}" required="true" requiredMessage="txt02 vazio"/>
<p:commandButton id="bto02" value="bto02" action="#{beanTest.doAction}"
update="panel"/>
</h:panelGrid>
</p:panel>
</h:form>
</p:panel>
</h:body>
</html>
managedBean
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package p01;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.ViewScoped;
/**
*
* @author Rafael
*/
@ManagedBean
@ViewScoped
public class BeanTest implements Serializable{
/** Creates a new instance of Bean00 */
private String text01;
private String text02;
public String doAction(){
System.out.println("********* DOING ACTION ***********");
return null;
}
public String getText01() {
return text01;
}
public void setText01(String text01) {
this.text01 = text01;
}
public String getText02() {
return text02;
}
public void setText02(String text02) {
this.text02 = text02;
}
}