Posts

Showing posts from January, 2014

python - Django Tutorial - Part 1 - URL didn't match -

this has been asked before, problems placement of mysite/urls.py or missing text somewhere. i've gone on in detail, doesn't apply here. i'm following django tutorial exactly, means hasn't referenced including polls app in settings.py file. can pull right view if manually type in "polls" @ end of url, in " http://127.0.0.1:8000/polls " shouldn't have work. i'm assuming tutorial isn't wrong in way. link tutorial is: https://docs.djangoproject.com/en/1.9/intro/tutorial01/ the error get: page not found (404) request method: request url: http://127.0.0.1:8000/ using urlconf defined in mysite.urls, django tried these url patterns, in order: ^polls/ ^admin/ current url, , didn't match of these. my views.py file: from django.shortcuts import render django.http import httpresponse def index(request): return httpresponse("hello, world. you're @ polls index.") my polls/urls.py file: from django.conf.url

mysql - How to get the ranks of two different colums in a table in my case? -

so have table named db_points. ---------------------------------------- | name | points | spoints | rpoints | ---------------------------------------- | max | 240 | 50 | 1242 | | alvin | 600 | 123 | 3012 | | amanda | 234 | 1000 | 132 | | angela | 50 | 514 | 4023 | | rudolph | 2000 | 230 | 1232 | ---------------------------------------- i need rank based on ordering tpoints (points+spoints), points, spoints, rank based on rpoints , rpoints. this following angela, rudolph or amanda. -------------------------------------------------------------------- | rankt | name | tpoints | points | spoints | rankr | rpoints | -------------------------------------------------------------------- | 4 | angela | 564 | 50 | 514 | 5 | 4023 | | 1 | rudolph | 2230 | 2000 | 230 | 2 | 1232 | | 2 | amanda | 1234 | 234 | 1000 | 1 | 132 | --------------------------

How to zoom out an image by Bilinear Interpolation in java? -

