Posts

Showing posts from May, 2010

jsp - sending an AJAX post request to another page -

i'm newbie in web development , problem when click on "my link"it gives me "bad request" because of huge number of variables in ids. -how should change code send post request? -any better solution handle case? thank you <!doctype html "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <%@page contenttype="text/html" pageencoding="utf-8"%> <% string var3 = request.getparameter("var3"); string var4 = request.getparameter("var4"); string var5 = request.getparameter("var5"); %> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>title</title> <link rel="stylesheet" href="../style.css"/> <link rel="stylesheet" href="../common/css/cupertino/jquery-ui-1.8.4.custom

pom.xml - How to access system properties passed with -D switch in maven -

i using android-maven-plugin writing uiautomator test cases. project works different clients , need send client's name string program, selected cleint's app tested. here code expecting client's name @override protected void setup() throws exception { super.setup(); uiautomatorutils.unlockemulator(); string launcherstring = /* needed way access client's name string" */ assertnotnull("launcherstring not provided", launcherstring); applauncher.launchapplicationfromdesiredlauncher(launcherstring); uiautomatorutils.setcurrenttestname("loginlogout"); } how can achieve this. tried pass argument command line this: mvn install -dlauncher=xyzclient , value in setup() system.getproperty("launcher"). not working. i want know best approach challenge? imho not practice test case pull such dynamic value outside. not know how build maven project if such property required specif

Java BufferedWriter isn't working -

