formRemote não atualiza
30/01/2013 13:16
<g:formRemote name="myForm2" update="updateMe" method="GET"
action="${createLink(controller: 'documento', action: 'reduzTexto')}"
url="[controller: 'documento', action: 'reduzTexto']">
<input name="id" type="hidden" value="${doc.texto}" />
</g:formRemote>
<div id="updateMe"> ${params.id} </div>
def reduzTexto = {
String texto = params.id
String busca = params.q
busca = busca.toLowerCase()
def tamanhoBusca = busca.length()
def localIndice = texto.toLowerCase().indexOf(busca)
int Indiceaux = 0
int letrasDepois = 0
if (localIndice > 50){
Indiceaux = localIndice - 50
}else
if (localIndice > 20){
Indiceaux = localIndice - 20
}
else
Indiceaux = 0
if ((texto.length() - localIndice)>300)
letrasDepois = 300
else
letrasDepois = texto.lenght()
String resultado = texto.substring(Indiceaux,(localIndice+tamanhoBusca+letrasDepois))
Indiceaux = resultado.indexOf(" ")
resultado = resultado.substring(Indiceaux,resultado.length())
params.id = resultado.replaceAll("(?i)"+busca, "<b>"+busca+"</b>")
}
<div id="updateMe"> ${params.id} </div>
params.id = resultado.replaceAll("(?i)"+busca, "<b>"+busca+"</b>")
render resultado.replaceAll("(?i)"+busca, "<b>"+busca+"</b>")
<input type="submit" style="display:none"/>
<g:formRemote name="myForm2" update="updateMe" method="GET"
action="${createLink(controller: 'documento', action: 'reduzTexto')}"
url="[controller: 'documento', action: 'reduzTexto']">
<input name="s" type="hidden" value="${doc.texto}" />
<input type="submit" style="display:none"/>
</g:formRemote>
<div id="updateMe"> </div>
def reduzTexto = {
print "olá grails"
String texto = params.s
String busca = params.q
busca = busca.toLowerCase()
def tamanhoBusca = busca.length()
def localIndice = texto.toLowerCase().indexOf(busca)
int Indiceaux = 0
int letrasDepois = 0
if (localIndice > 50){
Indiceaux = localIndice - 50
}else
if (localIndice > 20){
Indiceaux = localIndice - 20
}
else
Indiceaux = 0
if ((texto.length() - localIndice)>300)
letrasDepois = 300
else
letrasDepois = texto.lenght()
String resultado = texto.substring(Indiceaux,(localIndice+tamanhoBusca+letrasDepois))
Indiceaux = resultado.indexOf(" ")
resultado = resultado.substring(Indiceaux,resultado.length())
render resultado.replaceAll("(?i)"+busca, "<b>"+busca+"</b>")
}
<g:javascript library="jquery/jquery"/>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Busca</title>
<style type="text/css">
* {
font-family: Arial, sans-serif;
padding: 0;
margin: 0;
}
body {
font-size: 0.9em;
padding: .5em;
}
#header form input {
padding: .1em;
}
#header .hint {
color: gray;
}
#header h1 a {
text-decoration: none;
font-family: Georgia, serif;
color: dimgray;
}
#header h1 {
letter-spacing: -0.1em;
float: left;
}
#header h1 span {
font-family: Georgia, serif;
color: #424242;
}
#header form {
margin-left: 22em;
padding-top: .1em;
}
.title {
margin: 1em 0;
padding: .3em .5em;
text-align: right;
background-color: seashell;
border-top: 1px solid lightblue;
}
.result {
margin-bottom: 1em;
}
.result .displayLink {
color: green;
}
.result .name {
font-size: larger;
}
.paging a.step {
padding: 0 .3em;
}
.paging span.currentStep {
font-weight: bold;
}
ul {
margin: 1em 2em;
}
li, p {
margin-bottom: 1em;
}
</style>
<script type="text/javascript">
var focusQueryInput = function() {
document.getElementById("q").focus();
}
</script>
</head>
<body onload="focusQueryInput();">
<div id="header">
<h1><a href="/Gerdoc/" target="_blank">Busca documentos</a></h1>
<g:formRemote name="myForm" update="up" method="GET"
action="${createLink(controller: 'documento', action: 'busca')}"
url="[controller: 'documento', action: 'busca']">
<input type="text" name="q" value="" size="50" id="q" />
<input type="submit" value="Busca" />
<input type="hidden" name="textoAux" value=${buscaDoc()}>
</g:formRemote>
<div style="clear: both; display: none;" class="hint"> See <a href="/Gerdoc/">Lucene query syntax</a> for advanced queries</div>
</div>
<div id="main">
<g:set var="qtd" value="${0}" />
<div class="title">
<span>
Exibindo <strong>1</strong> - <strong>${qtd}</strong> de <strong>${qtd}</strong>
resultados para <strong>${params.q}</strong>
</span>
</div>
<div class="results">
<div class="result">
<g:each var="doc" in="${buscaDoc()}">
<div class="name">
<g:link controller="documento" action="show" id="${doc.id}"> ${doc.tipo}</g:link>
</div>
<div class="displayLink">${doc.path}
<g:link controller="documento" action="readFromFile" params="[p:doc.path]"
target="_blank">Arquivo</g:link>
</div>
//parte que não funciona
<g:formRemote name="myForm2" update="updateMe" method="GET"
action="${createLink(controller: 'documento', action: 'reduzTexto')}"
url="[controller: 'documento', action: 'reduzTexto']">
<input name="s" type="hidden" value="${doc.texto}" />
<input type="submit" style="display:none"/>
</g:formRemote>
<div id="updateMe"> </div>
<g:set var="qtd" value="${qtd + 1}"/>
</g:each>
<g:if test="${(qtd < 1) && (params.q)}">
A sua pesquisa - <b> ${params.q} </b> - não encontrou nenhum documento.
<br>
<br>
Sugestões: <br>
<g:each var="sug" in="${searchLucene()}">
<g:link controller="documento" action="busca" params="[q:sug]" >${sug} </g:link> <br>
</g:each>
</g:if>
</div>
</div>
<div>
<div class="paging">
Page:
<span class="currentStep">1</span>
</div>
</div>
</div>
</body>
</html>
<g:javascript library="prototype" />
<g:javascript library="prototype" />
<g:javascript library='jquery' />
<g:javascript library="prototype" />
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Busca</title>
<script type="text/javascript" src="/Gerdoc/js/jquery/jquery-1.7.1.js"></script>
<style type="text/css">
* {
font-family: Arial, sans-serif;
padding: 0;
margin: 0;
}
body {
font-size: 0.9em;
padding: .5em;
}
#header form input {
padding: .1em;
}
#header .hint {
color: gray;
}
#header h1 a {
text-decoration: none;
font-family: Georgia, serif;
color: dimgray;
}
#header h1 {
letter-spacing: -0.1em;
float: left;
}
#header h1 span {
font-family: Georgia, serif;
color: #424242;
}
#header form {
margin-left: 22em;
padding-top: .1em;
}
.title {
margin: 1em 0;
padding: .3em .5em;
text-align: right;
background-color: seashell;
border-top: 1px solid lightblue;
}
.result {
margin-bottom: 1em;
}
.result .displayLink {
color: green;
}
.result .name {
font-size: larger;
}
.paging a.step {
padding: 0 .3em;
}
.paging span.currentStep {
font-weight: bold;
}
ul {
margin: 1em 2em;
}
li, p {
margin-bottom: 1em;
}
</style>
<script type="text/javascript">
var focusQueryInput = function() {
document.getElementById("q").focus();
}
</script>
</head>
<body onload="focusQueryInput();">
<div id="header">
<h1><a href="/Gerdoc/" target="_blank">Busca documentos</a></h1>
<form onsubmit="jQuery.ajax({type:'GET',data:jQuery(this).serialize(), url:'/Gerdoc/documento/busca',success:function(data,textStatus){jQuery('#up').html(data);},error:function(XMLHttpRequest,textStatus,errorThrown){}});return false" method="POST" action="/Gerdoc/documento/busca" name="myForm" id="myForm">
<input type="text" name="q" value="" size="50" id="q" />
<input type="submit" value="Busca" />
<input type="hidden" name="textoAux" value=[gerdoc.Documento : 3316]>
</form>
<div style="clear: both; display: none;" class="hint"> See <a href="/Gerdoc/">Lucene query syntax</a> for advanced queries</div>
</div>
<div id="main">
<div class="title">
<span>
Exibindo <strong>1</strong> - <strong>0</strong> de <strong>0</strong>
resultados para <strong>fabiana</strong>
</span>
</div>
<div class="results">
<div class="result">
<div class="name">
<a href="/Gerdoc/documento/show/3316"> PROTESTO</a>
</div>
<div class="displayLink">documentos/PROTESTO/AP/AP017/AP017 - 085
<a href="/Gerdoc/documento/readFromFile?p=documentos%2FPROTESTO%2FAP%2FAP017%2FAP017+-+085" target="_blank">Arquivo</a>
</div>
<form onsubmit="jQuery.ajax({type:'GET',data:jQuery(this).serialize(), url:'/Gerdoc/documento/reduzTexto',success:function(data,textStatus){jQuery('#updateMe').html(data);},error:function(XMLHttpRequest,textStatus,errorThrown){}});return false" method="POST" action="/Gerdoc/documento/reduzTexto" name="myForm2" id="myForm2">
<input name="s" type="hidden" value="TEXTO GIGANTE DO DOCUMENTO" />
<input type="submit" style="display:none"/>
</form>
<div id="updateMe"> </div>
</div>
</div>
<div>
<div class="paging">
Page:
<span class="currentStep">1</span>
</div>
</div>
</div>
</body>
</html>
<input name="id" type="hidden" value="${doc.texto}" />
<input type="hidden" name="textoAux" value=[gerdoc.Documento : 3316]>
<input name="id" type="hidden" value="${doc.texto}" />
<input type="hidden" name="textoAux" value=${buscaDoc()}>
Para se registrar, clique aqui.