Error Validating in modalPanel
acdias Aug 4, 2007 11:05 AMHi, first: sorry for my bad english, I'm brazilian. :D
Well. I'm working with Facelets, JSF, MyFaces, RichFaces and Ajax4JSF and I have problems with validation in modalPanel.
Here's the code of my template:
<?xml version="1.0" encoding="iso-8859-1"?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
xmlns:rich="http://richfaces.ajax4jsf.org/rich">
<head>
<title>Centro Universitário de Patos de Minas - UNIPAM</title>
<meta name="resource-types" content="document" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="revisit-after" content="2 days" />
<meta name="classification" content="Internet" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Description"
content="Centro Universitário de Patos de Minas - UNIPAM - O seu futuro é aqui. A melhor infra-estrutura e o melhor corpo docente" />
<meta name="Keywords"
content="unipam, centro universitário, patos de minas, minas gerais, administração, agronomia, ciências biológicas, ciências contábeis, direito, educação física, fisioterapia, história, letras, matemática, nutrição, pedagogia, psicologia, publicidade e propaganda, comunicação social, química, secretariado executivo, sistemas de informação, zootecnia, unipam, centro universitário de patos de minas, patos de minas, minas gerais, fepam, internet, aluno, ensino, faculdade, universidade, graduação, pós-graduação, qualidade, cursos online, XHTML, HTML, web standards, tableless, standards, compatibilidade, usabilidade, acessibilidade, web" />
<meta name="robots" content="ALL" />
<meta name="distribution" content="Global" />
<meta name="rating" content="General" />
<meta name="author" content="WEB UNIPAM" />
<meta name="language" content="pt-br" />
<meta name="doc-class" content="Completed" />
<meta name="doc-rights" content="Public" />
<link rel="shortcut icon" href="theme/default/images/favicon.ico" />
<link href="../css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"
src="#{facesContext.externalContext.requestContextPath}/js/valida.js"></script>
</head>
<body>
<a4j:outputPanel ajaxRendered="true">
<h:form style="display:none" prependId="false">
<h:inputHidden id="maximumSeverity"
value="#{facesContext.maximumSeverity.ordinal}" />
</h:form>
</a4j:outputPanel>
<ui:insert name="content" />
</body>
</html>Here, the code of my form:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
xmlns:rich="http://richfaces.ajax4jsf.org/rich"
template="/template.jsp">
<ui:define name="content">
<h:form prependId="false">
<rich:modalPanel id="panel" width="600" height="400">
<f:facet name="header">
<h:outputText
value="Participação em bancas de comissões julgadoras" />
</f:facet>
<f:facet name="controls">
<h:graphicImage value="/images/modal/close.png"
style="cursor:pointer" onclick="Richfaces.hideModalPanel('panel')" />
</f:facet>
<a4j:outputPanel ajaxRendered="true">
<h:messages id="erro" />
</a4j:outputPanel>
<label for="natureza">Natureza:</label>
<h:selectOneRadio required="true"
value="#{bancaController.banca.naturezaBanca.idNaturezaBanca}"
id="natureza">
<f:selectItems value="#{bancaController.radio}" />
</h:selectOneRadio>
<label for="titulo">Título:</label>
<h:inputText id="titulo" required="true"
requiredMessage="Campo Requerido"
value="#{bancaController.banca.titulo}" />
<label for="ano">Ano:</label>
<h:inputText id="ano" value="#{bancaController.banca.ano}" />
<label for="pais">País:</label>
<h:selectOneMenu id="pais"
value="#{bancaController.banca.pais.idPais}" required="true">
<f:selectItems value="#{bancaController.pais}" />
</h:selectOneMenu>
<label for="idioma">Idioma:</label>
<h:selectOneMenu id="idioma"
value="#{bancaController.banca.lingua.idLingua}" required="true">
<f:selectItems value="#{bancaController.idioma}" />
</h:selectOneMenu>
<label for="homepage">Home Page:</label>
<h:inputText value="#{bancaController.banca.homePage}" id="homepage" />
<label for="instituicao">Instituição:</label>
<h:inputText id="instituicao"
value="#{bancaController.banca.instituicao.nome}" />
<h:graphicImage value="/img/lupa.gif"
onclick="javascript:Richfaces.showModalPanel('panel2')" />
<a4j:commandButton value="Cadastrar"
action="#{bancaController.action}" reRender="erro"
oncomplete="windowClose('panel');" />
<a href="javascript:Richfaces.hideModalPanel('panel');">Fechar</a>
</rich:modalPanel>
</h:form>
<rich:panel>
<a href="javascript:Richfaces.showModalPanel('panel')">Adiciona</a>
</rich:panel>
</ui:define>
</ui:composition>And here are de js file:
function windowClose(panelName)
{
if (!(document.getElementById("maximumSeverity").value == "2"))
Richfaces.hideModalPanel(panelName);
}Well... I have no problems to render, but when I click in the a4j:commandButton the validation fails. The form require value of all selectOneRadio's and selectOneMenu's even if they have an item selected. If I put h:form inside the modalPanel I have a request Error when I submit.
What should I do?