Posts

java - Getting the Object Calling a Method -

in java, how can object calling method, within method calling, if method in class? have looked on internet , no solution. please help? the way can think of pass this method, static void somemethod(object o) { system.out.println(o); } void testit() { somemethod(this); // <-- pass current instance method. }

scala - build.sbt defining project dependency between modules -

i have project in playframework. has 1 main project without code/logic. , have few submodules: main: admin common shop modules: admin , shop base on common module (classes like: user, role, permission), have configure way: lazy val shop = project.in(file("modules/shop")) .dependson(cirs) .dependson(common) .dependson(admin) lazy val admin = project.in(file("modules/admin")) .dependson(cirs) .dependson(common) .dependson(shop) but in module common have view wonna display links (a href...) other submodules. have use reverse routing classes, wich controllers in submodules: shop , admin. have use that: <a href="@controllers.shop.routes.index.index">shop</a> <a href="@controllers.admin.routes.index.index">admin</a> wich mean have add .dependson(shop).dependson(admin) common module. but cause cyclic dependencies, wich incorrect! please me. how can deal it?

java - Serve static resources from within a compressed file using Spring -

is possible serve static resources within compressed file using spring mvc? this . i have data packaged individual json files (e.g. 123.json, 1634.json, etc.) , and serving them via <mvc:resources mapping="/resources/**" location="/resources/" /> the files under .../resources/datafiles/ . user can go http://mywebsite.com/resources/datafiles/123.json retrieve data entity 123. however, have ~10,000 json files. great if compress them under 1 file ( .../resources/datafiles/entities.zip ) , tell spring serve individual json files within compressed file. so user still go http://mywebsite.com/resources/datafiles/123.json file under .../resources/datafiles/ entities.zip. i'm using tomcat 7.0 if question outside scope of mvc framework. i'm not sure if there's spring out-of-the-box component that, can create independent servlet handle incoming requests static resources, servlet parse file name, , dynamically read zipped file corre...

python - How to dynamically add items to jinja variable in Flask? -

i'm building website using flask jinja2 templating engine , i'm dynamically building menu ( as described here ): {% set navigation_bar = [ ('/', 'index', 'home'), ('/aboutus/', 'aboutus', 'about us'), ('/faq/', 'faq', 'faq') ] %} {% set active_page = active_page|default('index') -%} <ul> {% href, id, title in navigation_bar %} <li{% if id == active_page %} class="active"{% endif %}> <a href="{{ href|e }}">{{ title|e }}</a> </li> {% endfor %} </ul> now if user logged in want show additional things. @ runtime want add items navigation_bar variable. tried this: {% if g.user.is_authenticated() %} {% navigation_bar.append(('/someotherpage', 'someotherpage', 'someotherpage')) -%} {% endif %} but unfortunately results in following error: templatesyntaxerror: en...

asp.net - How to Upload .aspx websites onto APACHE Tomcat -

i have created website has extension of .aspx using microsoft expression web 4 , need upload onto out apache tomcat server. there can guide me how this? i host websites on windows web hosting. click on link below , click on link mono-project see if you. http://www.c-sharpcorner.com/forums/thread/167026/how-to-deploy-asp-net-app-on-tomcat-apache.aspx

jquery - JavaScript to detect bottom of page does the reverse on Chrome -

i'm trying infinite scrolling page, condition test if we're @ bottom of page not behaving correctly on chrome. on chrome alert seems trigger @ top of page rather when hitting bottom. works correctly on ie11 though. on chrome $(document).height() equals 0. have <!doctype html> html @ top of page if matters. oddly took example worked within jsfiddle on chrome: http://jsfiddle.net/nick_craver/gwd66/ $(window).scroll(function () { if ($(window).scrolltop() + $(window).height() == $(document).height()) { alert("test"); } } } what kind of css applied page, more body element? padding or margin making $(document).height() equal more combination of $(window).scrolltop() , $(window).height(). following code determine if ever meeting if() criteria. what version of jquery using? $(window).scroll(function() { var scrollposition = $(window).scrolltop() + $(window).height(); var bodyheight = $(document).heigh...

Convert for loop/print output to string? Python -

def reveal(): guessright = 0 letter in secretword: if letter == usertry: guessright = guessright + 1 print usertry, else: print "_", return guessright reveal() when using reveal() _ _ _ _ _ printed loop- there way of converting prints string, or getting function return 2 outputs, integer guessright, , stuff printed while reveal() running? sure, there lots of ways -- simplest use list hold data (appending new data rather printing) , ''.join @ end: def reveal(): text = [] guessright = 0 letter in secretword: if letter == usertry: guessright = guessright + 1 text.append(usertry) else: text.append('_') return guessright, ''.join(text) reveal() here return tuple python's way of returning multiple values. can unpack tuple in assignment if wish: guessright, text = reveal()