Posts

c# - Binding in winform like in WPF -

i want bind winform's form's width property text on label label's text gets updated every mouse movement made. achieved updating when element on form clicked not continious updating(like if change text in resize handler). how thing? you can bind width property doing this: label1.databindings.add(new binding("text", this, "width")); the problem there form isn't notifying framework property has changed. easiest best bet meat , potatoes way: protected override void onresize(eventargs e) { base.onresize(e); label1.text = this.width.tostring(); } edit: okay, if want use data binding, here way works (but reaching around head scratch ear): add object data source form , set datasource type "system.windows.forms.form". next, add code: public form2() { initializecomponent(); this.formbindingsource.datasource = this; binding binding = new binding("text", this.formbindingsource, "size"...

c# - Set Copy to Output folder by code -

i developing code generation tool, project files(.csprj) created code. there way mark content file copied output directory? ... var project = new buildengine.project(); project.load(projectfile.fullname, projectloadsettings.ignoremissingimports); var builditem = project.addnewitem("content", filename); ... need builditem.copytooutput=true ... project.save(projectfile.fullname); every ideas welcome. thank you. try builditem.setmetadata("copytooutputdirectory", "always");

performance - Persistence.createEntityManager() painfully slow with Hibernate -

i'm having huge performance issues eclipse rcp application, apparently caused hibernate. more specific, application takes extremely long start (up 2 minutes) - profiling , debugging showed creating hibernate/jpa entitymanagerfactory (which happens @ startup) takes extremely long. i've played around lot settings, such using file database rather in-memory , not using hbm2ddl, without success. has ever experienced problems these? i'm using jdk 1.6.20, hibernate 3.5 , hsqldb 1.8 (in-memory configuration). below persistence.xml: <?xml version="1.0" encoding="utf-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0"> <persistence-unit name="my_db" transaction-type=...

java - why are struts Action classes not thread safe? -

i can read in many websites struts action classes not thread safe . not able understand why . also read book says "struts action classes cached , reused performance optimization @ cost of having implement action classes in thread-safe manner" how caching action classes , being thread safe related? . how caching action classes , being thread safe related? if cache , re-use instances of class, allowing multiple threads access same instance simultaneously, class inherently not thread-safe*. if place mutable instance or static fields on class, results under concurrency unexpected , problematic. on other hand, if each thread has own instance of class, class inherently thread-safe. struts 1 action classes not thread-safe. should not place mutable fields on class, instead using form bean class form fields passed action. struts 2 action classes thread-safe. new copies instantiated each request , placing instance fields on class core concept in framework. ...

Google Website Optimiser Control Javascript -

could explain javascript makes google's website optimiser control script? specifically: first 2 lines, seem empty functions, , why third function wrapped parentheses () ? as far can tell script writing out new <script> presumably loads a/b testing. function utmx_section(){} function utmx(){} (function() { var k='0634742331',d=document,l=d.location,c=d.cookie; function f(n) { if(c) { var i=c.indexof(n+'='); if (i>-1) { var j=c.indexof(';',i); return escape(c.substring(i+n.length+1,j<0?c.length:j)) } } } var x=f('__utmx'),xx=f('__utmxx'),h=l.hash; d.write('<sc'+'ript src="'+'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime=...

postgresql - SQL UNION Question -

can explain me why sql statement: select 'test1' union select 'test2' union select 'test3' returns: test2 test3 test1 i trying figure out logic behind union keyword in aspect. there way return: test1 test2 test3 without using order by clause? in other words, can control execution order of union statements? if matters, using postgre 9.0 , php language many thanks, brett according postgresql docs union : union appends result of query2 result of query1 ( although there no guarantee order in rows returned ).

ruby on rails - Chrome browser can't find partial -

i use following in controller add tasks project model using ajax. def task_add project = project.find(params[:project]) @task = projecttask.new(:description => params[:description]) project.project_tasks << @task render :partial => 'task' end and ajax call: $('#task-add').click(function(){ var taskdesc = $('#task-description').val(); $.ajax({ type: "post", url: "/project_task_add", data: ({project:<%= @project.id %>, description:taskdesc}), success: function(data){ var data = $('<div/>').append(data); $('#tasks').append($('#new-task', data).html()); } }); }); it works fine in firefox chrome gives following error: failed load resource: server responded status of 500 (internal server error) digging deeper in chrome dev tools find following response: <h1>template missing<...