java - ResourceTool : to recover a jpg with ResourceNode [velocity] -


during searching, piece of advice following situation :

the guy, on website, choose parcel send, when validates choice, carriers appear results. carriers have different offers different logos located in special directory.

now business logic use :

if in directory find peculiar logo corresponding special offer, take logo display in web page special offer.

i choose work resourcetool velocity

i have implement 2 methods getlogo() , getlabel().

the getlogo() special logo.

i think use method recover object :

public static resourcenode getresource(context context, resourcetype resourcetype, string...keys) {     try {         if (null != resourcestool.instance) {             resourcenode resource = resourcestool.instance.getresourceset(context, resourcetype);             if (null != resource) {                 deque < string > keydeque = new arraydeque < > ();                 (string key: keys) {                     keydeque.add(key);                 }                 return (resourcenode) resource.sub(keydeque);             }         }     } catch (exception e) {         boxtalelogger.debug("[resourcestool.getresource] error: ", e);     }     return null; } 

now searching example merely use method recover different .jpg

question 2 : don't understand meaningful of context context in method ?

then resourcetype enum either string or picture (the logo in fact)

all right found :

 public string getlogo(resourcenode node){    //readable variables   string ope_code = (string)((instance)get("operateur")).get("ope_code");   string paysdest = ((instance)db.getentity("tab_pays").fetch((integer) get("pz_id"))).get("pz_iso");    string path = node.get(ope_code+"_"+get("srv_code")+"_"+paysdest+".png");    if (path=null){       path = node.get(ope_code+"_"+get("srv_code")+".png");       if (path=null){              path = node.get(ope_code+".png");       }   }   return path ; 

}

now testing method, tell after.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -