2011/7/27 Pistis Valentino <[email protected]>
> I'm newbbie in Struts frameworks.
> I integrate Struts1 with Struts2, at the moment only 1 page uses
> Struts2 and the rest of the web app still using Struts2.
> At this points it's ok...
> but...
> now I want to use tiles2 for the unique page that uses struts2, so I
> read this tutorial:
>
>
http://www.vaannila.com/struts-2/struts-2-example/struts-2-tiles-example-1.html
> and many others, but I have persistently this error:
>
> ======================================
> Struts Problem Report
>
> Struts has detected an unhandled exception:
>
> Messages:
> javax.servlet.jsp.JspException: Error executing tag: Attribute
> 'header' not found.
>
How are you invoking the "aboutPage2" definition? I don't see any action at
all in your struts.xml, nor a result type for Tiles.
Antonio
Ciao Antonio,
thank you for the response, only today i'm subscribed to the maillist...and
i read the response fortunately viewing the archive mail list...
For invoking the action I used a Convention Plugin for Struts2, i use the
tags into the action.
And I'm sure, before using tiles, the aboutPage2 without using tiles it's
ok, and the jsp was writing entirely into 1 page jsp without any other
"tile", except javascript and css.
This is the code for the action with convention plugin tags:
-----------------------------------------------------------------
package it.dom.app.struts2;
import it.dom.app.businessObjects.base.HibernateSession;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.hibernate.Session;
import org.hibernate.cfg.Settings;
import org.hibernate.connection.ConnectionProvider;
import org.hibernate.engine.SessionFactoryImplementor;
import com.opensymphony.xwork2.ActionSupport;
//@ParentPackage(value = "struts2")
public class AboutPage2Action extends ActionSupport {
/**
* A generated Serial Version ID
*/
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(AboutPage2Action.class);
Session hibSession = HibernateSession.currentSession();
// Per recuperare il nome del database
final SessionFactoryImplementor sessionFactoryImplementor =
(SessionFactoryImplementor) hibSession
.getSessionFactory();
final Settings settings = sessionFactoryImplementor.getSettings();
ConnectionProvider connectionProvider = settings.getConnectionProvider();
Connection connection = null;
DatabaseMetaData databaseMetaData = null;
String dbUserName = null;
String dbVersion = null;
String dbDriverName = null;
String dbDriverVersion = null;
/**
* Il metodo execute e' molto piu' semplice rispetto a Struts, inoltre non
* e' necesario usare un ActionForm per il passaggio dei dati.
*/
@Action(value = "/protected/about2", results = {
@Result(location = "/pages/struts2/aboutPage2.jsp", name = "success")
})
public String execute() {
try {
connection = connectionProvider.getConnection();
databaseMetaData = connection.getMetaData();
dbUserName = databaseMetaData.getUserName();
dbVersion = databaseMetaData.getDatabaseProductVersion();
dbDriverName = databaseMetaData.getDriverName();
dbDriverVersion = databaseMetaData.getDriverVersion();
connection.close();
log.info("Ho appena letto i dati e chiuso la connessione!");
addActionMessage("Ho appena letto i dati e chiuso la connessione!");
return SUCCESS;
} catch (SQLException e) {
log.error("Attenzione!! Problemi con la lettura dei dati dal DB per
AboutPage2!", e);
addActionError("Attenzione!! Problemi con la lettura dei dati dal DB per
AboutPage2!");
return ERROR;
} finally {
HibernateSession.closeSession();
}
}
public String getDbUserName() {
return dbUserName;
}
public void setDbUserName(String dbUserName) {
this.dbUserName = dbUserName;
}
public String getDbVersion() {
return dbVersion;
}
public void setDbVersion(String dbVersion) {
this.dbVersion = dbVersion;
}
public String getDbDriverName() {
return dbDriverName;
}
public void setDbDriverName(String dbDriverName) {
this.dbDriverName = dbDriverName;
}
public String getDbDriverVersion() {
return dbDriverVersion;
}
public void setDbDriverVersion(String dbDriverVersion) {
this.dbDriverVersion = dbDriverVersion;
}
}
--------------------------------------------------------------------------------------
If I'm wrong, please, help me... :)
Thanx a lot!! (Grazie mille!!)