Limpar campos input depois da pesquisa

2 respostas
L

Boa noite galera…

tenho um jsp onde faço uma pesquisa e nela mesmo retorn uma lista… isso funciona, porém quero que quando eu clicar no botao pesquisar ao me retornar a lista das coisas quero que os inputs da tela limpe… olhem meu jsp:

<h1><img src="image/user.png" alt="" />Relatórios</h1>
    </div>
    <div class="content">
        <form name="form1" action="Relatorios.do?action=list&amp;filter=S" method="post" id="form">
			<table style="width: 100%;">
			  <tr>
				<td style="text-align: center;"><b>Tipo de Relatório:</b>
				  <select name="filter#IDTBORIGEM#Integer" id="filter#IDTBORIGEM#Integer" value="<c:out value="${filter_IDTBORIGEM_Integer}"/>" style="width: 170px; margin-top: 4px">
				  			<option value="">Selecionar</option>
				  			<option value="1">Contas a Receber</option>
							<option value="2">Contas a Pagar</option>
						</select>
					<br />
				  <br />
				  <b>Cliente/Fornecedor:</b>
					<input type="text" name="filter#NOME#String" id="filter#NOME#String" value="<c:out value="${filter_NOME_String}"/>" style="width:170px;"/>
				  <br />
				  <br/>
				  <b>Data Inicial:</b>
				  	<input type="text" style="width:72px;" name="filter#DATAINICIAL#String" id="filter#DATAINICIAL#String" value="<c:out value="${filter_DATAINICIAL_String}"/>" />
				  <b>Data Final:</b>
					<input type="text" style="width:72px;" name="filter#DATAFINAL#String" id="filter#DATAFINAL#String" value="<c:out value="${filter_DATAFINAL_String}"/>" />				  
				  
			  </tr>
			  <tr>
			  <td style="text-align: center">                   
				<a onclick="javascritp:document.form1.submit();" class="button" >Filtrar</a>
			</td></tr>
			</table>
		</form>
<c:if test="${relatorioList eq 'relatorioList'}" >	
    <div class="content">
        <table class="list">
          <thead>
            <tr>
              <td align="left">Cliente</td>
              <td align="left">Parcela</td>
              <td align="left">Qtd. Parcelas</td>
              <td align="left">Vencimento</td>
              <td align="left">Valor</td>
            </tr>
          </thead>
          <tbody>
            <c:forEach var="RelatorioContasPagar" items="${sessionScope.RelatorioContasPagar_list}">
            <tr>
              <td align="left"><c:out value="${RelatorioContasPagar.NOME}" /> </td>
              <td align="left"><c:out value="${RelatorioContasPagar.PARCELA}" /> </td>
              <td align="left"><c:out value="${RelatorioContasPagar.QTDPARCELAS}" /> </td>
              <td align="left"><c:out value="${RelatorioContasPagar.VENCIMENTO}" /> </td>
              <td align="left"><c:out value="${RelatorioContasPagar.VALOR}" /> </td>
            </tr>
            </c:forEach>
          </tbody>
        </table>
      <div class="pagination">
      	<div class="links">
        	   <a href="RelatorioContasPagar.do?action=list&amp;page=1&amp;filter=S">Primeira</a>
            <a href="RelatorioContasPagar.do?action=list&amp;page=${currentPage - 1}&amp;filter=S">Anterior</a>
            <b><c:out value="${currentPage}" /></b>
            <a href="RelatorioContasPagar.do?action=list&amp;page=${currentPage + 1}&amp;filter=S">Pr&oacute;xima</a>
            <a href="RelatorioContasPagar.do?action=list&amp;page=${noOfPages}&amp;filter=S">&Uacute;ltima</a>
        </div>
        <div class="results">Exibindo p&aacute;gina <strong><c:out value="${currentPage}" /></strong> do total de <strong> <c:out value="${noOfPages}" /></strong> P&aacute;gina(s)</div>
      </div>

    </div>		
</c:if>

Alguma dica…?

2 Respostas

L

Tente setar vazio nas variáveis que representa seus input da JSP em sua Action.

Ex: a variável na sua action que representa o atributo name="filter#NOME#String" seta vazio nele String nome = ""; após obter o retorno da sua lista.

L

Lucas.. ainda não consegui fazer.. olha como esta a minha classe:

public class Relatorios implements ActionCommand {

	public static Logger logger = Logger.getLogger(Relatorios.class);

	private static String LIST_USER = "/index.jsp?Page=Relatorios.jsp";

 	public void execute(HttpServletRequest request,
			HttpServletResponse response, RequestContext context)
			throws ServletException, IOException {

		HttpSession session = request.getSession();
		String action     = request.getParameter("action");
		String forward    = "";
		String msgSuccess = "";
		String msgError   = "";
		String Where      = " 1 = 1";

		int page = 1;
		if (request.getParameter("page") != null)
			page = Integer.parseInt(request.getParameter("page"));
		int iOffset = (page - 1) * DB.Limit;
		int qtdOfRecords = 0;

		if (action == null) {
			action = "list";
		}

		try {
			forward = LIST_USER;
			Fin_DebitoDAO dao = new Fin_DebitoDAO();

			if (action.equalsIgnoreCase("list")) {
				forward = LIST_USER;

				Enumeration<String> en = request.getParameterNames();
			    while (en.hasMoreElements()) {

			    	 String param = (String) en.nextElement();
			    	 String[] paramProperties = param.split("#");
			    	 String paramValue = "";

			    	 if ( param.indexOf( "filter#" ) > -1 ) {

			    		 paramValue   = (String) request.getParameter(param.toString());
			    		 session.setAttribute(param.replace("#", "_"),request.getParameter(param));

			    		 if (paramValue.length() > 0 ){
			    			 if (paramProperties[2].equalsIgnoreCase("Integer") == true) {
				    			 Where = Where + " AND " + paramProperties[1].toString() + " = " + paramValue;
				    			 
				    		 } else if (paramProperties[2].equalsIgnoreCase("Date") == true) {
				    			 Where = Where + " AND " + paramProperties[1].toString() + " >= '" + paramValue +"'";
				    			 Where = Where + " AND " + paramProperties[1].toString() + " <= '" + paramValue +"'";
				    		 } else {
				    			 Where = Where + " AND UPPER(" + paramProperties[1].toString() + ") LIKE UPPER('%" + paramValue + "%')";
				    		 }
			    		 }
			    	 }
			    	 
			    }

				session.setAttribute("RelatorioContasPagar_list", dao.Fin_Debito_List(Where, "nome", iOffset));
				session.setAttribute("relatorioList", "relatorioList");

			}  

			/***********************************************
			 * PAGINACAO
			 ***********************************************/
			qtdOfRecords = dao.getNoOfRecords();
			int noOfPages = (int) Math.ceil(qtdOfRecords * 1.0 / DB.Limit);
			session.setAttribute("noOfPages", noOfPages);
			session.setAttribute("currentPage", page);
			session.setAttribute("msgSuccess", msgSuccess);
			session.setAttribute("msgError", msgError);

			context.setNextPage(forward);

		} catch (Exception e) {
			session.setAttribute("msgError", "Nao foi possivel efetuar " + action + " do registro!" + e.getMessage());
			logger.error(e.getMessage(), e);
		}

	}

}
Criado 23 de maio de 2013
Ultima resposta 24 de mai. de 2013
Respostas 2
Participantes 2