Feb 28, 2008

100% Height Div in Firefox

It was a surprise for me to find out that this is actually a problem with tricks and hacks involved.

Once I wanted to make 100% height div, I've found lots of “solutions”, all of which were either ie-only or involved render the div as a table cell or caused it to be exactly 100% of the screen height, ignoring the height of the actual content (which might be bigger), or caused scrollbar to appear even though content was fitting in one screen.

Although none of the solutions was perfect, when properly combined they actually do the thing.

General concepts are:
— Make html and body elements 100% high to allow inner blocks height setup;
— Set container's height to auto and min-height to 100% to avoid content overflow;
— Don't put content in the container itself but use it as a wrapper to allow padding without scrollbar

So here it goes: 100% height div for both IE and Firefox.
View source to see how it's done.

Feb 27, 2008

«Connection is read-only» Exception

I've ran into funny exception recently. I've a function updating database table using Spring's JdbcTemplate and for some reason there was this exception:

java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1056)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1973)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1940)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1925)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:773)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:566)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:767)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:825)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:833)
at com.myapplication.user.JdbcUserDao.saveData(JdbcUserDao.java:511)

...


There wasn't much about it on the Internet, but apparently, the problem occures when the JdbcUserDao is configured as proxy bean and saveData method (or any other method making updates to database) is missing its PROPAGATION_REQUIRED flag in the applicationContext.xml.

Feb 26, 2008

***

This blog will probably mostly consist of solutions for coding problems I've faced but for which I couldn't find direct answers on the Internet.

Googling the problem is the first thing I do after I can't figure it out for myself, and usually there's a blog post entitled with exact same words I used as a search query. In most cases that post solves the problem, but sometimes Google has nothing to offer (yes, even on the second page).

After several hours (or minutes) of hard (or enjoyable) work, the problem is solved and I can share my explorations with people all over the world. Although most likely I'll share them with myself a couple weeks later since I'm so forgetful.

Anyway, I guess it is now clear why this way of blogging looks like putting missing pieces of the puzzle in place for me.

Since now I am still in the beginning of the long way of all sorts of coding, some things may seem unwise, but again, I prefer to think of this as of some sort of draft notebook used just to keep random instructions, links or thoghts in one place.