Archive for May, 2009

Mobile: Google G2 / HTC-Magic cannot do 3G on ATTW :(

Saturday, May 30th, 2009

Basically, it is a 3G band issue. TMobile & AT&T Wireless do not use the same 3G bands (AT&T Wireless does not use use the conventional ones). G2/HTC-Magic was built for TMobile.

The G2/HTC-MagicĀ 3G Network HSDPA 900 / 2100

AT&T Wireless usesĀ 850mhz(the old TDMA band) and 1900mhz for 3G.

Here is a great post about the TMobile/ATTW 3G band issue.

Ho, well, it was too good to be true. Edge is still not that bad, at least for email/calendar and even Map.

jQuery: Remove vs. Hide

Tuesday, May 19th, 2009
$("p").hide();

jQuery hide just hide an element by adding the “display:none” css properties.

$("p").remove();

jQuery remove removes the elements from the DOM including all event handlers and internally cached data.

jQuery: Get last added (or appended) element.

Wednesday, May 13th, 2009
var lastAddedElement = $("#myDiv").append("Cool link").find(":last");

The $.fn.append method returns the selected element and not the added one (this is to allow chaining)

jQuery: Pass data from draggable to droppable (jQueryUI)

Friday, May 8th, 2009

jQuery has a neat and efficient way to attach data to DOM elements ($.fn.data). You can use it to pass data from your draggable to your droppable.

First you attach the data to the draggable UI element:

$(".document").draggable({
  helper: 'clone',
  revert: 'invalid'
}).data("myData","secret data");

Then, you get it back on drop:

$(".folder").droppable({
   accept: ".document",
   hoverClass: "drophover",
   tolerance: "touch",
   drop: function(event, ui){
           alert($(ui.draggable).data("myData"));
   }
});
See also: jQuery UI Drop API

Hibernate: org.hibernate.WrongClassException … instanceAlreadyLoaded

Monday, May 4th, 2009

Hibernate inheritance and relationship could lead to the following exception:

Caused by: org.hibernate.WrongClassException: Object with id: 3 was not of the
specified subclass...
...
        at org.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.java:1267)
        at org.hibernate.loader.Loader.getRow(Loader.java:1219)
        at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:603)
        at org.hibernate.loader.Loader.doQuery(Loader.java:724)
...

Putting @ForceDiscriminator near the @DiscriminatorValue(..) of your respective classes might solve the problem.
See Hibernate Annotation Doc

jQuery: Custom Button with Div and CSS

Friday, May 1st, 2009

Html code:

<div class="button">My Custom Button</div>

CSS code:

/*** .button ***/
.button{
	display: inline;
	border: solid 1px #999999;
	border-top-color: #ffffff;
	border-left-color: #ffffff;
	background-color: #f4f4f4;
	padding: 3px;
	cursor: pointer;

}

.button.down{
	border-top-color: #999999;
	border-right-color: #ffffff;
	border-bottom-color: #ffffff;
	border-left-color: #999999;
	background-color: #f0f0f0;
}
/*** /.button ***/

JS code:

<script type="application/javascript">
$(document).ready(function(){

    $(".button").live("mousedown",function(){
        $(this).addClass("down");
    }).live("mouseup",function(){
        $(this).removeClass("down");
    }).live("mouseout",function(){
        $(this).removeClass("down");
    });
});
</script>

I used “live“, but obviously, you can use “bind” as well.

See also: jQuery Live