i trying read image, zoom in 80*60 , zoom out resulted image 5 times bilinear interpolation method. error : exception in thread "main" java.lang.arrayindexoutofboundsexception: 4800 . can me please? this have done : import java.awt.color; import java.awt.graphics2d; import java.awt.image; import java.awt.renderinghints; import java.awt.image.bufferedimage; import java.awt.image.databufferbyte; import java.awt.image.writableraster; import java.io.bytearrayinputstream; import java.io.file; import java.io.ioexception; import java.io.inputstream; import javax.imageio.imageio; public class biinterpolationtest { public static int zh; public static int zw; public static void main(string[] args) throws ioexception { // todo auto-generated method stub int[][] savedimage; file f = new file ("f:\\java\\gray scale images\\3.jpg"); savedimage = readimage(f); bufferedimage grayimage = new bufferedimage(saved

javascript - Java HtmlUnit click on anchor link does not work. How do I get the new page? -

i'm trying click on "more" anchor tag on website using htmlunit in order expand list until more anchor tag not exist. page = client.getpage(url); htmlanchor anchor; while((anchor = page.getfirstbyxpath("//a[@class='load-more list']")) != null) { page = (htmlpage) anchor.getpage(); } i've tried page = anchor.click(); system.out.println(anchor) shows htmlanchor[ href="/guideitem/list/?id=g407&requesttype=browse&filter=zmlsdgvypxmlm2fmcmvljmxpbwl0ptmw" class="load-more list" data-hijax="false" ] i continue problem , post find here. i've had similar problem, hope helps. "solved itself" after disabled css on webclient: webclient.getoptions().setcssenabled(false); my anchor was: <div class="my-anchors-parent-class"/> <a href="javascript:void(0) class="text" id="buttonsearch" style="display: block;">search

c++11 - C++ unordered_map with char* key produces unexpected behavior -

i attempted use unordered_map hash char* key integer value. after writing custom functors hash , compare char*, unordered map appeared work. however, noticed hash return incorrect results. created test project reproduce error. code below creates unordered_map char* key , custom functors. runs 1000x cycles , records hash errors occurred. wondering if there wrong functors, or if problem lies within unordered_map. appreciated. thanks! #include <cstdlib> #include <stdio.h> #include <string.h> #include <time.h> #include <tr1/unordered_map> using namespace std; //these varaibles used printing status. static const char* c1; static const char* c2; static int cmpret; static int cmpval; static const char* hashchar; static size_t hashval; // character compare functor. struct cmpchar { bool operator()(const char* s1, const char* s2) const { c1 = s1; c2 = s2; cmpval = strcmp(s1, s2); cmpret = (cmpval == 0); return cmpret; } };

c++ - Qt: when can I access dynamic properties from qtcreator? -

i have couple of widgets in qtcreator promoted same class. however, i'd them have subtle differences between two, i'd pass differences in ui file promoted class can use distinguish itself. dynamic properties seem way go in ui editor i've assigned dynamic property each promoted widget. in code tried accessing property, noticed seems available post construction (probably because qt calling setproperty() after object created. mywidget::mywidget(qwidget* parent) : qglwidget(parent) { this->property("someproperty").tostring(); // returns blank } void mywidget::initializegl() { this->property("someproperty").tostring(); // returns string set in ui file } so question how people use these properties constructor-type stuff? in initializegl, seems odd since these properties might not related initializing opengl. imagine connect property changed signal , there. common way handle this? if generated code setupui() .ui file th

php - Webix Data Loading from Laravel Link -

trying load data webix data table using following code. looks browser getting json data back, webix isn't doing data. no datatable shows up, can still see full json under network -> response tab in firefox inspector. valid way of loading data webix? <script type="text/javascript" charset="utf-8"> dtable = new webix.ui({ container:"box", view:"datatable", select:"row", scroll:"xy", leftsplit:3, url: "{{ url('/getcontacts') }}", datatype: "json" }); </script> specifically, question around whether url work route 'getcontacts' returns json object. after troubleshooting webix, determined yes. using "{{ }}" does work webix, case, g

python 2.7 - messagebox getting looped -

i displaying message box on click of option menu when data not available , acquired. somehow whenever change content of option menu message box gets looped. like- first time vanishes when press ok. when change option again second time displays message box 2 times , third time 3 times. can tell me change in code? #the function change option menu value def module_func(event): #declarations if(datetext.get()!="" , drivetext.get()!=""): global module_dir global selected_module modules['menu'].delete(0,end) select="-----select-----" modules['menu'].add_command(label=select, command=tk._setit(module,select)) module_dir in get_immediate_subdirectories(('%s\%s\%s')%(startpath,selected_shot,selected_fec)): module_dropdown.append(module_dir) modules['menu'].add_command(l

Selenium cannot find the element under iframe -

i'm trying find element under iframe, , i've switch frame, still can not find element enter image description here my html in link: http://pastebin.com/ashyrdxq hi first of i found 1 iframe on page id = msgframe , please note per source code frame commented not playing role hence please not use switch driver use list<webelement> commonelements = driver.findelements(by.classname("apps_title")); for(int =0;i<commonelements.size();i++){ system.out.println(commonelements.get(i).gettext()); } and work hope you.

rest - RAML 1.0 ciclical nested includes -

i have issue, have created 2 libraries define 2 different types, here are: category.raml #%raml 1.0 library uses: - event: !include event.raml - tournament: !include tournament.raml types: ############################################################################# base: usage: base type category properties: min_age: description: minimum age participate in category required: true type: number max_age: description: maximum age participate in category required: true type: number name: description: name of category required: true type: string gender: description: gender of category required: true enum: - male - female - mix tournament: description: tournament of category required: true type: tournament.base #############################################################################

javascript - Collapse with dynamic accordions -

<div class="panel-group" id="accordion"> {{#each forms}} <div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href=".collapse"> {{fid}}</a> </h4> </div> <div class="panel-collapse collapse"> <div class="panel-body"> {{> form}} </div> </div> </div> {{/each}} </div> <template name="form"> <li class="list-group-item list-group-item-warning">first name : {{fname}}</li> <li class="list-group-item list-group-item-warning">last name : {{lname}}</li> <li class="list-group-item list-group-item-warning">analysis

java - How to put database connection information to a separate file? -

in php, create file, e.g. connect.php , include file each , every page like: in java created separate file in same project folder called connect.java , tried call in other files files database connection no luck far . i tried last time amazed me variables connect page not able use them in main program . can please me . bellow code use connect mysql , prinde stuff but wanna make separate file don’t print nothing connect , print want in different file so if talk in php term wanna include other files connectivity might needed. try { class.forname("com.mysql.jdbc.driver"); system.out.println("driver loading success!"); string url = "jdbc:mysql://localhost:3306/saloon"; string name = "root"; string password = ""; try { java.sql.connection con = drivermanager.getconnection(url, name, password);

html - Link javascript function to Submit button -

this structure of html: <html> <body> <head> ... <script type='text/javascript' src="js/javascript.js"></script> </head> ... <button class="submit" onclick="submitted()">submit</button> </body> </html> my file directory desktop/project/ . within project folder html file on own , there subfolder called js javascript.js exists. within external js file goes this: function submitted(){ ... subtask(variable) ... } function subtask(param){ ... } within submitted() added alert('hello'); first thing , wouldn't trigger alert when refresh html page. doing wrong? change <script> tag to: <script type="text/javascript" src="js/javascript.js"></script> .. means "one directory above current directory".

How to set border at bottom for linear layout programactically in android -

i want set thick border color @ bottom of linear layout programmatically. have found many codes couldn't need. code: linearlayout li=new linearlayout(getactivity()); li.setlayoutparams(new linearlayout.layoutparams(linearlayout.layoutparams.match_parent, linearlayout.layoutparams.wrap_content)); li.setorientation(linearlayout.vertical); thanks. you should create xml file (border.xml) in drawable folder creating border :- <?xml version="1.0" encoding="utf-8"?> <inset xmlns:android="http://schemas.android.com/apk/res/android" android:insettop="-2dp" android:insetright="-2dp" android:insetleft="-2dp"> <shape android:shape="rectangle"> <stroke android:width="1dp" android:color="@color/ora" /> <solid android:color="#d3000000" /> </shape> </inset> and set background dynamically using line

java - Creating PDF document with different page sizes -

i want create pdf document different page sizes. able create document pages of same size. i.e. a4 using htmlworker, pass entire html content input. read same pdf , trying generate response should have different page sizes. response generated has different page sizes...but page content not shown. please suggest missing here. file tempfile = new file(temppdfname); pdfcontentbyte canvas = finalpdfwriter.getdirectcontent(); pdfreader pdfreader = new pdfreader(new fileinputstream(tempfile)); int totalpages = pdfreader.getnumberofpages(); pdfimportedpage page; (int currentpage = 0 ; currentpage < totalpages ; currentpage++) { page = finalpdfwriter.getimportedpage(pdfreader, currentpage); if (currentpage < 2) { canvas.addtemplate(page, pagesize.a4.width(), pagesize.a4.height()); finalpdfdoc.setpagesize(pagesize.a4); finalpdfdoc.newpage(); } else { canvas.addtemplate(page, pagesi

iphone - Xcode 6 beta 2 issue exporting .ipa: "Your account already has a valid iOS distribution certificate" -

Image
i'm having trouble exporting app ad hoc distribution on xcode 6 beta 2: when exporting project ad hoc development on xcode 6, receive alert. i've tried exporting on xcode 5 , had no problems @ saving .ipa. experiencing problem well? this worked me. on machine kept both xcode 5 , xcode 6 beta. from xcode 6 beta, archive project. close xcode 6. open xcode 5, go organizer , export ad hoc build proper provisioning profile. that's it!

node.js - Remove quotes from a json object value -

i using woocommerce api in node js import product data mssql server db woocommerce database. the recordset, getting through ms sql query, contains images field . in woocommerce api, import images need type of json object , var data = { product: { title: 'premium quality', type: 'simple', regular_price: '21.99', description: 'pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. donec eu libero sit amet quam egestas semper. aenean ultricies mi vitae est. mauris placerat eleifend leo.', short_description: 'pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.', categories: [ 9, 14 ], **images: [ { src: 'http://example.com/wp-content/uploads/2015/01/premium-quality-front.jpg', position: 0 },** {

canvas - Android SurfaceView onTouchEvent not getting called -

i'm developing game using surfaceview listens touch events. ontouchevent method in surfaceview works fine many of devices, in devices, doesn't called (moto x style one) , app stops responding. i guess might due overloading of main thread due ontouchevent starving. could android experts on here give me tips reduce load on main thread if it's getting overloaded, or there might other reason may cause this the code quite complex still i'm posting if want go through it gameloopthread public class gameloopthread extends thread{ private gameview view; // desired fps private final static int max_fps = 120; // maximum number of frames skipped private final static int max_frame_skips = 5; // frame period private final static int frame_period = 1000 / max_fps; private boolean running = false; public gameloopthread(gameview view){ this.view = view; } public void setrunning(boolean running){ this.r

javascript - difference between js functions by using parameters -

what's difference between: // example 1 sum(8,2) console.log(sum(8,2)); // outputs what?? // example 2 sum(8)(2) console.log(sum(8)(2)); // outputs what?? function sum(x,y) { return x+y; } function sum(x) { return function(y){ return x+y; } } why 1 used on other , why? what trying called function currying try this: function sum(x) { return function(y) { return x + y; } }; var sumwith4 = sum(4); var finalval = sumwith4(5); finalval = sumwith4(8); one of advantages helps in reusing abstract function. example in above example can reuse sumwith4 add 4 number out calling sum(4,5) explicitly. simple example. there scenarios in part of function evaluated based on first param , other part on second. can create partial function providing first param , reuse partial function repeatedly multiple different second params.

python - Beautifulsoup error with class content Hyphens "-"? -

i used python 2.7 + beautifulsoup 4.4.1 e = beautifulsoup(data) s1 = e.find("div", class_="one").get_text() # successful s2 = e.find("div", class_="two-three").get_text() # error after, looking @ screenshot in comments: first of need read response, cannot directly cast str : e = e.read() second, seems of content being populated using javascript hence html doesn't contain tags. i.e. there no elements present class rating-count : >>> s.find('span', class_='rating-count') [] it doesn't mean hyphenated search class name not working because if try display-price work: >>> s.find('span', class_='display-price') <span class="display-price">free</span> which means ones trying aren't available in html said earlier in comments.

r - How to create function for data.table -

i want create function used data.table. supposed have library(data.table) dt = data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9) foo <- function(data, field, grp){ data[, field, by=grp] } i have tried foo(dt, .n, grp = y) or foo(dt, y) they return errors. how pass input arguments in data.table? you in essence asking reinvent function [.data.table . [ function perform implicit evaluation of second argument, j , in context of datatable. in case of getting counts groups it's just: dt[ ,.n, by=y] y n 1: 1 3 2: 3 3 3: 6 3 had wanted sequences groups have been: > dt[ ,1:.n, by=y] y v1 1: 1 1 2: 1 2 3: 1 3 4: 3 1 5: 3 2 6: 3 3 7: 6 1 8: 6 2 9: 6 3

c++ - What's the differece between of link to a dynamic file and as a input object? -

i use g++ link project (an executable mono_kitti) , project dependent on thirdparty library pangolin. when link action -lpangolin option: g++ -l../../lib -lorb_slam2 -lpangolin mono_kitti.o -o mono_kitti it returns: mono_kitti.o:(.data+0x0): undefined reference `vtable pangolin::handler' mono_kitti.o:(.data+0x8): undefined reference `vtable pangolin::handlerscroll' mono_kitti.o: in function `pangolin::handler::~handler()': mono_kitti.cc:(.text._zn8pangolin7handlerd2ev[_zn8pangolin7handlerd5ev]+0x13): undefined reference `vtable pangolin::handler' mono_kitti.o: in function `pangolin::handlerscroll::~handlerscroll()': mono_kitti.cc:(.text._zn8pangolin13handlerscrolld2ev[_zn8pangolin13handlerscrolld5ev]+0x13): undefined reference `vtable pangolin::handlerscroll' collect2: error: ld returned 1 exit status but when use command: g++ -l../../lib -lorb_slam2 mono_kitti.o /usr/local/lib/libpangolin.so -o mono_kitti it succeeded. but failed again when tr

excel - Sort data by two alternating categories -

Image
i want sort data 2 categories supposed alternate, order 1,0,1,0,1,0,... i have whole dataset , categories 1 , 0 mixed. (e.g. 1,1,1,0,1,0,0,1,...) want sort data set 1 , 0 alternate how can this? not find out how to. paste below formula cell d2 , drag down copy. when sorted d column have binary column sorted 0,1,0,1... etc. =countif(a2:a11,a2)+a2/10 or can use below suggested @dirkreichel: =countif(a$2:a2,a2)+a2/2

localization - Access form ressources from code in VS 2015 (VB.NET) -

good morning, context: have localized vb.net form, called menu.vb localization activated, have multiple ressource files attached, menu.resx, menu.fr-fr.resx... i have added custom string ressources files, , display string in msgbox, depending on culture selected. problem: can't access form ressource within form code. could please me this? thanks lot, maxime use system.componentmodel.componentresourcemanager access form resources: // inside form code - 'this' represents form instance dim resources componentresourcemanager = new componentresourcemanager(this.gettype()) // string want resources.getstring("nameofthestringresource") // optionally can access same specific culture resources.getstring("nameofthestringresource", new cultureinfo("en-us"))

Servlet - web.xml vs Java config -

i'm migrating old project web.xml approach complete java-style servlet 3.0 configuration. but can't understand how translate part of xml configuration in java code. in particular next snippet: <jsp-config> <taglib> <taglib-uri>....</taglib-uri> <taglib-location>....</taglib-location> </taglib> </jsp-config> any hint welcome! as secondary, more academic, question: servlet 3.0 api offer full coverage of xml, or not? stefano, since jsp 2.0, there no need in put <taglib> tag in web.xml. head first servlets , jsp book: the container automatically builds map between tld files , names, when jsp invokes tag, container knows find tld describes tag. how? looking through specific set of locations tlds allowed live. when deploy web app, long put tld in place container search, container find tld , build map tag library. so, have have tld file correct uri. places put tld file:

ElasticSearch Cluster Replication -

i have elasticsearch cluster of 3 nodes. each node can become master , data node. elasticsearch settings are: index.number_of_shards: 8 index.number_of_replicas: 2 gateway.recover_after_nodes: 2 gateway.recover_after_time: 5m gateway.expected_nodes: 3 discovery.zen.minimum_master_nodes: 2 discovery.zen.ping.multicast.enabled: false discovery.zen.ping.unicast.hosts: ["host1", "host2:9200","host3:9200"] cluster , cluster health green. shard allocation node1 - 0,1,2,3,4,6 6 primary , other replicas node2 - 5,6,7 replicas node3 - 0,1,2,3,4,5,7 primary this structure shows 1 replica copy of each shard split on nodes. mentioned 2 replicas in settings should show 2 replica copy of each shard. am understanding wrong or missing in settings. index.number_of_replicas elasticsearch.yml new indices. ones have need adjusted manually: put /_all/_settings { "index": { "number_of_replicas": 2 } } also, please consider upgrad

spring - (Too) complex configuration management (Java properties) -

i'm working @ company having (too) complex configuration management process: in each module there application.properties file. there properties developers like: database.host = localhost properties change in other environments maintained in application.properties file in override-properties folder (for each module) like: database.host=@dbhost@ there default-deployment.properties file default values other environments like: database.host=novalueconfigured.db_host a postconfigure.properties file database_ host=@configure.db_host@ those files needed if property value depends on environments (is different development, testing, live). finally there excel document sheet every environment , row like: configure.db_host - a comment ... - 127.0.0.1 (just example). excel responsible generating correct property files rpm packages. this process not complex error prone. how simplified/improved? the approach should compatbiel spring di. i start master configuratio

javascript - My list becomes crazy after sorting -

i'm creating list editor using angular , jquery ui. goal add/edit/remove/sort items. here's html code display list. <ul id="sortable" > <li ng-repeat="cat in admin.catalogues"> <label for="title">title</label> <input type="text" name="title" ng-model="cat.title" /> <label for="image">image</label><input type="text" name="image" ng-model="cat.image" istype="image" /> <button ng-click="admin.removecatalogue(cat)">remove</button> </li> </ul> then have these angular methods (i have copied should useful). this.catalogues = []; this.addcatalogue = function () { var newcat = { title: "", image: "", pdf: "" }; this.catalogues.push(newcat); }; this.removecatalo

alternate element in json array angularjs -

Image
i'm pushing 2 times different data in array : $scope.numtickets.push({nbuser:data.users[i].name}); so retrieve data in view doing : <ul ng-repeat="user in numtickets track $index"> <li>{{user.nbuser}}</li> <li>{{user.nbticket}}</li> </ul> and few lines after: $scope.numtickets.push({nbticket:data.tickets.length}); and display me this: and want alternate name , number. should have : claire pagniez 1 michel polnaref 1 mathilde zimmer 3 and here array display in console: if see code, can see have no choice push first names , ticketnumber. need sort elements alternate name , ticket. here code controller: $scope.displayuser = function(id) { var token = "xxxxxxxx"; userdisplay .send(token, id) .then(function(data) { console.log(data); $scope.userbyorga = data.users; $scope.numtickets = []; (i = 0; < data.users.length; i++) { var userid = dat

doctrine2 - Symfony 2 & Doctrine: select count and group by return false results -

i have table this id | adkey | ip | created_at 1 | ns0392djej | 127.0.0.1 | 2016-04-25 09:00:00 2 | ns0392djej | 127.0.0.1 | 2016-04-25 09:20:00 3 | ui0392djpo | 127.0.0.1 | 2016-04-25 09:30:00 the goal add new row each time click on advertise on website. my problem when want number of click advertise (the name of advertise adkey column) in example, should ns0392djej ==> 2 ui0392djpo ==> 1 but following request, count 1 first, global getquerybuilder() */ public function getquerybuilder() { $querybuilder = $this->getentitymanager()->createquerybuilder(); $querybuilder ->select('e') ->from($this->getentityclass(), 'e') ->orderby('e.id', 'desc'); return $querybuilder; } then, extend in child class public function getquerybuilder() { $qb = parent::getquerybuilder(); $qb->addselect( $qb->expr()->count('e.id') . &#

facets - Elasticsearch custom Aggregation Result -

in developed training module, there page lists courses table view filterable header. 1 of columns "saved" column "saved" if bookmarked , "unsaved" if not. the course entity indexed below: { "_index": "myindex", "_type": "course", "_id": "248fc0a2-06e1-11e6-b740-000c298fdb4d", "_score": 1, "_source": { "boost_number": 1, "entity_type_number": 64, "course_status_string": "closed", "title": "my test course", "body": "this test course", "created_date": "20160420t101753z", "categories_uuid": [ ], "segment_string": [ "other" ], "vertical_string": [ "other" ], "saved_users_uuid": [ "251bde26-4adf-11e4-b705-000c298fdb4d", "00026884-7cc8-11e3-a570-fa163e2bcb

java - Can different application server implementations share Remote EJBs? -

after reading official java ee docs , after playing openejb, wondering capabilities of different application servers cross-communicate remote ejbs. right now, seems me despite api's standardisation, inter-process communication not standardized, example ejbd protocol seems supported openejb. i in particularly wondering protocols used implementing ejb-based rpcs. until now, believed communication done via http. looking documentations websphere, jboss , tomee, seems every application server cooks own soup. my question therefore: can different application servers communicate via remote ejbs , protocol typically implemented. , why application server tomee offer deriving solution in first place? yes, possible. ejb-spec requires support of corba/iiop. ejb 3.1 spec (chapter 2.5): to interoperability ejb environments include systems multiple vendors, ejb specification requires compliant implementations support interoperability protocol based on corba/iiop remo

google maps - Geo Intent, how to auto launch directions -

currently developing ionic mobile app , have directions button on 1 of pages. currently setting intent this if(address.length !== 0){ address = "(" + address + ")"; } var location = getdrivinglocation(); var url = encodeuri(location.latitude + "," + location.longitude + "?q=" + location.latitude + "," + location.longitude + address); window.location = "geo:" + url + "&z=18"; it launches map , current spot, still need press directions button manually on google maps start directions. there in url can change make auto start? you can try use url scheme, url scheme allows launch ios application ios app. these supported url schemes: comgooglemaps:// , comgooglemaps-x-callback:// - these schemes allow launch google maps app ios , perform 1 of several actions: display map @ specified location , zoom level. search locations or places, , display them on map. request directions 1 location anot

java - How can I access the mapping field directly whilst also having a relationship defined -

@entity @table(name="sometable_citylocation") public class citylocation extends model implements serializable { private int citydestinationid; @manytoone @joincolumn(name="citydestinationid", referencedcolumnname="destinationid") private city city; i have relationship, can cities easy mapping defined, need able set , alter citydestinationid directly because it's supplied me external source. what annotations need able without losing functionality(getting cities object, being able set/alter/get id field/getters/setters) exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'modeldao': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: private org.hibernate.sessionfactory nl.exit.crunch.dao.abstractdao.sessionfactory; nested exception org.springframewor

android layout landscape/portrait with different options -

is there way directly tell android layout resource choose landscape or portrait mode? i know it's simple, put normal "main_layout.xml" in "res/layout" folder , landscape "main_layout.xml" in "res/layout-land" folder. now assume have 2 layouts called "main_layout_blue.xml" , "main_layout_red.xml". user can choose 1 of them , can set appropriate layout. on orientation change again fine. where stuck giving user option set different layouts different orienations "main_layout_blue.xml" portrait mode , "main_layout_red.xml" landscape mode. is there android option explicitly tell system use "res/layout/main_layout_blue.xml" portrait orientation , "res/layout-land/main_layout_red.xml" landscape orientation? missing here? after orientation change, view recreated can check orientation of device following: activity.getresources().getconfiguration().orientation and base

oop - JavaScript - Different ways to construct objects -

while reading other people's source code , various articles on web, found when different people use "object-oriented-style" programming in javascript, quite differently. suppose, want create tiny module having 1 property , 1 function. i've seen @ least 4 approaches task: // option 1 var myobject1 = { myprop: 1, myfunc: function () { alert("myprop has value " + this.myprop); } }; // option 2 var myobject2 = function () { return { myprop: 1, myfunc: function () { alert("myprop has value " + this.myprop); } }; }(); // option 3 var myobject3 = function () { this.myprop = 1; this.myfunc = function () { alert("myprop has value " + this.myprop); } }; var myobject3 = new myobject3(); // option 4 var myobject4 = function () { }; myobject4.prototype.myprop = 1; myobject4.prototype.myfunc = function () { alert("myprop has value " + this.myprop); }; var myobject4 = new myobject4(); all th