Usar uma xhtml em uma jsp(Resolvido)

15 respostas
N

Boa noite galera eu estou fazendo um projeto onde minha paginas JSF são todas jsp ... gostaria de saber se tem como eu dar um include neste código que peguei na net para mostrar as h:message em uma rich:modalPanel

segue o código de uma pagina xhtml
<?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">
<rich:modalPanel id="_messagesPanel" showWhenRendered="#{not empty facesContext.maximumSeverity}" autosized="true" moveable="true"
                 xml:lang="pt-br" 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:rich="http://richfaces.org/rich"
                 xmlns:a4j="http://richfaces.org/a4j" >

    <f:facet name="header">
        <h:panelGroup style="margin-right: 15px;">
            <h:outputText value="Críticas encontradas em: "/>
            <ui:insert name="pageTitle"/>
        </h:panelGroup>
    </f:facet>
    <f:facet name="controls">
        <h:panelGroup>
            <h:outputLink id="_fecharLink" onclick="document.getElementById('_messagesPanel').component.hide();return false;"
                          style="color: white; font-weight: bold; cursor: pointer; margin-left: 10px; top:3px;">X</h:outputLink>
        </h:panelGroup>
    </f:facet>
    <h:form>
        <rich:messages tooltip="true" style="white-space: pre;">
            <f:facet name="errorMarker">
                <h:graphicImage url="/images/error.gif" style="margin-right:5px; position: relative; top: 1px;"/>
            </f:facet>
        </rich:messages>
        <rich:spacer height="40"/>
        <h:panelGrid style="text-align:center; margin: 0 auto; width: 100%;">
            <h:commandButton value="Fechar" id="_fecharButton" onclick="document.getElementById('_messagesPanel').component.hide();return false;"/>
             <rich:hotKey key="esc" handler="document.getElementById('_messagesPanel').component.hide();return false;"/> <!--se o usuário clicar esc a janela da modal desaparece-->
        </h:panelGrid>
    </h:form>
</rich:modalPanel>

ou tem outra forma de eu usar este mesmo código em minha pagina com extensão jsp ??

vlwww

15 Respostas

N

bom eo coloquei o código que estava no xhtml dentro da jsp… porem quando eo a incluo em outra pagina o modalPanel ja aparece … por cima do e gostaria que ele aparecesse apenas quando ter as mensagens…
obrigado

M

Em um projeto JSF as páginas são JSP mesmo o que diferencia são as taglibs.

.xhtml é extesão pra templates facelets, posso estar errado mas eu acho que esse código ai é um template facelet.

N

sim sim esse código é um template porem minhas paginas são todas JSP
e preciso usar isso nelas
:confused: alguma dica?

M

Você está usando facelets no teu projeto?

N

não :confused:
o que ue precisava se não desse certo isso era abrir um modalPanel quando exebir as mensagens do <h:message>
sacou? não tem outra opção sem ter que usar o facelets?

M

Acho que vc ainda não entendeu.
Você está usando um template facelets sem usar facelets no teu projeto é por isso que não tá funcionando.

Se você quer exibir essa modalPanel para exibir as mensagens do h:message vc consegue mas não desse jeito ai.

Mas caso vc queira usar facelets no projeto dê uma olhada em: http://www.devmedia.com.br/articles/viewcomp.asp?comp=5332

N

se eu colocar facelest em meu projeo eo consigo chamar essa pagina em uma pagina JSP sem as tags template?

obrigado

M

você chegou a ler o link que eu passei?

N

sim

M

vc tentou resolver o problema antes de perguntar?

N

rapaz criei uma template, ate certo ponto funcionou porem no meu rich:menuItem eu tenhu um action=“home” que esta mapeado no meu faces-config porem quando eu clico no botao uma vez ele redireciona certim mais se clico de novo ele parece que se perde e coloca um endereço estranho no navegador antes do http: e não carrega as coisas…

vc sabe o que pode ser?

vlw

N

olha o que aparece antes wyciwyg://22/http://localhost:8083/SUI

M

agora sim vc pode postar o código :slight_smile:

N

Bom olha minha pagina layout.xhtml

