Tuesday, 15 June 2010

java - Any descriptive struts2 api doc for tags? -



java - Any descriptive struts2 api doc for tags? -

folks trying find tags api doc on net not find 1 descriptive. everywhere link reference http://struts.apache.org/2.1.8/docs/if.html illustration if have figure out if mymanager in below if tag treated string literal or ognl look against valuestack, can not find decription this.

<s:if test="mymanager"> </s:if>

can point me doc/link?

i guess help you, site listed article on apache official site. http://www.roseindia.net/struts/struts2/struts-2-tags.shtml http://www.dzone.com/tutorials/java/struts-2/struts-2-tutorial/struts-2-tutorial.html

java api struts2

web services - Salesforce/php - downloaded image attachments are corrupted - Any Ideas? -



web services - Salesforce/php - downloaded image attachments are corrupted - Any Ideas? -

here code downloading attachment salesforce.com using php toolkit , enterprise wsdl:

header('content-type: application/force-download'); header('content-disposition: inline; filename="image.jpg"'); $mysforceconnection = getconnection(); $query = "select id, name, body attachment id ='" .$id ."'"; $queryresult = $mysforceconnection->query($query); $records = $queryresult->records; print_r(base64_decode($records[0]->fields->body));

when file gets downloaded correctly right number of bytes when open image, windows image viewer says corrupt. thought why happening?

the same code works fine pdfs , text files.

you want echo output, @eyescream mentioned. when utilize print_r function, additional tab , newline characters placed output create more readable. plain echo output properly.

header('content-type: application/force-download'); header('content-disposition: inline; filename="image.jpg"'); $mysforceconnection = getconnection(); $query = "select id, name, body attachment id ='" .$id ."'"; $queryresult = $mysforceconnection->query($query); $records = $queryresult->records; echo base64_decode($records[0]->fields->body);

php web-services salesforce

text - Python - Nested loop that doesn't work when reading a file -



text - Python - Nested loop that doesn't work when reading a file -

this nested loop works fine when reading lists:

list = [1,2,3,4,5] num = 0 while num < 5: in list: print(i) num += 1

this loop print elements in list. problem doesn't work @ when reading textfiles. instead of printing first 5 lines of text read through , print them.

f = open(r'c:\users\me\python\bible.txt') num = 0 while num < 50: line in f: print(line) num += 1

i can assume num variable doesn't increment after each iteration, there reason this, , there solution?

the code

for line in f: print line num += 1

is looping on lines in file. @ same time increment num one. @ end of for-loop num equal number of lines in files, larger 50, exit while-loop.

using style should write:

for line in f: print line num += 1 if num > 50: break

also first code has same problem. why need 2 loops if want loop on 1 construction in 1 dimension? codes not pythonic, illustration should rewrite them as:

list = [1,2,3,4,5] in list: print i,line in enumerate(f): print line if > 50: break

python text iteration

sql - SUM() from a multi-part JOIN -



sql - SUM() from a multi-part JOIN -

select sum(t.optlevel) + sum(o.reqlevel1) + sum(b.noptvalue) _inventory left bring together _items t on t.id64 = i.itemid left bring together _refobjcommon o on o.id = t.refitemid left outer bring together _bindingoptionwithitem b on b.nitemdbid = i.itemid i.charid = 7843 , i.slot between 0 , 12 , i.itemid != 0

i'm having problem query, not quite experienced joins be.

t.optlevel >= 0 _items , row there

o.reqlevel1 between 1 , 101 _refobjcommon , row there

however, b.noptvalue _bindingoptionwithitem either null, 1, or 2 row not there... when b.noptvalue = 1 or 2 nowadays in 1 of 12 row results ( i.slot between 0 , 12 ) script runs perfectly: sum total if b.noptvalue returns null in 12 row results sum gets returned null whole query.

i know there simple solution, cannot find it.

without understanding question, there's cool function coalesce(), returns first of parameters not null.

