<p: layout /> quando uso, dados no bean ficam nulos

6 respostas
W

preciso criar um layout em jsf para um trabalho de faculdade, resolvi usar o <p: layout />…
até aí tudo bem, o problema é q tenho inputtext neles, com um botão, mas os dados sao recebidos nulos…
quando tiro o componente, funciona normalmente…

alguem ja passou por isso ?

<h:body>
        <f:view>
            <h:form>
                <ui:composition id="uiTemplate" template="template.xhtml">
                    <ui:define id="uiDefineTemplateTopo" name="menu">

                        <h:panelGrid style="margin-top: -12%; margin-left: 15%; position: fixed" >
                            <h:panelGrid>
                                <h:panelGrid columns="2">
                                    <h:outputLabel  value="Nome: "/>
                                    <p:inputText value="#{usuarioBean.usuario.nome}" />

                                    <h:outputLabel  value="Cidade: "/>
                                    <p:inputText value="#{usuarioBean.usuario.cidade}" />

                                    <h:outputLabel  value="Idade: "/>
                                    <p:inputText value="#{usuarioBean.usuario.idade}" />

                                </h:panelGrid>
                                <p:commandButton value="cadastrar" actionListener="#{usuarioBean.cadastrarUsuario}" />
                            </h:panelGrid>
                        </h:panelGrid>

                    </ui:define>
                </ui:composition>
            </h:form>
        </f:view>
    </h:body>

6 Respostas

leonardobhbr

Amigo o atributo usuario dentro de usuarioBean está instanciado?

W

sim, ele esta instanciado, só fiz esse arquivo para testar,
o problema realmente é com o <p:layout />…

o bean nao pega o valor dos componentes que eestao dentro dele :?

Hebert_Coelho

Seu arquivo template na raiz do WebContent?

No meu projeto eu fiz assim:

<ui:composition template="/templates/templatePrincipal.xhtml">
W

então, eu deixo ele na raiz, nem cheguei a criar uma pasta para ele…

tem coomo postar o seu código ? eu só adicionei o template, e os beans param de funcionar…

Hebert_Coelho
Meu template:
<!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:p="http://primefaces.prime.com.tr/ui"
	xmlns:f="http://java.sun.com/jsf/core">
<h:head>
	<link rel="stylesheet" type="text/css" href="${request.contextPath}/resources/css/skin.css" />
	<title><ui:insert name="pageTitle">#{msgs.projeto}</ui:insert>
	</title>
</h:head>
<h:body bgcolor="#ffffff">
	<f:view contentType="text/html">
		<table style="border: 0px solid #CAD6E0" align="center" cellpadding="0" cellspacing="0" border="0" width="100%">
			<tbody>
				<tr>
					<td class="header" height="49" align="left" valign="middle" width="100%" bgcolor="#354757"><ui:insert name="pageHeader" /> 
						Header
					</td>
				</tr>
				<tr>
					<td height="1" width="100%" bgcolor="#CAD6E0"></td>
				</tr>
				<tr>
					<td width="100%" colspan="2">
						<table width="100%"  align="left" cellpadding="0" cellspacing="0" border="0">
							<tbody>
								
								<tr>
									<td align="center" width="100%" valign="middle"><ui:insert name="body">Page Body</ui:insert></td>
								</tr>
							</tbody>
						</table></td>
				</tr>
				<tr>
					<td colspan="2" valign="bottom" height="1" width="100%" id="footer" bgcolor="#ffffff">Fundo</td>
				</tr>
			</tbody>
		</table>
	</f:view>
</h:body>
</html>
<!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:p="http://primefaces.prime.com.tr/ui" 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:ez="http://java.sun.com/jsf/composite/demo">
<ui:composition template="/templates/templatePrincipal.xhtml">
	<ui:define name="body">
		Seu código aqui.
	</ui:define>
</ui:composition>
</html>
W

ja fiz template desse modo, é exatamente oque eu fiz em um projeto anterior, mas agora resolvi usar o primefaces,
reparei que vc nao esta usando a tag <p:Layout />

http://www.primefaces.org/showcase/ui/layoutFull.jsf

esta do link, quando eu coloko qualker coisa dentro dela, na funciona mais x.x

Criado 21 de novembro de 2011
Ultima resposta 21 de nov. de 2011
Respostas 6
Participantes 3