Boa noite a todos, estou utilizando extjs +dwr …em um aplicativo simples, mas não estou conseguindo chamar o método de uma classe, o que estou usando então como já disse, para a parte visual extjs e dwr mais nada,
Aqui está o meu index.jsp , junto com o extjs , e na função gravaTxt é onde eu chamo a classe do java que está mapeada no dwr…
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>Teste Extjs</title>
<link rel="stylesheet" type="text/css" href="/PrototipoDwr/ext-3.2.0/resources/css/ext-all.css" />
<script src="/PrototipoDwr/ext-3.2.0/adapter/ext/ext-base.js"></script>
<script src="/PrototipoDwr/ext-3.2.0/ext-all.js"></script>
<script>
Ext.onReady(function(){
var MeuForm=new Ext.form.FormPanel({
renderTo:document.body,
title:"Editor Web",
//anchor:'100%',
labelWidth:100,
labelAlign:"left",
layout:"form",
padding:10,
border:false,
frame: true,
width:'100%',
height:'100%',
items:[
{
xtype: 'htmleditor',
id:'editorTxt',
//name: 'editorTxt',
// fieldLabel:'Biography',
width: 770,
height:500,
anchor:'97%'
} ,{
layout: 'column',
width: '100%',
border: false,
labelWidth: 10,
items: [{
layout: 'form',
width: '50%',
labelWidth: 10,
items: [{
xtype: 'button',
id : 'salvarTexto',
text: 'Salvar Texto',
minWidth : 150,
listeners:{
click:function(){
gravaTxt();
}
}
}]
},{
layout: 'form',
width: '50%',
labelWidth: 10,
items: [{
xtype: 'button',
id : 'limpar',
text: 'Limpar Texto',
minWidth : 150,
listeners:{
click:function(){
TestAjax();
}
}
}]
}]
}
]
});
var tryToDownload = function (url) {
var oIFrm = document.getElementById("IFrameDownload");
oIFrm.src = url;
} ;
var gravaTxt = function(){
var txt = Ext.getCmp('editorTxt').getValue();
if (txt == '') {
Ext.Msg.alert('Atenção', 'Não há texto para ser salvo');
} else {
EditorAction.download(txt);
}
};
});
</script>
</head>
<body>
<iframe
id="IFrameDownload" src="" style="visibility:hidden">
</iframe>
</body>
</html>
A classe java
package action;
import java.io.IOException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteMethod;
import org.directwebremoting.annotations.RemoteProxy;
@RemoteProxy
@DataTransferObject
public class EditorAction {
/**
*
*/
private static final long serialVersionUID = 1L;
@RemoteMethod
public static void download(String content )
throws IOException {
String nomeArquivo = "Texto";
HttpServletResponse response = null;
response.setHeader("Content-Disposition", "attachment; filename=" + nomeArquivo + ".doc");
response.setContentType( "application/download" );
ServletOutputStream outStream = response.getOutputStream();
try {
outStream.print( content );
outStream.flush();
} finally {
outStream.close();
}
}
/*
@SuppressWarnings("null")
public String downloadTxt(String txt) {
String nomeArquivo = "Texto";
HttpServletResponse response = null;
response.setHeader("Content-Disposition", "attachment; filename=" + nomeArquivo + ".doc");
ServletOutputStream outStream = response.getOutputStream();
try {
outStream.print( txt );
outStream.flush();
} finally {
outStream.close();
}
} */
}
e o web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<dwr>
<allow>
<convert converter="bean" match="action.EditorAction"/>
<create creator="new" javascript="EditorAction" class="action.EditorAction">
<include method="download"/>
</create>
</allow>
</dwr>
Como uso anotações na classe java não possuo um dwr.xml, aparentemente acho que ta tudo certo, mas ao rodar o aplicativo o firebug apresenta o erro de “EditorAction is not defined” , bom alguem sabe se tem algo faltando ou qual é o erro ? Bom agradeceria qualquer ajuda…