Tremend Tech Blog

"Software is a great combination between artistry and engineering. When you finally get done and get to appreciate what you have done it is like a part of yourself that you've put together." (Bill Gates)

Looking for software experts?

Need an expert advice on software development? Need consulting work done in time and at high standards? Tremend has the right solution for you.

We can provide expertise in:
  • high traffic and complex content website infrastructures
  • website development-advanced web programming with PHP, .NET, Java, Flash/Flex, Ajax

Our friends

Spring magic - Nested transactions

June 21st, 2006 by Ioan Cocan

The problem: Import a large number of items into a database, commiting valid ones and keeping track of invalid ones. All in a single transaction.

Traditional solution: Tedious to write. Programatically start a transaction and set a savepoint for each processed item. Rollback to savepoint if an exception occurs or commit if all ok.

Spring solution: Easy, just modifying the transaction demarcation. Along with traditional EJB transaction demarcation startegies, PROPAGATION_NESTED provides the needed behaviour.

Have the descriptor look like:

<bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">

<property name="transactionManager" ref="transactionManager"/>

<property name="transactionAttributes">

<props>
<prop key="import*">PROPAGATION_REQUIRED</prop>

 

<prop key="importNewItem">PROPAGATION_NESTED, -ImportException</prop>

<prop key="*">PROPAGATION_REQUIRED, readOnly</prop>

</props>

</property>

</bean>

And code like:

void import(){

while( moreToImport) {

try {

importNewItem(item);

imported.add(item);

}catch(ImportException ie){

failed.add(item);

}

}

}

 

The outer method (import) will start the transaction and inner method (importNewItem) will start nested transactions. The programmer can choose to catch inner methods exceptions, thus commiting the outer transaction, or let them propagate, rolling back the outer transaction.

More on nested transactions: http://forum.springframework.org/showthread.php?t=16594.

Share/Save

Posted in Java, General | No Comments »

Firefox overflow hidden prohibits event firing on other elements

June 19th, 2006 by Marius Hanganu

It seems that for Firefox, the style overflow hidden stops firing onmousemove or onmouseover events. Not sure if there is any standard for this behavior and if Firefox implements it or not. My guess is that there’s probably no standard, or if it is, it should be changed. Take a look at this small demo.

The demo page handles onmousedown, onmouseup, onmousemove, onmouseover events. What it happens basically is that when you have two DIVs with NO overflow hidden style, the events are fired correctly (onmouseover when moving your mouse over each one of the DIVs, onmousemove when moving the mouse over each DIV).

But when setting overflow=hidden, suddenly onmousemove and onmouseover are no longer fired when moving your mouse over the other DIV. Instead, Firefox keeps firing onmousemove with the same source, no matter where you are on the page.

Not too many references on this on the web. Just a question on dojo’s mailing list about it: http://dojotoolkit.org/pipermail/dojo-interest/2006-April/007137.html

Share/Save

Posted in HTML, Javascript | 2 Comments »