Monday, November 2, 2009
It's funny cause it's true
“The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.”—Joe Armstrong
Monday, October 26, 2009
Dependency Injection Makes Your Code Worse
Read my article which explains why, and feel free to comment:
http://java.dzone.com/articles/dependency-injection-makes
http://java.dzone.com/articles/dependency-injection-makes
Sunday, October 11, 2009
understanding monads - thanks to jQuery
In my previous post I wrote about jQuery:
I was taking a short break from watching Bathurst and googling monads again... when I came across this great blog post. It turns out that the magical things I love about jQuery are a monad!
I feel like I'm a little bit closer to understanding monads now, and I'm happy to have a name to describe the magic I was using without knowing what it was.
Go Lowndesy!
...if you simply wrap the "this" keyword with $(), it magically somehow becomes a jQuery object...
I was taking a short break from watching Bathurst and googling monads again... when I came across this great blog post. It turns out that the magical things I love about jQuery are a monad!
I feel like I'm a little bit closer to understanding monads now, and I'm happy to have a name to describe the magic I was using without knowing what it was.
Go Lowndesy!
Wednesday, October 7, 2009
jQuery - using "this" in a .each() function
The "this" keyword can be used in two ways inside a jQuery callback function. If you use "this" in the callback below without putting the $() around it, you will get a reference to the HTML element selected by the $(".currency") class selector.
However, if you simply wrap the "this" keyword with $(), it magically somehow becomes a jQuery object, and you can use all the regular jQuery functions on it like .text() and .val()
However, if you simply wrap the "this" keyword with $(), it magically somehow becomes a jQuery object, and you can use all the regular jQuery functions on it like .text() and .val()
$(".currency").each(function() {
$(this).text(formatCurrency($(this).text()));
});
Friday, September 25, 2009
How to copy a field value from a jQuery UI Dialog into a form
If you have a form on your page, and would like to display a jQuery dialog which prompts for some extra data to add to the form before you submit it, here's how you can do it:
Basically, the
<SCRIPT language=JavaScript>
function copyValueAndSubmit() {
$('#popupDiv').dialog("destroy").appendTo("#myForm");
$("#myForm").submit();
}
$(function() {$('#popupDiv').dialog({autoOpen: false});});
</SCRIPT>
<form id="myForm" name="myForm">
<input id="field1"/>
<input id="field2"/>
<button type="button" onclick="$('#popupDiv').dialog('open');">Save</button>
</form>
<div style="visibility:hidden;">
<div id="popupDiv">
<input id="field3"/>
<button type="button" onclick="copyValueAndSubmit();">Submit</button>
</div>
</div>
Basically, the
.dialog("destroy").appendTo("#myForm") call allows you to grab whatever was in the popup dialog and append it to the form on your page before it gets submitted.
No wonder Apple is concerned about Google's iPhone apps
I just got my replacement iPhone and it seemed to vibrate randomly. I thought maybe there was a problem with it - but it turns out Google has just enabled push email!
I am extremely impressed with Google. Push Gmail is free and awesome, their calendar support and integration with the iPhone is awesome (including multiple calendars), and it all works with Google Apps for your own Domain as well.
I think Google just killed MobileMe.
I am extremely impressed with Google. Push Gmail is free and awesome, their calendar support and integration with the iPhone is awesome (including multiple calendars), and it all works with Google Apps for your own Domain as well.
I think Google just killed MobileMe.
Thursday, September 17, 2009
How to determine the type of Request with Spring MVC's @InitBinder
If you want to determine the request method of a request (i.e."POST", "GET" etc) in Spring MVC, using a SimpleFormController you could just call isFormSubmission(). When using annotations, the @RequestMapping annotation gives you that functionality for free in the annotation parameters.
If you want to achieve the same thing on a method annotated with @InitBinder, the same does not apply. However, you can simply do this:
Why would you want to know the type of request in an @InitBinder method? Stay tuned to find out one pretty cool application.
If you want to achieve the same thing on a method annotated with @InitBinder, the same does not apply. However, you can simply do this:
@InitBinder
public void initBinder(HttpServletRequest request) {
if ("POST".equals(request.getMethod()){
//Do something
}
}
Why would you want to know the type of request in an @InitBinder method? Stay tuned to find out one pretty cool application.
Labels:
annotations,
java,
mvc,
spring
Subscribe to:
Posts (Atom)