Pessoal boa noite, estou pesquinsado sobre o assunto portanto desculpe se falar alguma bobagem aqui eu tenho o seguinte cenário:
ex:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="rich" uri="http://richfaces.ajax4jsf.org/rich"%>
<%@ taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Cadastro De Estados</title>
</head>
<body>
<f:view>
<jsp:include page="/menu.jsp"></jsp:include>
<h:form>
<center>
<h:panelGrid columns="1">
<h:messages />
</h:panelGrid>
<h:panelGrid columns="2">
<h:outputText value="Estado: " />
<h:inputText value="#{estadoBacking.nomeEstado}" size="20" maxlength="45" />
<h:outputText value="Sigla: " />
<h:inputText value="#{estadoBacking.siglaEstado}" size="20" maxlength="2" />
</h:panelGrid>
<h:panelGrid columns="2">
<h:commandButton value="Salvar" action="#{estadoBacking.incluir}" />
<h:commandButton value="Cancelar" action="#{estadoBacking.novo}" />
</h:panelGrid>
</h:form>
</center>
</f:view>
</body>
</html>
Porem queria dividir isto criando minha TAG, utilizo JSF 1.2, ficaria algo assim…
Criaria minha TAG como algo a baixo
<minhaTagTeste>
<h:panelGrid columns="1">
<h:messages />
</h:panelGrid>
<h:panelGrid columns="2">
<h:outputText value="Estado: " />
<h:inputText value="#{estadoBacking.nomeEstado}" size="20" maxlength="45" />
<h:outputText value="Sigla: " />
<h:inputText value="#{estadoBacking.siglaEstado}" size="20" maxlength="2" />
</h:panelGrid>
<h:panelGrid columns="2">
<h:commandButton value="Salvar" action="#{estadoBacking.incluir}" />
<h:commandButton value="Cancelar" action="#{estadoBacking.novo}" />
</h:panelGrid>
</minhaTagTeste>
ai depois na jsp eu coloco os imports de acordo com o que a minha tag utiliza e ficaria um codigo assim
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="rich" uri="http://richfaces.ajax4jsf.org/rich"%>
<%@ taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Cadastro De Estados</title>
</head>
<body>
<f:view>
<jsp:include page="/menu.jsp"></jsp:include>
<h:form>
<minhaTagTeste>
</h:form>
</f:view>
</body>
</html>
Ai na JSP, algo que seria somente o necessário para colocar a minhaTagTeste, eu fazia minha TAG e em qualquer lugar do sistema que precise dele exemplo em em modal eu só colocaria minha TAG.
Pessoal muito Obrigado…!!!