Posts

javascript - Determining what jQuery .ajax() resolves a string of redirects to -

i'm aware redirects followed automatically, , have little/no control on process. fine, i'm still interested in request ends up. possible see url request ends at? i not want rely on returned html tell me am. sample code: var originalurl = '/this/will/be/redirected'; $.ajax({ url: originalurl, datatype: "html", success: function(data, statustext, jqxhr) { var endpointurl = insertmagichere(); alert("our query " + original + " ended @ " + endpointurl + "!"); } }); i'm looking around in jqxhr it, no luck far. (though, i'm new this, right under nose) so far know (and have testet) possible detect if there has been redirect , how many redirects made (but not where). you can have code: var xhr = $.ajax({ url: originalurl, datatype: "html", success: function(data, statustext, jqxhr) { console.log(data); console.log(statustext); console.log(jqxhr....

android - generate main.xml inside onCreate() -

is possible generate main.xml inside oncreate()? such as: package avm.project; import java.io.bufferedwriter; import java.io.file; import java.io.filewriter; import java.lang.reflect.field; import android.app.activity; import android.content.res.resources; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.button; import android.widget.viewflipper; public class avmordersystemactivity extends activity { viewflipper flipper; @override public void oncreate(bundle icicle) { super.oncreate(icicle); //file[] listoffiles = folder.listfiles(); /*for (int = 0; < listoffiles.length; i++) { if (listoffiles[i].isfile()) { log.i("xml generator","file " + listoffiles[i].getname()); } else if (listoffiles[i].isdirectory()) { log.i("xml generator","directory " + listoffiles[i].getname()); ...

Unexpected end of Pattern : Python Regex -

when use following python regex perform functionality described below, error unexpected end of pattern. regex: modified=re.sub(r'^(?i)((?:(?!http://)(?!testing[0-9])(?!example[0-9]).)*?)(?-i) (code[0-9]{3})(?!</a>)',r'<a href="http://productcode/\g<1>">\g<1></a>',input) purpose of regex: input: code876 code223 matchjustcode657 code69743 code876 testing1code888 example2code098 http://replaced/code665 should match: code876 code223 code657 code697 and replace occurrences with http://productcode/code876 http://productcode/code223 matchjusthttp://productcode/code657 http://productcode/code69743 should not match: code876 testing1code888 testing2code776 example3code654 example2code098 http://replaced/code665 final output http://productcode/code876 http://productcode/code223 matchjusthttp://productcode/code657 http://productcode/code69743 code876 testing1code888 example2code098 http://replaced/code665 edit ...

seam - JSF: Button/Link without form submit -

in earlier projects used s:button or s:link seam 2 when caceling something, because wouldn't submit form , no model updates occured. now switched weld + seam 3 , couldn't find there anymore - blind or have use else? geziefer you can in plain jsf 2.0 setting immediate attribute true in h:commandbutton . from myfaces wiki: the immediate attribute can used achieve following effects: allow commandlink or commandbutton navigate user page without processing data in input fields of current screen. in particular, allows navigation occur when there validation errors. "cancel" button typically falls category. allow commandlink or commandbutton trigger back-end logic while ignoring validation of fields on screen. more general version of item above. make 1 or more input components "high priority" validation, if of these invalid validation not performed "low-priority" input components in same page. can...

android - Problem finding/reading a file -

i'm trying develop small application, given json file, , have extract data it. understood json object takes string argument, i'm trying access file , write data string. i've placed file in "json file" folder, , when try read file, throws me file not found exception. i've tried several ways find path file, every attempt vain. might i'm extracting path wrong, or might else, please me. in advance. here code of finding path: try { path = environment.getrootdirectory().getcanonicalpath(); } catch (ioexception e) { e.printstacktrace(); //to change body of catch statement use file | settings | file templates. } file jfile = new file(path + /"json file/gallery.json"); here code reading file : string str =""; try { bufferedreader in = new bufferedreader(new filereader(jfile)); ...

silverlight - When does a PhoneApplicationPage get disposed? -

for example, if have page this: public partial class page1 : phoneapplicationpage { dispatchertimer timer = new dispatchertimer(); public page1() { initializecomponent(); timer.interval = timespan.fromseconds(5); timer.tick += new eventhandler(timer_tick); timer.start(); } void timer_tick(object sender, eventargs e) { messagebox.show("timer tick"); } } in app, navigate page, pop message box every 5 seconds. press "back" button on phone , navigate previous page. weird thing still pops message box every 5 seconds. know can stop timer in onnavigatedfrom method, why happening? isn't page disposed after press button on it? thanks it disposed gc when nothing keeping awake. dispatchertimer keeps awake, though created page. guess in past has been dispatchertimer being referenced dispatcher itself, , can't clean up, or along lines. to demonstrate add finalize method #if de...

java - Non-blocking write to a socket in Android -

i have android app has socket open. write socket without possibility of blocking thread on write noticeable amount of time. if io error occurs, write silently fail. there easy way this? yes, nio provides socketchannel class (call getchannel method on socket ), allows call configureblocking use non-blocking mode. should i/o through channel, , not through socket object.