Skip to content

Instantly share code, notes, and snippets.

render : function() {
var that = this;
TemplateManager.get(this.template, function(template) {
$(that.el).html(template({
"canEdit" : that.canEdit,
"innerId" : that.options.innerId,
"innerType" : that.model.innerObjectType +'s',
save:function (nousevar,settings) {
//var url = this.parentType + '/' + this.parentId + '/' + this.innerObjectType + 's' + '/add/' + innerObjectId
url = this.urlRoot();
//var url = "keyword/" + this.id + "/superKeywords/add/" + superId
console.log('add relation between ' + this.parentId + ' and ' + this.id);
var self = this;
@oak-tree
oak-tree / keywordControllerTest
Created November 28, 2013 10:01
mock testing with controller...
package org.jpp.api.controller;
import org.apache.log4j.Logger;
import org.jpp.domain.Keyword;
import org.jpp.service.domain.KeywordService;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@oak-tree
oak-tree / regular_template_manager_use
Created December 5, 2013 16:41
regular_template_manager_use
render : function(args) {
/*
* using template manager we can allow object use diffrent
* templates.
*/
if (keywords.size() > 0) {
SetJoin<Report, Keyword> keyword = report.join(Report_.keywords);
Expression<Long> keywordExpr = keyword.get(Keyword_.id);
Predicate pred = keywordExpr.in(keywords);
preds.add(pred);
query.having(cb.equal(cb.countDistinct(keyword.get(Keyword_.id)),
keywords.size()));
}
@oak-tree
oak-tree / gist:8708433
Created January 30, 2014 13:36
spring controller integration test
MvcResult result = (MvcResult) mockMvc.perform(post("/api/search/report/advanced").contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(pageRequest.getBytes()))
.andExpect(status().isOk())
.andExpect(content().contentType(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$[0].page").value(page.intValue()))
.andExpect(jsonPath("$[0].page").exists()).andReturn();
booolView.render().$el.find('img').one('load', function(event) {
/* make sure to cancel timeout first */
model.trigger('boool:load-event');
self.collection.trigger('boool:load-event');
console.log('loaded');
}).one('error', function(event) {
console.log('error loading the img');
connect: {
options: {
port: 9000,
// // change this to '0.0.0.0' to access the server from outside
// // hostname: 'localhost'
hostname: '0.0.0.0'
},
livereload: {
options: {
middleware: function (connect) {
/**
*
* add bind to function prototype example
* model.on('click',myobject.somefunction.bind(this));
*
*/
Function.prototype.bind = function(context) {
var fn = this; // correlates to this.onTimeout
return function() { // what gets passed: an anonymous function
/* this WORKS */
@RequestMapping(value = "{field}/image/{name}.jpg", method = RequestMethod.GET)
public void getImage(HttpServletResponse response, @PathVariable("field") String field,@PathVariable("name") String name)
throws NoSuchImageException, BadFieldNameException, IOException, PathTraversalException {
model.uploadMagdirImageFile(MagdirPrecondition.fieldNameOk(field),name, response);