im having problem bufferedwriter. reading in 50,000 word wordlist, using stemming algorithm , creating new wordlist contains word stems. instead of new file containing stems litrally contains: - here code: public static void main(string[] args) { bufferedreader reader=null; bufferedwriter writer=null; try { writer = new bufferedwriter(new filewriter(new file("src/newwordlist.txt"))); hashset<string> db = new hashset<string>(); reader = new bufferedreader(new inputstreamreader(new fileinputstream("src/wordlist"),"utf-8")); string word; int i=0; while ((word=reader.readline())!=null) { i++; stemmer s= new stemmer(); s.addword(word); s.stem(); string stem =s.tostring(); if(!db.contains(stem)){ db.add(stem); writer.write(stem); //system.out.println(stem);

oracle - Where to look on error SP2-0317 Expected symbol name is missing -

i have oracle procedure , getting error. when online, following helpful message: cause: sql*plus expecting symbol, not specified. actions: check syntax of command used correct options. those actions pretty nebulous. check symbols, where? begin resolve error? (i've found answer, because appears have caught others on team too, wanted post question , answer here. post code, when still looking, didn't know in code look, couldn't cut down manageable size, , posting proprietary code not appropriate. plus, turned out problem in comments, not in code @ all.) may have comments or may output string contain '&' sign. '&' should followed substitution variable in sql* plus

jquery - Why isn't my javascript function defined for this function? -

this consistent, firebug showing saveform function not being defined form 'button.save' event handler, works 'button.deleteform' event handler: function saveform(form) { var $form = form; var url = $form.attr('action'); $.ajax({ type: "post", enctype: 'mutipart/form-data', url: url, data: $form.serialize(), // serializes form's elements. success: function(data) { // data server response. // change function tell // user whether submission // correct or fields have // bad data. var response = json.parse(data); return true; } }); return false; // avoid execute actual submit of form. } // not use event handlers .click(). // viable

login - How to fetch the username of a person logged into a JSP webapp using the memoryrealm? -

so have simple jsp web app running composed of several .jsp files, , protect using memoryrealm system asks username , password upon entering of .jsp pages, , remembers session, until browser closed. question is, how fetch username of person show him on 1 of pages? p.s. running webapp on apache tomcat 7.0.35 // username. string user = request.getremoteuser(); // user principal. string userprincipal = request.getuserprincipal().getname(); // user in specific role? boolean isuserinrole = request.isuserinrole(role); boolean isuserinjsprole = request.isuserinrole("jspuser"); from: http://sourceforge.net/apps/trac/ogsa-dai/wiki/faqhowtopasswordprotectjsppages

jquery - how to change Div based on another div -

my code this: #border-content3 { margin: 15px auto; padding: 1%; position: relative; float: left; } #right-menu { min-width: 150px; margin: 15px auto; padding: 1%; position: relative; font-family: tahoma, geneva, sans-serif !important; font-size: 12px !important; float: right; } and html code this: <div id="right-menu"> </div> <div id="border-content3"> <input name="test" class="test" id="test" value="a" type="checkbox" /> </div> i try moving checkbox on right menu,but not work this $('#test').css("position","absolute"); $('#test').css("z-index","3000")); $('#test').animate({left:'400'},1000)); please me moving select element on right menu jquery you have 3 typos in code. 2 ) , , missing px $('#test').css(&qu

jquery - Send JSON data to PHP and use it -

i have issue sending json data ajax php file , use upload server. if i'm making echo of variable $email_info->name returned data value empty. i've tried json_decode doesn't it. this code have, jquery: $( document ).on('click', '#send_touch', function(){ new_email = []; new_email.push({ name: $('#name').val(), phone: $('#phone').val(), email: $('#email').val(), interested_in: $('#interested_in').val(), user_id: $('#email_user_id').val() }); new_email = json.stringify({email: new_email}, null, "\t"); $.ajax({ url: "core.php", type: "post", data: { newmail: new_email }, success: function(data){ alert(data) }, error: function(){ } }); }); php: if ($_post['newmail']) { $timesta

regex - Get digit from filename immediately preceeding file extension, with other digits in filename -

i'm trying extract last number before file extension in bash script. format varies it'll combination of numbers , letters, , last character digit. need pull digits , store them in variable. the format generally: sdflkej10_sdlkei450_sdlekr_1.txt i want store final digit 1 variable. i'll using loop through large number of files, , last number double , triple digits. so file: kej10_sdlkei450_sdlekr_310.txt i'd need return 310. the number of alphanumeric characters , underscores varies each file, number want before .txt extension , after underscore. i tried: bname=${f%%.*} number=$(echo $bname | tr -cd '[[:digit:]]') but returns digits. if try number = $(echo $(bname -2) changes number returns. the problem i'm having related variability, , fact i've been asked in bash. appreciated. regex='([0-9]+)\.[^.]*$' [[ $file =~ $regex ]] && number=${bash_rematch[1]} this uses bash's underappreciated =~

$.fancybox.close() not working after getting ajax response -

i opening fancybox using following method $.fancybox({ 'href': urlvariable, 'width': 200, 'height': 200, 'autodimensions': false, 'hideoncontentclick': false, 'showclosebutton': false, 'oncomplete': function() { /*this method close button close fancybox method works expected*/ $("a.close").on("click", function() { $.fancybox.close(); }); } }); inside first fancybox i've form , submit via ajax , when response, want close fancybox , open new 1 using similar method before opening fancybox ve tried close first 1 using below method not working expected $.fancybox.close() but method not working. second fancybox not getting triggered.

c# - Passing Type to to method with generics -

hi tryng create generic wrapper around unity enable me change ioc frameworks whenever want without need of public static void registertypes(idependencyinjectioncontainerwrapper container) { list<type> types = loadtypesfromassemblies(); foreach (var type in types) { var interfacetype= type.customattributes .firstordefault(a => a.attributetype.name == typeof(dependencyservice).name) .constructorarguments[0].value; container.registertype<type, interfacetype>(); } } what's happening here getting list types attribute dependencyservice applyed. then iterate on , getting first constructor argument of attribute. i attempting register type in container threw generics.this having problems. i not know how pass 2 types have in registertype method generics.as stands getting errors because passing in generic variable not object type is

c# - Guid format is not Recognised -

i error in dropdownlist when it's converting string guid. stack trace: @ system.guid.guidresult.setfailure(parsefailurekind failure, string failuremessageid, object failuremessageformatargument, string failureargumentname, exception innerexception) @ system.guid.tryparseguid(string g, guidstyles flags, guidresult& result) @ system.guid..ctor(string g) @ projects_addproject.wizcreateproject_activestepchanged(object sender, eventargs e) @ system.web.ui.webcontrols.wizard.onactivestepchanged(object source, eventargs e) @ system.web.ui.webcontrols.wizard.multiviewactiveviewchanged(object source, eventargs e) @ system.web.ui.webcontrols.multiview.onactiveviewchanged(eventargs e) @ system.web.ui.webcontrols.multiview.set_activeviewindex(int32 value) @ system.web.ui.webcontrols.wizard.set_activestepindex(int32 value) @ projects_addproject.proxy_navigate(object sender, historyeventargs e) @ system.web.ui.scriptmanager.raisenavigate(historyeventargs e) @ system.web.ui.script

ruby on rails - Globalize3 and creating object in all languages -

i have model named menu has product_types belong it. upon creation of menu want set default product_types: i have constant: defaults = [ { name_en: 'white bread', name_nl: 'wit brood', name_fr: 'pain blanc'}, { name_en: 'brown bread', name_nl: 'bruin brood', name_fr: 'pain brun' } ] and should create translations error @ moment saying: "you cannot call create unless parent saved" def create_defaults producttype::defaults.each |pt| t = product_types.create t.translations.create(locale: 'en', name: pt[:name_en]) t.translations.create(locale: 'nl', name: pt[:name_nl]) t.translations.create(locale: 'fr', name: pt[:name_fr]) end the menu can in 3 languages (selectable user) , user has default language. default language can dutch, english or french. it's possible have dutch user languages of menu in dutch , french. the code tried before (that didn't give er

axapta - X++ loop through lines in grid control -

so idea assign icon window control in grid control of form (purchtable), depending on whether record has document attached it. i use select statement check docuref if there match between refrecid , current recid. so question is, how assign different icon each line? can't figure out :/ i'm guessing wrote display method similar method showdochandicon on table inventtestgroupmember. in case, need return icon resource number depending on data of current line. example lines contain enum field , enum has 3 values 1, 2 , 3 , values 1 , 2 want return icon 1 , value 3 want return icon 2. btw, wrote check if there match between refrecid , recid. please consider checking refdataareaid , reftableid, since refrecid may not unique in table docuref.

javascript - PhoneGap Android: Google map api v3 showing blank screen -

i building webapp using phonegap cordova 2.9.0. app developed working fine in desktop browser when try run app in android device (after getting build using build_tool shows first alert generated javascript. after blank white screen appears nothing else. the link app source @ link . in app trying users current location using navigator.geolocation the app aims show available bitcoin trade places in google map withing given radius of user location. app can downloaded using link . update: i able geolocation points , show them in alert, wehn try render them on map marker, map not rendering on android device. (working on desktop browser) index.html <!doctype html> <html> <head> <title>tittle</title> <script> window.location='./main.html'; </script> <body> </body> </html> main.html <!doctype html> <html> <head> <title>coinmap</title> <meta char

asp.net mvc - ReturnUrl Duplicating Parameters - MVC 4 -

i'm having problem retunurl duplicating querystring parameters. my url like: "www.mysite.com/order/?id=1&item=123" then, redirect me login page , url like: "www.mysite.com/login/redirecturl=/order? id=1&item=123&id=1&item=123 " after user login, action redirect to: "www.mysite.com/order/? id=1&item=123&id=1&item=123" in page when use request.querystring["id"] got error, because querystring "id" duplicated. my login action code this: [httppost] [allowanonymous] public actionresult index(loginmodel model, string returnurl) { if(verifylogin(model)) { if(returnurl != null) return redirect(returnurl);//redirect url duplicated parameters else return redirect("/home"); } else { modelstate.addmodelerror("", "invalid username or password"); } return view(); } how can solve problem? i

c# - Combine List and ObservableCollection -

i have wpf application contains datagrid bound list. list implements inotifypropertychanged interface. can see when property has changed. when new item added or deleted there no event tell me has happened. after reading have seen observablecollection can tell me when item has been added or deleted via collectionchanged event. observablecollection has few short comings list overcomes. so question if it's possible combine list & observablecollection have functionality of both? possible have list inherit from? if there methods need overwritten? the simple answer question 'yes, work'. the observablecollection<t> class extends collection<t> class, implements ilist<t> , icollection<t> , ienumerable<t> , ilist , icollection , ienumerable interfaces - same list<t> class. however, observablecollection<t> class implements inotifycollectionchanged , inotifypropertychanged interfaces, these main difference between

xampp - Can't load localhost in Chrome after enabling Intranet Browsing in IE10 -

just title says. using xampp. i testing local site in ie10 , told me needed enable intranet browsing. did. went chrome test local site , won't load localhost anymore. is there way can have both loading locahost in harmony? firefox works fine, way. see: enabling intranet browsing ie10 . switch off enhanced protected mode enhanced protected mode should not enabled default; uses 64-bit content processes , disables various controls. if necessary, switch off in cog/tools > internet options > advanced > security section [...] then: assuming you’ve enabled intranet browsing, click security tab followed “local intranet” icon. ensure “enable protected mode” unchecked [...] configure intranet mode add local addresses if automatic detection of local addresses doesn't work, manually add local addresses should part of intranet network (so, you, localhost , 127.0.0.1 , etc... feels silly, eh? disable compatibility view by default, ie ena

ImageMapster: How to make the tooltip follow the mouse -

i wondering if there way make tooltip not appear @ corner of area, instead above wherever mouse is. need "follow" mouse while it's active. if has sample code doing thankful. for each area add unique id, check mouseenter or mouseover area , mouse position , reposition tooltip: <map id="map" name="map"><area id="area1" shape="poly" name="area1" alt="" coords="607,320, 620,321,....... var xoffset; var yoffset; $('#map_container').mapster( { fillopacity: 0.2, fillcolor: "ffffff", stroke: true, strokecolor: "ffcb0b", strokeopacity: 0.8, strokewidth: 6, singleselect: true, mapkey: 'name', listkey: 'name', showtooltip: true, onclick: function (e) { // }, tooltipclose: ["area-click", "area-mouseout"], staticstate: true, onshowtooltip: function (e) {

c# - creating proxy using wsdl programmatically and wsdl parsing -

i working on xml web services. client web service "client" has url of wsdl of server web service "service" @ run time. in order "client" use "service" need following thing "programmatically": 1) wsdl file on fly "service" or location on disk. 2) create proxy programmatically i.e not using wsdl.exe or add web reference. 3)invoke methods on created proxy. is possible it? if 1 has done greatful take suggestions how accomplish. using system; using system.collections.generic; using system.text; using system.reflection; using system.codedom; using system.codedom.compiler; using system.security.permissions; using system.web.services.description; namespace connectionlib { public class wsproxy { [securitypermissionattribute(securityaction.demand, unrestricted = true)] public static object callwebservice(string webserviceasmxurl, string servicename, string methodname, object[] args) {

c# - Getting compilation error with method: "not all code paths return a value" -

i can't figure out why keep getting compilation error: "not code paths return value". writing simple class method supposed return true if account available use , false if account not available or null/empty. code method below: public static bool accountavailable(int accountid) { try { bool accountavailable; string querytransaction = "select count(accountid) accounts accountid = " + accountid.tostring() + " , accountused = 0"; //grab connection database database database = databasefactory.createdatabase(); //create instance of command dbcommand command = database.getsqlstringcommand(querytransaction); object dataobject = command.executescalar(); if (dataobject == null || string.isnullorempty(convert.tostring(dataobject))) { accountavailable = false; } else if (convert.toint32(dataobject) == 0) { accoun

spring - java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V -

below pom.xml of spring batch project , below exception if deploy in jboss 5 , same war works fine if deploy in local windows machine. suspect there conflict in jar respect org.springframework:spring-context:jar:2.5.6 . even tried excluding spring core jar in spring batch dependency, couldn't resolve can in advance.is there way exclude spring-context:jar:2.5.6 error trace java.lang.nosuchmethoderror: org.springframework.web.context.configurablewebapplicationcontext.setid(ljava/lang/string;)v @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:369) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:284) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:111) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:3910) @ org.apache.catalina.core.standardc

objective c - Trying to make this work... (Xcode for mac NOT iPhone) - ArrayController -

i'm writing stopwatch application mac, , working on 'laps' feature. putting laps table view better organization. i'm using array controller put things table. basically, i'm trying this: [arraycontroller addobject: [nsmutabledictionary dictionarywithobjectsandkeys:@"lap 1", @"lapnumber", nil]]; that works fine , dandy, i'd able control number next lap using integer representing number of laps, called numlaps. thus, code be: [arraycontroller addobject: [nsmutabledictionary dictionarywithobjectsandkeys:@"lap %i", numlaps, @"lapnumber", nil]]; however, more 2 commas before nil, think program getting screwed up. getting following thrown in console, though don't understand means / how fix it: 2013-09-03 16:52:31.515 popup[3242:303] +[nsmutabledictionary dictionarywithobjectsandkeys:]: second object of each pair must non-nil. or, did forget nil-terminate parameter list? 2013-09-03 16:52:31.519 popup[3242:303

asp.net mvc 4 - VS2012 NuGet update causing cryptic warnings on build -

the recent visual studio 2012 update seems have broke in build. think has last week's nuget update. nuget package restore started. packages installed , there nothing restore. nuget package restore finished. 1>------ rebuild started: project: project1, configuration: debug cpu ------ 1> consider app.config remapping of assembly "microsoft.data.odata, culture=neutral, publickeytoken=31bf3856ad364e35" version "5.2.0.0" [] version "5.6.0.0" [c:\users\avianbc\desktop\project1\packages\microsoft.data.odata.5.6.0\lib\net40\microsoft.data.odata.dll] solve conflict , rid of warning. 1> consider app.config remapping of assembly "microsoft.data.edm, culture=neutral, publickeytoken=31bf3856ad364e35" version "5.2.0.0" [] version "5.6.0.0" [c:\users\avianbc\desktop\project1\packages\microsoft.data.edm.5.6.0\lib\net40\microsoft.data.edm.dll] solve conflict , rid of warning. 1> consider app.config remapping of assembl

java - Spring MVC Date Validation jsr303 today or greater than today -

i have field : private date effectivedate; i intend use jsr303 validation , need validate date today or greater today. i unable find annotation this. i came across @past , @future need @todayorfuture is there such existing annotation or require custom annotation? all inputs appreciated. thanks

mtu - TCP file Transfer window size -

i'm trying reverse engineer application, , need understanding how tcp window size works. mtu 1460 application transfers file using tcp point b. know following: the file split segments of size 8k each segment compressed then each segment sent point b on tcp. these segment text file can of size 148 bytes, , pdf 6000 bytes. for text file, supposed see segments of 148 attached 1 form 1 large tcp stream? , split according window size? any appreciated. the receiver application should see data in teh same way, sender application sent it. tcp uses byte-streaming , collects bytes in in-order manner , delivers application. mtu largely internal semantics tcp , not take application-layer packet boundaries. if tcp has enough data send in send buffer (each tcp socket has own send buffer, btw), package next segment worth mtu size , sends it; more precise, deducts tcp , ip header mtu size.

jsf - Richfaces placeholder not working -

i'm using jsf 2.0 , i'm trying use richfaces 4.3's placeholder. here's jsf code <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jstl/core" xmlns:rich="http://richfaces.org/rich"> .... .... <h:form> <table> <thead> <tr> <th> <h:outputtext value="header"/> </th> </tr> </thead> <tbody> <tr> <td> <h:inputtext id="first" value="#{bean.firstvalue}"> <rich:placeholder value="fill me"/> </h:inputtext>

c# - Initiate jagged list -

i trying make jagged list. gets filled values depending on 2 variable int's: rows, , cols. the pattern have list filled when rows = 4 , cols = 3: 00, 10, 20, 01, 11, 21, 02, 12, 22, 03, 13, 23 each double digit sub-list containing column, , row. have: namespace windowsformsapplication11 { public partial class form1 : form { public form1() { initializecomponent(); definecellpositionslist(); displaycellpositionslist(); } int rows = 4; int cols = 3; private list<list<int>> cellpositionslist = new list<list<int>>(); private void definecellpositionslist() { (int = 0; < (rows * cols); i++) { list<int> sublist = new list<int>(); (int row = 0; row < rows; row++) { (int col = 0; col < cols; col++) {

php - Detect if mysql or mysqli is being called for connection -

is there way check type of mysql connection being called mysql or mysqli . want have if statement call mysql or mysqli connection until can change out coding. this current connection file. duplicating what's below mysqli accomplish i'm trying do? $dbc = mysql_connect ($db_server, $db_user, $db_pass); mysql_select_db ($db_name) or die(mysql_error()); $g_link = false; function getdbconn() { global $g_link; if( $g_link ) return $g_link; $g_link = mysql_connect( 'localhost', 'username', 'password') or die('could not connect server.' ); mysql_select_db('social_db', $g_link) or die('could not select database.'); return $g_link; } function cleanupdb() { global $g_link; if( $g_link != false ) mysql_close($g_link); $g_link = false; } you can use get_resource_type function: if(is_resource($g_link) &am

class - ruby: Trouble understanding classes and defining variables with @ -

i doing rspec tutorial , having difficulties reading tests. current test trying read is: describe book before @book = book.new end describe 'title' 'should capitalize first letter' @book.title = "inferno" @book.title.should == "inferno" end i can understand asking me do: create class book , method inside class capitalize. thoughts on how code wrong (i have seen example of code works in case) what tried do: class book def initialize(book) @book = book end def title(@book) @book.capitalize end end solution ended working: class book attr_reader :title def initialize(title=nil) @title = title && title.capitalize! end def title=(new_title) @title = new_title && new_title.capitalize! end end i not understand @ does. thought create variable works throughout entire class. in addition, wondering why @title used instead of @b

java - how would you format this to string -

i have public string tostring() { string s = ""; (int r = 0; r != 7 ; r++) { (int c = 0; c != 7 ; c++) { s += string.format("%02d " ,board[r][c]); } } return s; } and need return this 01 04 39 20 53 06 37 22 40 19 02 05 38 21 52 07 03 46 61 00 57 54 23 36 18 41 56 49 60 00 08 51 47 14 45 58 55 50 35 24 42 17 48 27 00 59 32 09 13 28 15 44 11 30 25 34 16 43 12 29 26 33 10 31 how can that? your adding space ever line never new line char public string tostring() { string s = ""; (int r = 0; r != 7 ; r++) { (int c = 0; c != 7 ; c++) { s += string.format("%02d " ,board[r][c]); } s += string.format("%n"); } return s; } %n platform independent new line char

ruby on rails - Rails3 ActiveRecord Transactions after_commit on multiple actions -

according the documentation can define same method executed after commit of type create or update: after_commit :do_foo_bar, :on [:create, :update] well, code results in parsing error me: can't convert symbol integer i change this: after_commit :do_foo_bar, :on => [:create, :update] i no errors, nothing happens! further investigation @ logs show me silent , strange error: /home/nuno/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:404: syntax error, unexpected '[', expecting tstring_content or tstring_dbeg or tstring_dvar or tstring_end ...(transaction_include_action?(:[:create, :update])) ... ^ /home/nuno/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:412: syntax error, unexpected keyword_end, expecting ')' /home/nuno/.rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:413: syntax error, unexpected $end, exp