added some methods to resource and corresponding javascript