select coalesce(sum(t.optlevel), 0) + coalesce(....

sql join sum

c++ - what should be the format of input data file which is passed as an object to MyDataStream stream(argv[1]) -



c++ - what should be the format of input data file which is passed as an object to MyDataStream stream(argv[1]) -

i using "libspatialindex" library creating r-tree index. info 2 dimensional next values:

(1, (1,5)), (19, (6,8)), (20, (3,8)), (4, (1,9)).

the description of info is:

1 info point , nowadays in interval (1,5) 19 info point , nowadays in interval (6,8) 20 info point , nowadays in interval (3,8) 4 info point , nowadays in interval (1,9)

i trying mass load above info r-tree. doing using next test code libspatialindex. however, not getting what should format of input info file passed object *mydatastream stream(argv[1]);*

the test code using is:

// copyright (c) 2002, marios hadjieleftheriou // include library header file. #include <spatialindex/spatialindex.h> using namespace spatialindex; #define insert 1 #define delete 0 #define query 2 class mydatastream : public idatastream { public: mydatastream(std::string inputfile) : m_pnext(0) { m_fin.open(inputfile.c_str()); if (! m_fin) throw tools::illegalargumentexception("input file not found."); readnextentry(); } virtual ~mydatastream() { if (m_pnext != 0) delete m_pnext; } virtual idata* getnext() { if (m_pnext == 0) homecoming 0; rtree::data* ret = m_pnext; m_pnext = 0; readnextentry(); homecoming ret; } virtual bool hasnext() { homecoming (m_pnext != 0); } virtual uint32_t size() { throw tools::notsupportedexception("operation not supported."); } virtual void rewind() { if (m_pnext != 0) { delete m_pnext; m_pnext = 0; } m_fin.seekg(0, std::ios::beg); readnextentry(); } void readnextentry() { id_type id; uint32_t op; double low[2], high[2]; m_fin >> op >> id >> low[0] >> low[1] >> high[0] >> high[1]; if (m_fin.good()) { if (op != insert) throw tools::illegalargumentexception( "the info input should contain insertions only." ); part r(low, high, 2); m_pnext = new rtree::data(sizeof(double), reinterpret_cast<byte*>(low), r, id); // associate bogus info array every entry testing purposes. // 1 time info array given rtree:data local re-create created. // hence, input info array can deleted after operation if not // needed anymore. } } std::ifstream m_fin; rtree::data* m_pnext; }; int main(int argc, char** argv) { seek { if (argc != 5) { std::cerr << "usage: " << argv[0] << " input_file tree_file capacity utilization." << std::endl; homecoming -1; } std::string basename = argv[2]; double utilization = atof(argv[4]); istoragemanager* diskfile = storagemanager::createnewdiskstoragemanager(basename, 4096); // create new storage manager provided base of operations name , 4k page size. storagemanager::ibuffer* file = storagemanager::createnewrandomevictionsbuffer(*diskfile, 10, false); // applies main memory random buffer on top of persistent storage manager // (lru buffer, etc can created same way). mydatastream stream(argv[1]); // create , mass load new rtree dimensionality 2, using "file" // storagemanager , rstar splitting policy. id_type indexidentifier; ispatialindex* tree = rtree::createandbulkloadnewrtree( rtree::blm_str, stream, *file, utilization, atoi(argv[3]), atoi(argv[3]), 2, spatialindex::rtree::rv_rstar, indexidentifier); std::cerr << *tree; std::cerr << "buffer hits: " << file->gethits() << std::endl; std::cerr << "index id: " << indexidentifier << std::endl; bool ret = tree->isindexvalid(); if (ret == false) std::cerr << "error: construction invalid!" << std::endl; else std::cerr << "the stucture seems o.k." << std::endl; delete tree; delete file; delete diskfile; // delete buffer first, storage manager // (otherwise the buffer fail trying write dirty entries). } grab (tools::exception& e) { std::cerr << "******error******" << std::endl; std::string s = e.what(); std::cerr << s << std::endl; homecoming -1; } homecoming 0; }

chop out readnextentry , test that:

void readnextentry(istream& is) { id_type id; uint32_t op; double low[2], high[2]; >> op >> id >> low[0] >> low[1] >> high[0] >> high[1]; }

we can create test input stream using istringstream:

bool isgood(const std::string& input) { std::istringstream ss(input); readnextentry(ss); homecoming ss.good(); }

and demonstrate:

int main() { std::cout << "good? " << isgood("asdf qwer zxcv uyio ghjk") << std::endl; std::cout << "good? " << isgood("0.0 0 0 0 0") << std::endl; std::cout << "good? " << isgood("1 2 3 4 5") << std::endl; }

c++ data-structures r-tree

android - take value from EditText from a ListView -



android - take value from EditText from a ListView -

i have simplecursoradapter edittext , textview, have take value every text view when button pressed,and have no ideea how create it,this simplecursoradapter class

private class edittextadapter extends simplecursoradapter { private context adcontext; public int getcount() { homecoming calatori.size()+1; } public edittextadapter(context context, int layout, cursor c, string[] from, int[] to) { super(context, layout, c, from, to); this.adcontext = context; } public view getview(int pos, view inview, viewgroup parent) { view v = inview; if (v == null) { layoutinflater inflater = (layoutinflater) adcontext .getsystemservice(context.layout_inflater_service); v = inflater.inflate(r.layout.element_lista_cipasport, null); } if (pos == getcount()){ ((textview) v.findviewbyid(r.id.text_ci)).settext("telefon"); ((edittext) v.findviewbyid(r.id.edt_ci)).sethint(""); ((edittext) v.findviewbyid(r.id.edt_ci)).setinputtype(inputtype.type_class_number); } ((textview) v.findviewbyid(r.id.text_ci)).settext(" ci/pasport "+calatori.get(pos).nume); } homecoming v; } }

