Tuesday, March 19, 2013

JQuery Autocomplete: event when suggestion is selected

There is an event when suggestion is selected, use the select event:

$("#username").autocomplete({
                            source: availableTags
                            , select: function( event, ui ) {
                                alert("hi");
                            }
                        });

Reference:
http://api.jqueryui.com/autocomplete/#event-select
http://stackoverflow.com/questions/7733315/jquery-autocomplete-event-select

Tuesday, February 19, 2013

Friday, February 15, 2013

Can't find Microsoft.Data.Entity.CTP

If you are trying to add a reference froom .NET Microsoft.Data.Entity.CTP but it is not avaliable in the "Add Reference > .NET" list,

Download the file EF4FeatureCTP3.exe from de following link
http://www.microsoft.com/en-us/download/details.aspx?id=13203

Restart Visual Studio and retry the reference adding and the Microsoft.Data.Entity.CTP will be in the list.

Reference:
http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/762277dc-a3b2-44f5-864a-fb5d3b704845/

Thursday, February 14, 2013

DBVisualizer: The JVM could not be started. The maximum heap size (-Xmx) might be to large or an antivirus or firewall tool could block the execution

If you the the folloging error:

"The JVM could not be started. The maximum heap size (-Xmx) might be to large or an antivirus or firewall tool could block the execution"

Modify the -Xmx value in the dbvis.vmoptions file located in the installation directory for DbVisualizer as follows.

-Xmx512m

or

-Xmx1024m

Save the file and restart DbVisualizer.

Resource:
http://www.dbvis.com/forum/thread.jspa?messageID=10472



Thursday, February 7, 2013

Thursday, January 3, 2013

Spring MVC and NetBeans Rest service from database tutorial: 415 Unsupported Media Type



I was doing the Spring MVC and NetBeans Rest service from database tutorial

http://netbeans.org/kb/docs/websvc/rest.html#rest-spring

But now wanted to consume the service with an ajax request in jquery:

                             var data = {"id":"1","identification":"1010182323","name":"jhon"};

                            $.ajax({                                           
                                                url: "/notes/"
                                                ,type: 'POST'
                                                ,dataType: "json"                                        
                                                ,data: data                                               
                                                ,success: function(data, textStatus, jqXHR){                                                  
                                                },
                                                error: function(jqXHR, textStatus, errorThrown){                                                
                                                }
                                            });


And I was getting the error:

 415 Unsupported Media Type

The solution was specifying the contentType and encoding the data to json:

                                     var data = {"id":"1","identification":"1010182323","name":"jhon"};

                                     $.ajax({                                          
                                                url: "/notes/"
                                                ,type: 'POST'
                                                ,dataType: "json"                                                
                                                ,data: Ext.JSON.encode(data) // here
                                                ,contentType: "application/json" // here                                                
                                                ,success: function(data, textStatus, jqXHR){
                                                },
                                                error: function(jqXHR, textStatus, errorThrown){
                                                }
                                            });

Here is an example of how to use the Ext.JSON.encode method

http://jhonjairoroa87.blogspot.com/2012/10/javascripy-simple-encodedecode-json.html

Resources:
http://docs.oracle.com/cd/E19226-01/820-7627/giepu/index.html
http://www.checkupdown.com/status/E415_es.html
http://stackoverflow.com/questions/9754767/cannot-set-content-type-to-application-json-in-jquery-ajax
http://api.jquery.com/jQuery.ajax/