aspose file tools*
The moose likes Struts and the fly likes Struts and AjaxTags autocompleter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts and AjaxTags autocompleter" Watch "Struts and AjaxTags autocompleter" New topic
Author

Struts and AjaxTags autocompleter

Claudio Rossi
Greenhorn

Joined: Sep 13, 2010
Posts: 2
Hi at all

i'm new of this forum and i hope to find an aswer to my question. I don't know if i post in the right board. I posted here because my application is developed with Struts

I implement ajaxtag in my web application.

I used a Servlet that was ask from the jsp.

this Servlet do an DB query using Hibernate but when i do criteria.list() for have the response to my DB the system says that "connection does not exist"

I have no idea why the system says that.

this is the code of my web.xml
<servlet>
<servlet-name>autocomplete</servlet-name>
<servlet-class>it.cabro.ajax.AutoComplete</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>autocomplete</servlet-name>
<url-pattern>/autocomplete.view</url-pattern>
</servlet-mapping>


and there is the code of my autocomplete.java:

String funzione = Util.filtraNull(request.getParameter("funzione"));

AjaxXmlBuilder axb = new AjaxXmlBuilder();
UserContainer userContainer = (UserContainer) request.getSession().getAttribute("userContainer");
Session session = null;
try
{

DataBaseAS400 dbAS400 = null;
try
{
dbAS400 = new DataBaseAS400(userContainer);
}
catch(Exception e)
{
log.error("", e);
}
try
{
// session = HibernateUtil.getFirstSessionAS400(userContainer);
session = HibernateUtil.currentSessionAS400(userContainer);
}
catch(Exception e)
{
axb.addItem(Util.escapeSpecialChar(e.getMessage()), "");
return axb.toString();
}

if(funzione.equals("codiceCliente"))
{
String ricerca = Util.filtraNull(request.getParameter("descrizioneFornitore").toUpperCase());
if(ricerca.equals(""))
return axb.toString();
try
{
Criteria criteria = session.createCriteria(Gcacm00f.class);
criteria = criteria.add(Restrictions.like("gcdsc1", ricerca.trim(), MatchMode.ANYWHERE));

List<Gcacm00f> lista = (List<Gcacm00f>) criteria.list();
log.debug("SIZE=" + lista.size());
for(Gcacm00f elem : lista)
{
axb.addItem(Util.escapeSpecialChar(elem.getDescrizioneEstesa()), elem.getGcid());
}

}
catch(Exception ex)
{
log.error("", ex);
}
}
}
finally
{
try
{
// if(userContainer != null && userContainer.getConn() != null && !userContainer.getConn().isClosed())
if(userContainer != null && !userContainer.isCloseConnection())
{
log.debug("CHIUDO SESSIONE HIBERNATE ");
HibernateUtil.closeSessionAS400(userContainer);
log.debug("CHIUDO CONNESSIONE");
//userContainer.getConn().close();
}
}
catch(Exception e)
{
log.error(e.getMessage(), e);
}
}
// if(userContainer != null)
// userContainer.setConn(null);
if(axb.isEmpty())
{
axb.addItem("Nessun record trovato", "ยงยงยง");
}
return axb.toString();
}

thank for the next answer. and i'm terible sorry for my bad English.

Bye
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts and AjaxTags autocompleter