[Resolvido] Alterar dados e Excluir naum funciona mais

Ola pessoal, estou com um problema por causa de uma migraçao que fiz de JSP para XHTML.

O problema é na ActionListener de Alterar e Excluir, que com o jsf funcionavam, agora naum funcionam mais…

os métodos

[code] public String excluir(ActionEvent event) {
System.out.println("Excluindo: " + perguntas.getCod_perguntas());
UIComponent link = event.getComponent();
UIParameter param = (UIParameter) link.findComponent(“excluir”);
Long id = (Long) param.getValue();

	Session session = HibernateUtil.currentSession();
	Dao<Perguntas> perguntasDao = new Dao<Perguntas>(session,
			Perguntas.class);
	this.perguntas = perguntasDao.load(id);
	perguntasDao.delete(this.perguntas);
	this.perguntas = new Perguntas();
	return "excluido";

}

public void escolhePerguntas(ActionEvent event) {
	UIComponent link = event.getComponent();
	UIParameter param = (UIParameter) link.findComponent("editCod");
	Long id = (Long) param.getValue();

	Session session = HibernateUtil.currentSession();
	Dao<Perguntas> dao = new Dao<Perguntas>(session, Perguntas.class);
	this.perguntas = dao.load(id);
}[/code]

O XHTML da pergunta:

[code]<?xml version="1.0" encoding="ISO-8859-1"?>

<ui:composition template="/pages/template/template.xhtml">
<ui:define name=“corpo”>

	<h:outputText value="Descrição:  " />
	
	<h:inputText value="#{perguntasHandler.perguntas.descricao}" required="true" validator="#{perguntasHandler.validaCase}">
		<f:validateLength minimum="5" />
	</h:inputText>
	
	<h:outputText value="Tipo:  " />
	
	<h:inputText value="#{perguntasHandler.perguntas.tipo}" required="true" validator="#{perguntasHandler.validaCase}">
		<f:validateLength minimum="2" />
	</h:inputText>
	
	
	<h:commandButton value="Salvar" action="#{perguntasHandler.salva}" />


<rich:spacer height="10"/>
<rich:separator height="1" lineType="dotted"/>
<rich:spacer height="10"/>

<ui:include src="listaperguntas.xhtml" />

</h:panelGrid>
</h:form>

</f:view>
[/code]

O XHTML da listapergunta que tem as chamadas alterar e excluir:

[code]<?xml version="1.0" encoding="ISO-8859-1"?>

	<h:column>
		<f:facet name="header">
			<h:outputText value="Alterar"/>
		</f:facet>
		
		<h:commandButton value="Alterar" actionListener="#{perguntasHandler.escolhePerguntas}">
			<f:param id="editCod" name="cod_perguntas" value="#{f.cod_perguntas}"/>
		</h:commandButton>
		
	</h:column>

	<h:column>
		<f:facet name="header">
			<h:outputText value="Excluir"/>
		</f:facet>
		<h:commandButton value="Excluir" actionListener="#{perguntasHandler.excluir}" />
		<f:param id="excluir" name="cod_perguntas" value="#{f.cod_perguntas}"/>
	</h:column>
	

	<f:facet name="footer">
		<rich:datascroller/>
	</f:facet>
	
	</rich:dataTable>


</h:form>

</f:subview>

[/code]

A diferença básica foi o include da listapergunta.xhtml na pergunta.xhtml:

era assim: <f:include page="listaperguntas.xhtml" /> ficou assim: <ui:include src="listaperguntas.xhtml" />

se eu deixar da primeira forma, me dá esse erro na hora de abrir a pagina:

An Error Occurred: /pages/questionario/perguntas.xhtml @41,43 <f:include> Tag Library supports namespace: http://java.sun.com/jsf/core, but no tag was defined for name: include

Eae galera, alguma sugestão??

Ah sim, e no console me aparece essa mensagem:

28/01/2010 12:33:03 com.sun.faces.lifecycle.RenderResponsePhase execute INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed. sourceId=j_id42:j_id47[severity=(ERROR 2), summary=(Campo Obrigatorio.), detail=(Campo Obrigatorio.)] sourceId=j_id42:j_id45[severity=(ERROR 2), summary=(Campo Obrigatorio.), detail=(Campo Obrigatorio.)]

A mensagem diz que não existe a tag include dentro da taglib que vc chamou de f: (java.sun.com/jsf/core)
a tag include se existir deve estar em outra taglib

[quote=Fierodd]A mensagem diz que não existe a tag include dentro da taglib que vc chamou de f: (java.sun.com/jsf/core)
a tag include se existir deve estar em outra taglib
[/quote]

O problema amigo, é que quando eu usava a pagina em JSP, naum usava o Facelets, essa tag funcionava perfeitamente…

E agora?

Quando vc usava jsp a taglib f: apontava para esse mesmo namespace (java.sun.com/jsf/core)?
Dá uma conferida ai pq na documentação não há essa tag include

Link da documentação das tags: http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/tlddocs/index.html

[quote=Fierodd]Quando vc usava jsp a taglib f: apontava para esse mesmo namespace (java.sun.com/jsf/core)?
Dá uma conferida ai pq na documentação não há essa tag include

Link da documentação das tags: http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/tlddocs/index.html[/quote]
Mano, na verdade estava jsp:include, olha como estam as taglibs na jsp:

&lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%&gt; &lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%&gt; &lt;%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %&gt; &lt;%@ taglib uri="http://richfaces.org/rich" prefix="rich" %&gt; //... &lt;jsp:include page="listaperguntas.jsp" /&gt;

Tive que mudar de jsp para xhtml para poder usar o Facelets, e ficou assim:

[code]<?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:a4j=“http://richfaces.org/a4j
xmlns:rich=“http://richfaces.org/rich”>

//só que aí o jsp:include não funciona…
<jsp:include page=“listaperguntas.xhtml” /> //unknown tag jsp:include

[/code]

Precipitaçao minha. Falei que era f:include e era jsp:include. Perdão amigo.

Mas continuo com o problema. O q devo fazer?? Se eu usar:

	&lt;ui:include src="listaperguntas.xhtml" /&gt;

Não funciona… :frowning:

Resolvido pessoal!!! O problema é q eu tinha um objeto required=“true” e ficava dando erro quando eu ia alterar ou excluir o objeto.

Flws.