From: Eric P. <th...@us...> - 2009-07-29 12:58:36
|
Update of /cvsroot/sandev/sand/platform/tools/src/org/sandev/tools/HTTP In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30395 Modified Files: XHTMLScreenAdaptor.java Log Message: Factored loadSpecifiedInstance and extended it to be able to handle driving a find or add operation for an array field. Index: XHTMLScreenAdaptor.java =================================================================== RCS file: /cvsroot/sandev/sand/platform/tools/src/org/sandev/tools/HTTP/XHTMLScreenAdaptor.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** XHTMLScreenAdaptor.java 23 Apr 2008 22:38:52 -0000 1.30 --- XHTMLScreenAdaptor.java 29 Jul 2009 12:58:23 -0000 1.31 *************** *** 438,442 **** loadUIAction(uifc,uiri,link,owner,user,uwl); } if(i==primaryFormIndex) { ! loadSpecifiedInstance(uifc,owner,user); } } //uifc.debugDump(" *** reconstructed form: " + link.getName() + " ***",uifc); link.setFormState(uifc); --- 438,442 ---- loadUIAction(uifc,uiri,link,owner,user,uwl); } if(i==primaryFormIndex) { ! initCustomAction(uifc,owner,user); } } //uifc.debugDump(" *** reconstructed form: " + link.getName() + " ***",uifc); link.setFormState(uifc); *************** *** 453,462 **** /** ! * If a particular instance was specified in the URL parameters, then ! * initialize the current form with it. This method also handles ! * partial specifications and buttons. */ ! protected void loadSpecifiedInstance(UIFormContext uifc,UIFormOwner owner, ! AuthUser user) throws UIScreenAdaptorException { --- 453,462 ---- /** ! * If a button was specified in the URL params, then set up to handle ! * it. This handles custom actions and tab selection, then calls ! * to handle more specified instance param driving. */ ! protected void initCustomAction(UIFormContext uifc,UIFormOwner owner, ! AuthUser user) throws UIScreenAdaptorException { *************** *** 464,476 **** if((button!=null)&&(!button.equals(""))) { debug(owner,"loadSpecifiedInstance: button " + button + ! " specified in URL."); int action=uifc.actionLabelToValue(button); ! if(action>uifc.ACTION_CUSTOM) { uifc.setAction(action); } ! else { uifc.setAction(UIFormContext.ACTION_CUSTOM); ! selectTab(uifc,button); uifc.clearOutputText(); //clear for button name uifc.appendInfo(button); } } String classname=uifc.getParam("class"); if((classname==null)||(classname.equals(""))) { --- 464,495 ---- if((button!=null)&&(!button.equals(""))) { debug(owner,"loadSpecifiedInstance: button " + button + ! " specified in URL."); //driving action via params.. int action=uifc.actionLabelToValue(button); ! if(action>uifc.ACTION_CUSTOM) { //defined action: edit, find etc uifc.setAction(action); } ! else { //not defined, presumably custom uifc.setAction(UIFormContext.ACTION_CUSTOM); ! selectTab(uifc,button); //select form tab if that's what it was uifc.clearOutputText(); //clear for button name uifc.appendInfo(button); } } + //At this point custom action setup and form tab selection is done. + //Check if we are driving more explicitely. + loadSpecifiedInstance(uifc,owner,user); + } + + + /** + * If a particular instance was specified in the URL parameters, + * then initialize the current form with it and handle setup of + * standard actions. Advanced driving requires that you specify + * the class and uniqueID of the instance we will be working with. + * That allows for jumping to pretty much anything, and helps to + * avoid having this processing conflict with the custom form + * buttons and tabs set up in the UI definition. + */ + protected void loadSpecifiedInstance(UIFormContext uifc,UIFormOwner owner, + AuthUser user) + throws UIScreenAdaptorException + { String classname=uifc.getParam("class"); if((classname==null)||(classname.equals(""))) { *************** *** 491,516 **** uifc.appendWarning(classname + " " + id + " not found."); } else { ! uifc.setRootMsg(spm); ! uifc.setCurrInst(spm); ! uifc.setCurrClass(spm.getShortName()); ! String position=uifc.getParam("pos"); ! if((position!=null)&&(!position.trim().equals(""))) { ! debug(owner,"loadSpecifiedInstance: pos " + position + ! " specified in URL."); ! uifc.initPosition(position); ! uifc.evalPosition(); } ! else { ! uifc.initPosition(spm.getShortName()); } ! if(uifc.getAction()!=UIFormContext.ACTION_CUSTOM) { ! uifc.setAction(UIFormContext.ACTION_UNDEFINED); } ! uifc.setModePath("LISTING"); ! if((button!=null)&&(button.equals("edit"))) { uifc.setModePath("LISTING.UPDATING"); ! debug(owner,"loadSpecifiedInstance calling edit hook"); ! owner.doActionEditHook(uifc); } ! else { ! debug(owner,"loadSpecifiedInstance calling display hook"); ! owner.doActionDisplayHook(uifc); } } ! debug(owner,"loadSpecifiedInstance complete."); } --- 510,561 ---- uifc.appendWarning(classname + " " + id + " not found."); } else { ! initSpecifiedInstance(uifc,owner,user,spm); } ! } ! ! ! /** ! * Given an instance, initialize our form with it as specified by ! * the URL parameters. ! */ ! protected void initSpecifiedInstance(UIFormContext uifc,UIFormOwner owner, ! AuthUser user,SandPersistMessage spm) ! { ! uifc.setRootMsg(spm); ! uifc.setCurrInst(spm); ! uifc.setCurrClass(spm.getShortName()); ! String position=uifc.getParam("pos"); ! if((position!=null)&&(!position.trim().equals(""))) { ! debug(owner,"loadSpecifiedInstance: pos " + position + ! " specified in URL."); ! uifc.initPosition(position); ! uifc.evalPosition(); } //go to the specified subpart ! else { //just init with at the top level of the instance ! uifc.initPosition(spm.getShortName()); } ! //at this point we have the correctly initialized instance ! String field=uifc.getParam("field"); ! String findclass=uifc.getParam("findclass"); ! switch(uifc.getAction()) { ! case UIFormContext.ACTION_CUSTOM: ! return; //owner will handle it ! case UIFormContext.ACTION_EDIT: ! uifc.setModePath("LISTING.UPDATING"); ! debug(owner,"loadSpecifiedInstance calling edit hook"); ! owner.doActionEditHook(uifc); ! break; ! case UIFormContext.ACTION_FIND: ! case UIFormContext.ACTION_NEW: ! if((field!=null)&&(!field.trim().equals(""))&& ! (findclass!=null)&&(!findclass.trim().equals(""))) { uifc.setModePath("LISTING.UPDATING"); ! debug(owner,"initSpecifiedInstance edit hook before find"); ! owner.doActionEditHook(uifc); ! uifc.setCurrClass(findclass); ! uifc.pushPosition(field + "[-1]"); //append ! break; } //otherwise fall through to default processing below ! default: //action not handle, reset and display ! uifc.setAction(UIFormContext.ACTION_UNDEFINED); ! uifc.setModePath("LISTING"); ! debug(owner,"loadSpecifiedInstance calling display hook"); ! owner.doActionDisplayHook(uifc); } } |