android listview android-edittext

javascript - Can't get RegExp to match in GWT -



javascript - Can't get RegExp to match in GWT -

example text: in park, kid plays. kid tall. kid watches kid @ play.

i want match "child" in first sentence, "child" in sec , 3rd sentences not "child" in 3rd sentence. or in other words, match "child" or "child" not if proceeded word "another"

i thought using negative behind

((?<\!another) [cc]hild)

but can't seem syntax right produce valid regexp.

even if syntax right not sure can in gwt. here snippet gwt javadoc

java-specific constructs in regular look syntax (e.g. [a-z&&[^bc]], (?<=foo), \a, \q) work in pure java implementation, not gwt implementation,...

any help or insight appreciated.

update:

colin's reply works isn't quite right.

colin's regex match "child" , "child" , not match "another child" asked. there few problems though.

what trying match on "child" , "child" can replaced either child's name or right pronoun he/she, depending on child's gender.

the problem colin's regex matches ", child" , ". child". doesn't match "child" if first word in text. example:

"child went park. in park, kid plays. kid tall. kid watches kid @ play."

the first kid not match. subsequent matches on ", child", ". child", , ". child".

i worked on regex colin came trying match "child" or "child" can't create work.

the regex in gwt has same level of back upwards regexp javascript, since calls on native javascript classes.

i can't think of way reject "another child" straight in regex, given javascript regex doesn't have back upwards look-behind or possessive quantifier.

therefore, write regex that, if "another" appears before "child", "another" matched; otherwise, "child" matched. can filter out matches have more 5 characters.

regexp.compile("(?:another +)?[cc]hild", "g")

note "child" in string "some children" matched. , if "another" embedded within longer word string, illustration "ranother"1, blindly pick fragment. prevent such cases, need add together word boundary check \b2:

regexp.compile("(?:\\banother +)?\\b[cc]hild\\b", "g") --- --- --- | | | prevent "ranother" prevent "children" matching or "nochild" matching

you may allow case-insensitive matching (which quite reasonable text) i flag. however, leave decide.

using regex above, match "another child" before matching "child". therefore, when match contains "child", know "another" does not precede it. therefore, can filter away matches length > 5, , left valid strings.

footnote

i utilize made word example. normal in arbitrary string, don't know if there word in english language "another" embedded inside.

there caveat here. "child4" or "child_something" not matched when \b used. while "another" in "_another child" or "5another child" not picked regex (and "child" matched, means take match). possible workaround this, , if request it.

javascript regex gwt negative-lookbehind