Posts

jquery - Create bootstrap select picker dynamically -

i'm using bootstrap select plugin . populating dynamically created select so: var select = $('<select/>', { 'class':"selectpicker" }).selectpicker(); (var idx in data) { if (data.hasownproperty(idx)) { select.append('<option value=' + data[idx].id+ '>' + data[idx].text+ '</option>'); } } select.selectpicker('refresh'); the data fine , select created, not recognizing bootstrap selectpicker trying create. have select on same page not create dynamically , works fine. <select class="selectpicker"> <option>mustard</option> <option>ketchup</option> <option>relish</option> </select> $('.selectpicker').selectpicker(); how dynamically create bootstrap select? thanks. you need append <select /> create dom before calling selectpicker() on it, this: var $select = $('<select/>...

java - How to properly handle empty resultset with Hibernate and Spring Boot -

i have spring app using hibernate , spring data jpa's crudrepository . seems work if data queried exists in database. however, if there query returns no result, crudrepository returns null , nullpointerexception . example http://localhost:8080/api/id=3 if there row id 3 in database works fine. if there isn't row id of 3 fails a: there unexpected error (type=internal server error, status=500) on client side , nullpointerexception on server side. what proper way of dealing simple case of "no results" query? inspect return value, if it's not null , return representation of 200 ok response. otherwise, return 404 not found . in end, have controller like: @requestmapping(...) public responseentity<?> getone(...) { something = repository.findone(...); if (something == null) return responseentity.notfound().build(); return responseentity.ok(something); } can refactor preceding code incorporate java 8's opti...

Neo4j Community Edition 3.0.1 failed to start -

i populated neo4j database using gremlin console 3.1.2. checked data persistent exiting above console , go pointing local database location: >graph=neo4jgraph.open('/myneo4jdb/graphdb') >g = graph.traversal() >g.v() ==>v[0] ==>v[1] ==>v[2] ==>v[3] working on windows 7 professional. checked directory c:\myneo4jdb\graph.db has been created , populated files. see visual representation of data using "neo4j community edition 3.0.1" got error "starting neo4j failed: component 'org.neo4j.server.database.lifecyclemanagingdatabase@3c5e750c initialized, failed start". know neo4j community edition 3.0.1" working fine display database. reason neo4j community edition failed open database? appreciated. you have upgrade database. set in neo4j.conf (you can reach via "options" pane in starter) dbms.allow_format_migration=true

marklogic - xdmp:node-delete funny behavior -

when used xdmp:node-delete on not existing node, works on query console in cpf throws xdmp-argtype: (err:xpty0004) xdmp:node-delete(()) -- arg1 not of type node() following in query console let $_ := xdmp:node-delete(fn:doc($uri)/enevelope:document-enevelope/enevelope:extractedtext) the document not have node, on query console not complain, give error when used in cpf? often times when works in query console doesn't work when i'm running in module permissions problem. as justin said it, error shows have empty sequence. happening because of xpath said or being happening because user running query cant see document. i'd check make sure document coming back. debugging cpf pain, check i'd xdmp:log it. you eval user in query console.

MySQL date between last monday and the next sunday -

i'm looking find records have booking date between previous monday , next sunday in mysql. so far have: select firstname , lastname , sessions , (select count(memberid) bookings m.memberid = b.memberid , b.date between lastmonday , nextsunday) sessionsused members i'm looking substitute lastmonday , nextsunday any appreciated! mysql's yearweek() function selects unique value each week can use comparison. takes a second parameter specifies whether weeks start on sunday (0) or monday (1). select count(memberid) bookings m.memberid = b.memberid , yearweek(b.date, 1) = yearweek(now(), 1); this select rows b.date in current week. specific week in past, change now() whatever date expression require. for more generic case week not start on sunday or monday, need more complicated logic. here substitute @weekday day on weeks begin, 2 = tues, 3 = wed, 4 = thu, 5 = fri, 6 = sat. select count(membe...

Android: My GridView's photos is mixed -

public class imageadapter extends baseadapter { layoutinflater inflater; imageview photo; checkbox check; bitmapfactory.options options; public imageadapter(context c) { inflater = (layoutinflater)c.getsystemservice(context.layout_inflater_service); } public int getcount() { return receivedphoto.size(); } public object getitem(int position) { return receivedphoto.get(position); } public long getitemid(int position) { return position; } public view getview(int position, view convertview, viewgroup parent) { if(convertview == null) { convertview = inflater.inflate(r.layout.phototab_list, parent, false); photo = (imageview)convertview.findviewbyid(r.id.photos); check = (checkbox)convertview.findviewbyid(r.id.photoscheck); options = new bitmapfactory.options(); options.insamplesize = 16; } log.i("load", posit...

How to get the constructor method of a class? -

i have class a takes class b template argument, , need b 's constructor in order (somewhat pseudocode): class a(b) { import std.typecons : tuple; import std.traits : parameters; tuple!(parameters!b) _args; this(parameters!b args) { _args = args; } } to store arguments constructor , later construct object of class b arguments stored in _args . this pretty command pattern. is there way constructor of b parameters ? or there better way achieve deferred object construction? yes, constructor's internal name __ctor : class c { this(int a, string b) { } } import std.traits; pragma(msg, parameters!(c.__ctor)); this outputs: (int, string)