<?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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="./css/default.css" rel="stylesheet" type="text/css" />
        <link href="./css/tableLayout.css" rel="stylesheet" type="text/css" />
        <title>SUI - Sistema �nico de Identificação</title>
    </head>

    <body>
        <table cellspacing="0" cellpadding="0" border="1" align="center" width="800">
            <tr>
                <td id="topo">
                    <ui:insert name="topo">
                        <h:graphicImage url="imagens/topo.png"/>
                    </ui:insert>
                </td>
            </tr>
            <tr>
                <td id="menu" height="30px">
                    <ui:insert name="menu"><f:subview id="menu">
                            <h:form id="menu">
                                <rich:toolBar width="800px" height="30px">
                                    <rich:menuItem value="HOME" icon="imagens/home.png" action="home" submitMode="ajax" immediate="true"/>
                                    <rich:menuItem value="CADASTRE-SE" icon="imagens/cadastre.png" action="#{EmpresaManagedBean.montarPaginaCadastroEmpresa}" submitMode="ajax" immediate="true" />
                                    <rich:menuItem value="LOGIN" icon="imagens/login.png" action="loginEmpresa" submitMode="ajax" immediate="true" />
                                    <rich:menuItem value="Ã?REA RESTRITA" icon="imagens/area.png" action="loginAdministrador" submitMode="ajax" immediate="true" />
                                    <rich:menuItem value="FALE CONOSCO" icon="imagens/fale.png"/>
                                </rich:toolBar>
                            </h:form>
                        </f:subview>
                    </ui:insert>
                </td>
            </tr>
            <tr>
                <td id="meio">
                    <ui:insert name="meio"></ui:insert>
                </td>
            </tr>
            <tr>
                <td id="rodape">
                    <ui:insert name="rodape"><f:subview id="rodape">
                            <h:graphicImage url="/imagens/rodape.png"/>
                        </f:subview>
                    </ui:insert>
                </td>
            </tr>
        </table>
    </body>

</html>

e uso ela para a pagina de home.xhtml

<?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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j">

    <head></head>
    <body>
        <ui:composition template="layout.xhtml">
            <ui:define name="meio">
            <table align="center" border="0" cellpadding="0" cellspacing="0">
            <f:view>
                <h:form id="formHome">
                    <tr>
                        <td style="background-image: url('/SUI_QRCODE/imagens/meiohome.png')" width="500">
                            <p align="center"><h:graphicImage url="/imagens/propaganda.png" /></p>
                        </td>
                    </tr>
                </h:form>
            </f:view>
            </table>
            </ui:define>
        </ui:composition>
    </body>
