Dear List,
I have not got any answer to my previous questions, so I wrote a test
application. I can compile this test, but it crashes. Can somebody help
me, what is the problem in this code? I have attached the code.
tusi
On Fri, 2010-10-22 at 14:30 +0200, Gabor E. Tusnady wrote:
> Dear list,
>
> I have found a error in Dbo/QueryModel_impl.h line 269 (version 3.1.5):
> The return statement is superfluous.
>
> Moreover I try to use QueryModel, but failed. In the linking state I got
> a lot of errors similar to this:
>
> ../XBuilder/libXBuilder.a(XModelFactory.C.o): In function
> `Wt::Dbo::QueryModel<Wt::Dbo::ptr<Reference>
> >::QueryModel(Wt::WObject*)':
> XModelFactory.C:(.text._ZN2Wt3Dbo10QueryModelINS0_3ptrI9ReferenceEEEC1EPNS_7WObjectE[Wt::Dbo::QueryModel<Wt::Dbo::ptr<Reference>
> >::QueryModel(Wt::WObject*)]+0x3f): undefined reference to
> `Wt::Dbo::Query<Wt::Dbo::ptr<Reference>, Wt::Dbo::DynamicBinding>::Query()'
>
>
> As I am not an expert, so I could not find the solution to this problem.
> Can somebody direct me to the right way? Where can I found a working
> example of QueryModel except of this:
>
> http://www.webtoolkit.eu/wt#/blog/2010/05/10/wt__dbo_meets_wt_views__querymodel
>
> What is the best definition of the <Result> class, used by QueryModel as
> template?
>
> Thanks your help
>
> tusi
>
>
> ------------------------------------------------------------------------------
> Nokia and AT&T present the 2010 Calling All Innovators-North America contest
> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest
#include <iostream>
#include <string>
#include <exception>
#include "Wt/Dbo/backend/Sqlite3"
#include "Wt/Dbo/Exception"
#include <Wt/WServer>
#include <Wt/WGlobal>
#include <Wt/WApplication>
#include <Wt/WEnvironment>
#include <Wt/WTableView>
#include <Wt/Dbo/Dbo>
#include <Wt/WText>
#include <Wt/WStandardItemModel>
#include <Wt/WStandardItem>
#include <Wt/WStringListModel>
#include <Wt/Dbo/Query>
#include <Wt/Dbo/QueryModel>
#include <Wt/Dbo/QueryModel_impl.h>
using namespace Wt;
using namespace std;
namespace dbo = Wt::Dbo;
WApplication *createApplication ( const WEnvironment& env );
class Test
{
public:
Test() :
col1("notSet"), col2("") { }
Test(const std::string& acol1) :
col1(acol1), col2("") { }
Test(const std::string& acol1, std::string& acol2) :
col1(acol1), col2(acol2) { }
Test(const char *acol1, const char *acol2) :
col1(acol1), col2(acol2) { }
template<class Action>
void persist(Action& a)
{
dbo::field(a, col1, "column1");
dbo::field(a, col2, "column2");
}
public:
std::string col1;
std::string col2;
};
class myAppl : public WApplication {
public:
myAppl ( const WEnvironment& env );
};
myAppl::myAppl(const Wt::WEnvironment& env) : WApplication( env ) {
dbo::backend::Sqlite3 sqlite3("test.db");
dbo::Session session;
session.setConnection(sqlite3);
session.mapClass<Test>("test");
try {
session.createTables();
} catch ( dbo::Exception *e ) {
cerr << e->what() << endl;
}
dbo::Transaction transaction(session);
Test *test1 = new Test("apple","red");
Test *test2 = new Test("grape","green");
dbo::ptr<Test> test1Ptr = session.add(test1);
dbo::ptr<Test> test2Ptr = session.add(test2);
transaction.commit();
dbo::QueryModel< dbo::ptr<Test> > *model = new dbo::QueryModel< dbo::ptr<Test> > ();
model->setQuery(session.find<Test>());
model->addAllFieldsAsColumns();
cerr << "Columns: " << model->columnCount() << " Rows: " << model->rowCount() << endl; //Columns: 4 Rows: 2
WTableView *view = new WTableView( );
view->resize(800, 400);
view->setModel(model);
//view->setAlternatingRowColors( true );
WText *t = new WText("<h1>Table:</h1>");
root()->addWidget ( t );
root()->addWidget ( view );
session.dropTables();
}
WApplication *createApplication ( const WEnvironment& env ) {
return new myAppl ( env );
}
int main ( int argc, char **argv ) {
return WRun ( argc, argv, &createApplication );
}
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest