[Logo] Neo Framework Forum
  [Search] Busca   [Recent Topics] Tópicos Recentes   [Members]  Lista de Usuários   [Groups] De volta para a página principal 
[Register] Registrar / 
[Login] Entrar 
Modificar Tag Template  XML
Índice dos Fóruns -> Dúvidas
Autor Mensagem
vberga
Equipe

Membro desde: 30/01/2009 15:47:23
Mensagens: 26
Offline

Pessoal, estou querendo modificar uma tag do neo para dar continuidade a ideia de um post aqui no forum sobre modificar uma tag para exibir/esconder os campos do filtro da listagem.

O que eu preciso: mostrar ou não um Comando(Botão/link) do lado de onde fica o link Criar na tag de listagem

a minha ideia é criar uma propriedade na tag HTML. e o seu uso seria assim:
Code:
 <t:listagem showSearchLink="true">
 <t:listagem showSearchLink="false">
 


Editei os seguintes artefatos:

ListagemTag.java
Code:
 public class ListagemTag extends TemplateTag {
 	
 	protected String titulo;
 	protected boolean showNewLink = true;
 	protected JspFragment linkArea;
 	protected boolean showSearchLink = true;
 
 	public boolean isShowSearchLink() {
 		return showSearchLink;
 	}
 
 
 	public void setShowSearchLink(boolean showSearchLink) {
 		this.showSearchLink = showSearchLink;
 	}
 
 
 	public JspFragment getLinkArea() {
 		return linkArea;
 	}
 
 
 	public void setLinkArea(JspFragment linkArea) {
 		this.linkArea = linkArea;
 	}
 
 
 	public boolean isShowNewLink() {
 		return showNewLink;
 	}
 
 
 	public void setShowNewLink(boolean showNewLink) {
 		this.showNewLink = showNewLink;
 	}
 
 
 	public String getTitulo() {
 		return titulo;
 	}
 
 
 	public void setTitulo(String titulo) {
 		this.titulo = titulo;
 	}
 
 	/**
 	 * método para ser chamado do template
 	 * @return
 	 */
 	public String getInvokeLinkArea(){
 		CharArrayWriter charArrayWriter = new CharArrayWriter();
 		try {
 			if (linkArea != null) {
 				linkArea.invoke(charArrayWriter);
 			}
 		} catch (Exception e) {
 			throw new NeoException(e);
 		}
 		return charArrayWriter.toString();
 	}
 
 	@Override
 	protected void doComponent() throws Exception {
 		if(Util.strings.isEmpty(titulo)){
 			titulo = (String) getPageContext().findAttribute("TEMPLATE_beanDisplayName");
 		}
 		pushAttribute("listagemTag", this);
 		includeJspTemplate();
 		popAttribute("listagemTag");
 	}
 
 }
 


ListagemTag.jsp
Code:
  <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  <%@ taglib prefix="n" uri="neo"%>
  <%@ taglib prefix="combo" uri="combo"%>
  <%@ taglib prefix="t" uri="template"%>
  <script>
  	function verFiltro(){
  		if (document.getElementById('filtro')){
  			if (document.getElementById('filtro').style.display == ''){
  				document.getElementById('filtro').style.display = 'none';
  			}else document.getElementById('filtro').style.display = '';
  		}
  	}
  </script>
  <n:form validate="false">
  	<n:validation>
  		<input type="hidden" name="notFirstTime" value="true"/>
  		<table class="outterTable" cellspacing="0" cellpadding="0" align="center">
  			<tr style="background: url('${pageContext.request.contextPath}/resource/img/titulo.gif')" class="outterTableHeader">
  				<td>
  					<span class="outterTableHeaderLeft">
  						${listagemTag.titulo}						
  					</span>
  					<span class="outterTableHeaderRight">
  						<c:if test="${listagemTag.showNewLink || !empty listagemTag.linkArea}">
  							${listagemTag.invokeLinkArea}
  							<c:if test="${listagemTag.showNewLink}">						
  								<!--
  									<n:link action="criar" class="outterTableHeaderLink">Criar</n:link>
  								-->
  								<button onclick="window.location.href='?ACAO=criar'">Novo</button>
  							</c:if>						
  							<c:if test="${listagemTag.showSearchLink}">						
  								<button onclick="verFiltro()">Pesquisar</button>
  							</c:if>						
  						</c:if>					
  					</span>
  				</td>
  			</tr>
  			<tr>
  				<td>
  					<n:doBody />
  				</td>
  			</tr>
  		</table>
  	</n:validation>
  </n:form>
 


Isso funciona em parte, porque o botão já é exibido na jsp (Porque o default é true) mas quando utilizo
Code:
 <t:listagem showSearchLink="false">
 

não funciona.

Como faço pra jsp reconhecer o novo atributo que setei na tag?

Vinícios Bergamaschi
rodrigo.freitas
Equipe
[Avatar]
Membro desde: 17/04/2007 16:43:33
Mensagens: 36
Localização: Belo Horizonte - MG
Offline

Vinícius,

você tem que registrar esse atributo na tld da taglib....

acha o arquivo template.tld

modifica essa parte aqui assim....
Code:
 <tag>
 		<description></description>
 		<name>listagem</name>
 		<tag-class>br.com.linkcom.neo.view.template.ListagemTag</tag-class>
 		<body-content>scriptless</body-content>
 		<attribute>
 			<description></description>
 			<name>titulo</name>
 			<required>false</required>
 			<rtexprvalue>true</rtexprvalue>
 		</attribute>
 		<attribute>
 			<description></description>
 			<name>showNewLink</name>
 			<required>false</required>
 			<rtexprvalue>true</rtexprvalue>
 		</attribute>
 		<attribute>
 			<description></description>
 			<name>showSearchLink</name>
 			<required>false</required>
 			<rtexprvalue>true</rtexprvalue>
 		</attribute>		
 		<attribute>
 			<description></description>
 			<name>linkArea</name>
 			<required>false</required>
 			<fragment>true</fragment>
 		</attribute>			
 		<dynamic-attributes>true</dynamic-attributes>			
 	</tag>
 
 


é só adicionar o seu atributo nesta parte onde eu adicionei acima...

tenta ai e ve se da certo....

abrassss

Rodrigo Duarte de Freitas
Desenvolvedor de Sistemas
LinkCom - Soluçoes em T.I
Belo Horizonte - MG
rodrigo.freitas@linkcom.com.br - www.linkcom.com.br
Telefone/Fax: (31) 3241-3586
[Email] [MSN]
 
Índice dos Fóruns -> Dúvidas
Ir para:   
Powered by JForum 2.1.7 © JForum Team