</html>
e a cadastroEmpresa.xhtml
<?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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:stella="http://stella.caelum.com.br/faces">

    <head>
        <script type="text/javascript" src="/resources/jquery.maskedinput-1.2.1.js"></script>

    </head>
    <body>
        <ui:composition template="/layout.xhtml">
            <ui:define name="meio">
                <table align="center" border="0" cellpadding="0" cellspacing="0">
                    <f:view>
                        <h:form id="formCadastroEmpresa">
                            <tr>
                                <td style="background-image: url('/SUI_QRCODE/imagens/meiohome.png')">
                                    <p align="center"><h:graphicImage url="SUI_QRCODE/imagens/sejausuario.png" /> </p>
                                    <table width="600" border="0" align="center">
                                        <tr>
                                            <td colspan="2"><p align="center"><h:message for="formCadastroEmpresa" style="color: red"/></p></td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <p align="right"><h:outputText value="Razão Social"/></p></td>
                                            <td><h:inputText id="razaoEmpresa" value="#{EmpresaManagedBean.empresa.razaoEmpresa}" maxlength="80" size="80"
                                                             required="true" requiredMessage="Este campo é obrigatório." style="text-transform:uppercase"/>
                                                <h:message for="razaoEmpresa" style="color: red" />
                                            </td>

                                        </tr>
                                        <tr>
                                            <td><p align="right"><h:outputText value="Nome Fantasia"/></p></td>
                                            <td><h:inputText id="nomeFantasiaEmpresa" value="#{EmpresaManagedBean.empresa.nomeFantasiaEmpresa}" maxlength="80" size="80"
                                                             style="text-transform:uppercase" required="true" requiredMessage="Este campo é obrigatório."/>
                                                <h:message for="nomeFantasiaEmpresa" style="color: red" />
                                            </td>

                                        </tr>
                                        <tr>
                                            <td><p align="right"><h:outputText value="CNPJ"/></p></td>
                                            <td><h:inputText id="cnpjEmpresa" value="#{EmpresaManagedBean.empresa.cnpjEmpresa}" maxlength="18" size="20" required="true"
                                                             requiredMessage="Este campo é obrigatório.">
                                                    <stella:validateCNPJ formatted="true"/>
                                                    <rich:jQuery selector="#cnpjEmpresa" query="mask('99.999.999/9999-99')" timing="onload"/>
                                                </h:inputText><br/>
                                                <h:message for="cnpjEmpresa" style="color: red" />
                                            </td>

                                        </tr>
                                        <tr>
                                            <td><p align="right"><h:outputText value="Ramo de Atividade"/></p></td>
                                            <td><h:inputText id="ramoAtividadeEmpresa" value="#{EmpresaManagedBean.empresa.ramoAtividadeEmpresa}" maxlength="70" size="60"
                                                             style="text-transform:uppercase"/>
                                            </td>

                                        </tr>
                                        <tr>
                                            <td><p align="right"><h:outputText value="Telefone"/></p></td>
                                            <td><h:inputText id="telefoneEmpresa" value="#{EmpresaManagedBean.empresa.telefoneEmpresa}" maxlength="13" size="20">
                                                    <rich:jQuery selector="#telefoneEmpresa" query="mask('([telefone removido]')" timing="onload"/>
                                                </h:inputText>
                                            </td>

                                        </tr>
                                        <tr>
                                            <td><p align="right"><h:outputText value="Fax"/></p></td>
                                            <td><h:inputText id="faxEmpresa" value="#{EmpresaManagedBean.empresa.faxEmpresa}" maxlength="13" size="20">
                                                    <rich:jQuery selector="#faxEmpresa" query="mask('([telefone removido]')" timing="onload"/>
                                                </h:inputText>
                                            </td>

                                        </tr>
                                        <tr>
                                            <td><p align="right"><h:outputText value="Celular"/></p></td>
                                            <td><h:inputText id="celularEmpresa" value="#{EmpresaManagedBean.empresa.celularEmpresa}" maxlength="13" size="20">
                                                    <rich:jQuery selector="#celularEmpresa" query="mask('([telefone removido]')" timing="onload"/>
                                                </h:inputText>
                                            </td>

                                        </tr>
                                        <tr>
                                            <td><p align="right"><h:outputText value="E-mail"/></p></td>
                                            <td><h:inputText id="emailEmpresa" value="#{EmpresaManagedBean.empresa.emailEmpresa}" maxlength="70" size="40" style="text-transform:lowercase" required="true"
                                                             requiredMessage="Este campo é obrigatório."/>
                                                <h:message for="emailEmpresa" style="color: red" />

                                            </td>

                                        </tr>
                                        <tr>
                                            <td><p align="right"><h:outputText value="Senha"/></p></td>
                                            <td><h:inputSecret  id="senha_empresa"  binding="#{EmpresaManagedBean.senhaInput}" value="#{EmpresaManagedBean.empresa.senhaEmpresa}" maxlength="10"  size="20" required="true"
                                                                requiredMessage="Este campo é obrigatório." validatorMessage="A senha deve ter no mínimo 6 caracteres.">
                                                    <f:validateLength minimum="6"/>
                                                </h:inputSecret><br/>
                                                <h:message for="senha_empresa" style="color: red" />
                                            </td>

                                        </tr>
                                        <tr>
                                            <td><p align="right"><h:outputText value="Confirmar Senha"/></p></td>
                                            <td><h:inputSecret id="confirmarSenhaEmpresa" validator="#{EmpresaManagedBean.validateSenha}"  value="#{EmpresaManagedBean.empresa.confimarSenhaEmpresa}" maxlength="10" size="20" required="true"
                                                               requiredMessage="Este campo é obrigatório." validatorMessage="A senha deve ter no mínimo 6 caracteres.">
                                                </h:inputSecret>
                                                <h:message for="confirmarSenhaEmpresa" style="color: red" />
                                            </td>

                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <p align="center"><h:panelGrid id="panel" columns="2" border="0">
                                                        <f:facet name="footer">
                                                            <h:panelGroup style="display:block; text-align:center">
                                                                <h:commandButton  id="cadastrar" action="#{EmpresaManagedBean.inserir}" image="/imagens/cadastrar.png"/>
                                                                <h:commandButton  id="voltar" action="home"   immediate="true" image="/imagens/voltar.png"/>
                                                            </h:panelGroup>
                                                        </f:facet>
                                                    </h:panelGrid>
                                                </p>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </h:form>
                    </f:view>
                </table>
            </ui:define>
        </ui:composition>
    </body>
</html>

foda que agora não funciona nada ate o jquery ele não reconhece ;/

N

puts o problema so acontece no firefox… tu sabe o porque?

Criado 30 de março de 2010
Ultima resposta 31 de mar. de 2010
Respostas 15
Participantes 2