Uncommented Bytes

Friday, December 28, 2012

Jetty JTA via JNDI with Spring

Finally got Jetty 8 to have JTA transactions available to Spring via JNDI lookup using Atomikos 3.8 after a lot of trouble. I'm not 100% sure if this is correct but it seems to be working for me.

My main driver was not wanting to have Atomikos classes hardcoded in the spring config. Instead we can just register the Atomikos UserTransactionManager and UserTransactionImp classes in JNDI and have Spring look them up, just like if we were using Websphere, Weblogic, etc. Now I can use Jetty for local development instead of Websphere without any change to my actual code base. (Be warned that I'm not using this in prod.)

Steps:
1) Jetty 8 install
    Download, unzip, setup JETTY_HOME var for IntelliJ to use
2) Atomikos 3.8 install
    Download, unzip
    copy from the Atomikos lib/ directory into Jetty lib/ext/:
    geronimo-j2ee-connector_1.5_spec.jar
    geronimo-jms_1.1_spec.jar
    geronimo-jta_1.0.1B_spec.jar
    copy all the JARs from the Atomikos dist/ directory into Jetty lib/ext/.
    (Hat tip to this blogpost for helping)
3) Jetty config for JTA (Ref posting that helped)

4) Spring JTA lookup
    Spring will lookup using standard JNDI locations of java:/TransactionManager and java:comp/UserTransaction
    <tx:jta-transaction-manager/>

Labels: , , ,

Tuesday, September 18, 2012

iPhone Gmail Notes sync to Mac

After setting up Mountain Lion on my Mac, I went and tried the new Notes sync feature. I've been syncing my notes from my iphone to Gmail for months now (or so I had thought).

But going into the Notes app on my Mac I did not see anything newer than 6-8 months ago.

Then I checked gmail and the Notes label showed the same. And a few google searches turned up empty.

The fix for me was to go into iPhone settings > Mail, Contacts, Calendars > Fetch New Data > Advanced > and change my Gmail Notes account from Fetch to Manual.

Then I relaunched the Notes app on my phone and everything magically synced.

Scary thing is I think none of my Notes were backed up, even though I thought they were.... Hopefully this will help someone else out there.

Monday, August 06, 2012

CSS word-break and word-wrap


Finding a cross-browser CSS solution to force breaks in long words inside of table-cells is not an easy task. My issue was specifically with email addresses formatted like reallyreally.long.email.addressthatdoesnotbreak@fakeemail.com. The snag is that support is decent inside of block-level elements like divs, but only hacks seem to exist for table cells.

The widely supported white-space will instruct the browser to wrap on normal wrapping characters, but the browsers will not break a word. There are two newer CSS properties to try: word-wrap and word-break.

word-break:break-all will force a break anywhere but ignores spaces. It works well if you know your table cell will only contain a single term or word, and you don’t care about wrapping on commas, hyphens, or spaces.

word-wrap:break-word will honor commas, hyphens, and spaces to wrap first and then will force a break in the middle of words when needed. The catch is it only works cross-browser on block-level elements and not on table cells. Also a width or max-width must be specified.

One promising hack sets a table to be table-layout:fixed but this did not work with the jQuery datatables plugin.

So here is my cross browser solution, tested in Chrome, Firefox, and IE9. It unfortunately requires wrapping your td contents inside of a div. But it does work with the jQuery datatables plugin.


CSS:
/* forces wraps in middle of words when necessary */
div.force-wrap {
  white-space: normal;
  word-wrap: break-word;
}
td.email,
td.email div.force-wrap {
  width: 30em;
}

Html:
<table><tbody>
<tr>
  <td class="”email”">
<div class="”forcewrap”">
reallyreally.long.email.addressthatdoesnotbreak@fakeemail.com, another.email.addressthatdoesnotbreak@fakeemail.com
</div>
</td></tr>
</tbody></table>



Additional References

https://bugs.webkit.org/show_bug.cgi?id=43917
http://blog.kenneth.io/blog/2012/03/04/word-wrapping-hypernation-using-css/
http://petesbloggerama.blogspot.com/2007/02/firefox-ie-word-wrap-word-break-tables.html

Labels: ,

Wednesday, June 27, 2012

jQuery to Disable IE MS Lync phone number icons

Corporate environments have been pushing out MS Lync as the IM successor to Office Communicator. With that comes a click-to-call plugin that automatically puts a little phone icon next to any detected phone number on a web page. I can only assume that clicking the icon will make a phone call, as if anyone really wants that feature to be on by default.

Unfortunately for web developers, the icon is rendered by inserting markup into the webpage. This is a problem for a number of reasons:

  1. The icon looks like it is part of your page, but it's really not. 
  2. It even prints with the page. 
  3. It screws up your layout because the icon is inserted AFTER the page is rendered and onLoad javascript executes! This plays double issues when using a scrolling tables plugin like jQuery datatables because now the header doesn't lineup with the columns.
  4. There is no meta tag to disable the plugin. The only option to disable the plugin is up to the user or administrator, and we know we can't count on users to disable it for us.

Our phone numbers were in the common US format of (555) 555-5555. After some trial-and-error I found that MS Lync does not detect phone numbers that use a non-breaking hyphen (&#8209) instead of the normal hyphens (&#45 and &#4208) (big thanks to this Dashes and Hyphens page).

Now I could have changed our code server-side to render the new hyphen, but this caused issues with our exports to Excel, Word, and PDF. So instead I created a simple jQuery plugin that will replace the common &#45 hyphen with a &#8209 non-breaking hyphen and foil the MS Lync plugin from detecting our phone numbers.



Labels: ,

Tuesday, June 19, 2012

JQuery UI datepicker IE focus fix

A little writeup cross-posted on the OPI blog about making the jquery UI datepicker send blur events when dates change, while handling a quirk with IE:
http://www.objectpartners.com/2012/06/18/jquery-ui-datepicker-ie-focus-fix/

Labels: ,

Thursday, January 19, 2012

Spring regex-backed Date converter

I've written a small OPI blog post describing a Regex backed Spring Date Formatter/Converter annotation.