Wednesday, December 31, 2008

First project in Flex

Since I have limited option, I used Flex as my UI, asp as my webserver that run sql and send response as xml.

Its just a first draft, but I'm very pleased with the results

Wednesday, December 24, 2008

First time learning from Video

Its my first time that I spend my night (instead of sleeping), watching video of learn Flex.
I find it very useful and I recommend everyone who want to learn Flex to watch this.
You can find the movies in here: http://www.adobe.com/devnet/flex/videotraining/

Sunday, December 21, 2008

JTable, detect when any cell's value changes

I have a dataModel, TableModel that extends DefaultTableModel.
I needed to know If the user changed the values of the table,
for this I override the method setValueAt:

public void setValueAt(Object aValue, int row, int column){
super.setValueAt(aValue, row, column);
tableModelChanged = true;
}

Transaction not successfully started

I got an exception : org.hibernate.TransactionException: Transaction not successfully started

The problem in my code was :
Session session = null; Transaction tx = null; session = PriorityWrapperHibernateUtil.getOneTimeSession(); tx = session.getTransaction(); for (int i = 0; i < objects.length; i++) { Object object = objects[i]; session.saveOrUpdate(object); } if(tx != null){ tx.commit(); }


instead, it should be : tx = session.beginTransaction();

I used the Koders site to find out where the exception is comming from

Saturday, December 20, 2008

Send an Object using HttpClient

I was looking for a way to send an Object (in my case, a Class) using HttpClient.
This is how I did it:
PostMethod httpMethod =new PostMethod(servletName);
HttpMethodParams httpMethodParams = new HttpMethodParams();
httpMethodParams.setParameter("Object Name", Object);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(tableDataTO);
ByteArrayRequestEntity byteArrayRequestEntity = new ByteArrayRequestEntity(bos.toByteArray());
httpMethod.setRequestEntity(byteArrayRequestEntity);
HttpClientManager.getInstance().executeRequest(httpMethod);


and in the other side, the Servlet side:

InputStream inputStream = request.getInputStream();
ObjectInputStream oos = new ObjectInputStream(inputStream);
ClassName className = null;
try {
className  = (ClassName ) oos.readObject();
} catch (ClassNotFoundException e) {
log.error("Unable to get ClassName  object from the request", e);
}

Thursday, December 18, 2008

create forum using Flex

Since I start to use Flex (well, learning....), I want to create a forum using Flex,
any idea? any one?