PageComper.java 224 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166
  1. package core.page;
  2. import java.io.BufferedReader;
  3. import java.io.File;
  4. import java.io.StringReader;
  5. import java.util.ArrayList;
  6. import java.util.Arrays;
  7. import java.util.Comparator;
  8. import java.util.HashMap;
  9. import java.util.HashSet;
  10. import java.util.LinkedList;
  11. import java.util.List;
  12. import java.util.Map;
  13. import java.util.Map.Entry;
  14. import java.util.Optional;
  15. import java.util.Set;
  16. import java.util.regex.Matcher;
  17. import java.util.regex.Pattern;
  18. import java.util.stream.Collectors;
  19. import com.google.gson.Gson;
  20. import com.google.gson.JsonArray;
  21. import com.google.gson.JsonElement;
  22. import com.google.gson.JsonObject;
  23. import com.google.gson.JsonParser;
  24. import org.apache.commons.lang3.StringUtils;
  25. import org.apache.logging.log4j.LogManager;
  26. import org.apache.logging.log4j.Logger;
  27. import org.dom4j.Document;
  28. import org.dom4j.DocumentHelper;
  29. import org.dom4j.Element;
  30. import base.SsC;
  31. import core.PrjApp;
  32. import ss.AppB;
  33. import ss.AppC;
  34. import ss.ccp.CcpB;
  35. import ss.ccp.CcpFieldB;
  36. import ss.cmn.file.FileU;
  37. import ss.cmn.ser.SerU;
  38. import ss.cmn.str.StrU;
  39. import ss.cmn.str.StrWeb;
  40. import ss.log.SsLog;
  41. import ss.log.ThdLog;
  42. import ss.obj.ObjB;
  43. import ss.obj.ObjC;
  44. import ss.obj.ObjFieldB;
  45. import ss.page.PageB;
  46. import ss.page.PageC;
  47. import ss.page.PageU;
  48. import ss.page.TabC;
  49. import ss.search.SearchC;
  50. import ss.skin.SkinC;
  51. // 来自 pms-core:XmslBjCompiler implements BjCompiler(接口类)。Lin
  52. public class PageComper {
  53. // 增加,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
  54. private static final Logger log4j = LogManager.getLogger(PageComper.class);
  55. ///// 来自 FileTranslator。 // 移到 PageCompC。Lin
  56. // private static final String INTERPOLE_JSPTOP_BEGIN = "<!-- jsptopstart -->";
  57. // private static final String INTERPOLE_JSPTOP_END = "<!-- jsptopend -->";
  58. // private static final String INTERPOLE_HEAD_BEGIN = "<!-- injectheadstart -->";
  59. // private static final String INTERPOLE_HEAD_END = "<!-- injectheadend -->";
  60. /* 去掉,不写应用名。Lin
  61. private static final String SET_APPNAME_JSP = "pms/clip/SetAppName.jsp"; // "/main/sheji/setAppName.jsp"。Lin
  62. private static final String SET_APPNAME_SCRIPT = "<%-- setAppName.jsp is 404 --%><% pageContext.setAttribute(wd.core.web.service.ServiceConst.APP_NAME,\"#{APPNAME}#\");%>\n";
  63. private static final String SET_XMDM_JSP = "pms/clip/SetXmdm.jsp"; // "/main/sheji/setXmdm.jsp"。Lin
  64. private static final String SET_XMDM_SCRIPT = "<%-- setXmdm.jsp is 404 --%><% r\n if(pageContext.getSession().getAttribute(wd.core.common.CoreConstVars.XMMC)==null)\r\n\tpageContext.getSession().setAttribute(wd.core.common.CoreConstVars.XMMC,\"#{XMDM}#\");\r\n %>\r\n";
  65. */
  66. /* 去掉,不用文件,用常量 PageCompC.SCR_clearToken。Lin
  67. private static final String CLEAR_TOKEN_JSP = "pms/clip/ClearToken.jsp"; // "/main/sheji/tokenClear.jsp"。Lin
  68. private static final String CLEAR_TOKEN_SCRIPT = "<%-- tokenClear.jsp is 404 --%><script> tokenCleanser('<wd:token service='wd.removePageToken' dest='' param='' />',{'tokenList':'<%= pageContext.getAttribute(wd.core.common.CoreConstVars.WD_PAGE_TOKENLIST)%>'});</script>\r\n";
  69. */
  70. // private static final String ADD_REMOVE_TOKEN_SCRIPT = "<script> addRemoveToken('<%= pageContext.getAttribute(wd.core.common.CoreConstVars.WD_PAGE_TOKENLIST)%>');</script>\r\n";
  71. /////
  72. // 浅编译部件。Lin
  73. // 入口参数 fileName 优先。
  74. // 不分 MiniBuilder、P18Builder
  75. // 区别只在于 PageObject 是否为 null
  76. // 把 fileName、pageB 都做为入口参数
  77. // public boolean miniCompile(String fileName, PageB pageobj, int type, String destDir)
  78. // 入口参数改为只有 pageName。Lin
  79. // 再调整为 PMS 编译项目的部件 -- 增加支持多线程。Lin
  80. // 增加 compPage(CompPageB),去掉 pageName(String) 和 srcDir(String) -- 上层直接产生到文件名
  81. // 增加 prjApp(PrjApp) -- 用 PrjApp 和 CompPageB 来生成编译后的文件位置和文件名
  82. // 另,对 PMS 本身的首页 编译后的存放位置,不做特别处理 -- 手工再拷贝到 PMS 项目的 webapp 目录里
  83. public static boolean compPage(CompPageB compPage, PrjApp prjApp) {
  84. String pageName = compPage.pageName; // 增加。Lin
  85. /* 再调整为 PMS 编译项目的部件。Lin
  86. PageB pageObj = PrjApp.pageMap.get(pageName);
  87. */ PageB pageObj = prjApp.pageMap.get(pageName);
  88. ///// 来自 MiniBuilder.build()。(@Override
  89. // extends PageBuilder
  90. /* 再去掉,改为入口参数 -- 直接由上层产生到文件名 -- PMS/CompPage.jsp。Lin
  91. String reader; // StringReader。改用 fileName。Lin
  92. */
  93. try {
  94. /* 改用 fileName。Lin
  95. reader = getSourceCode(AppB.webRoot + srcDir + pageName +".jsp"); // 统一用 srcDir。Lin
  96. */
  97. /* 再去掉,改为入口参数 -- 直接由上层产生到文件名 -- PMS/CompPage.jsp。Lin
  98. reader = prjApp.webRoot + srcDir + pageName +".jsp"; // 统一用 srcDir。Lin // = AppB.。再增加支持多线程。Lin
  99. */
  100. if (pageObj == null) { // 登录页、个人首页。Lin
  101. SsLog.print("prjApp.pageMap 没有找到:"+ pageName);
  102. // 少一级 PageC.PAGE_dir 目录。Lin
  103. // reader = getSourceCode(SsApp.webRoot + srcDir + pageName +".jsp"); // 统一用 srcDir。Lin
  104. /* 再去掉 false = bySys,原来的程序有增加 <html>、<body> 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin
  105. createNewFileWithUrl(reader, null, AppB.webRoot + pageName +".jsp", false); // 不用 .Md5Name。Lin
  106. */
  107. /* 再调整为 PMS 编译项目的部件。Lin
  108. * 增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程
  109. * pageObj(PageB) 移到 prjApp 前面
  110. * 源文件为 ".ss.jsp"(PageC.PAGE_ssExt),编译后的目标文件为 ".jsp"(AppC.EXT_jsp)
  111. createNewFileWithUrl(reader, null, prjApp.webRoot + pageName +".jsp"); // , AppB.。再增加支持多线程。Lin
  112. */ doCompPage(compPage.srcFileName, prjApp.webRoot + pageName + AppC.EXT_jsp, null, prjApp);
  113. } else {
  114. // reader = getSourceCode(SsApp.webRoot + srcDir + PageC.PAGE_dir + pageName +".jsp"); // 统一用 srcDir。Lin
  115. /* 兜兜转转,直接点。Lin
  116. * 去掉 FileTranslator
  117. FileTranslator f=new FileTranslator();
  118. f.setAppName(getFactory().getWebapp().getName());
  119. f.setJapSuffix(common.ConstVars.RUN);
  120. f.setPageobj(null);
  121. if(reader!=null)
  122. f.createNewFileWithUrl(reader, getFactory().getGeneratePath());
  123. */
  124. /* 再去掉 false = bySys,原来的程序有增加 <html>、<body> 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin
  125. createNewFileWithUrl(reader, pageObj, AppB.webRoot + PageU.cmptPageFileName(pageObj), false);
  126. */
  127. /* 再增加支持多线程 -- PMS 需要。Lin
  128. createNewFileWithUrl(reader, pageObj, AppB.webRoot + PageU.cmptPageFileName(pageObj));
  129. */
  130. /* 再调整为 PMS 编译项目的部件。Lin
  131. * 增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程
  132. * pageObj(PageB) 移到 prjApp 前面
  133. createNewFileWithUrl(reader, pageObj, prjApp.webRoot + PageU.cmptPageFileName(pageObj));
  134. */
  135. String tgtPageName = (prjApp.inDebug)? pageName : PageU.md5PageName(pageName); // MD5 部件名。Lin
  136. doCompPage(compPage.srcFileName, prjApp.webRoot + PageU.cmptPageFileName(tgtPageName), pageObj, prjApp);
  137. /// 增加自动生成 _baseInfo、_miniInfo,并编译刷新 pageMap。Lin
  138. /* 再改,部件文件名前缀 "env_" 改为增加的属性 env= 了。Lin
  139. * 就是找 dw_inp 等,直接找 "_inp"/"_miniInp" 就行了 -- 去掉了 "env_" 后,env_inp 改为 objInp,没有 "_inp" 了。Lin
  140. if (!pageName.startsWith(PageC.PAGE_envPre) && // 不包含 "env_inp"。Lin
  141. (pageName.endsWith(PageC.PAGE_inpSuf) || // "_input")。Lin
  142. pageName.endsWith(PageC.PAGE_miniInpSuf))) { // "_miniInput")。Lin
  143. */ if (pageName.endsWith(PageC.PAGE_inpSfx) ||
  144. pageName.endsWith(PageC.PAGE_miniInpSfx)) {
  145. String infoPageName = pageName.replace(PageC.PAGE_inpSfx, PageC.PAGE_baseInfoSfx) // "_input", "_baseInfo")。Lin
  146. .replace(PageC.PAGE_miniInpSfx, PageC.PAGE_miniInfoSfx); // "_miniInput", "_miniBaseInfo")。Lin
  147. PageB infoPage = prjApp.pageMap.get(infoPageName); // = PrjApp.。再增加支持多线程。Lin
  148. if (infoPage != null && !infoPage.bySys) // 手工写的 Info Page。Lin
  149. return true;
  150. /* 复制到 "_baseInfo"/"_miniInfo"。Lin
  151. * 不复制了,直接从 "_inp"/"_miniInp" 读
  152. FileU.copyFile(reader, AppB.webRoot + srcDir + infoPageName +".jsp");
  153. */
  154. infoPage = makeInfoPageB(pageObj, infoPageName, prjApp); // 生成 Info PageB。Lin
  155. String serDir = prjApp.webRoot + AppC.CFG_serDir; // = PrjApp.appRoot。再增加支持多线程。Lin
  156. SerU.doSer(infoPage, serDir + pageName); // 用 "_inp" 保存 -- 项目启动时加载。Lin
  157. prjApp.pageMap.put(infoPage.name, infoPage); // 更新 pageMap。Lin // PrjApp.。再增加支持多线程。Lin
  158. /* 再去掉 true = bySys,原来的程序有增加 <html>、<body> 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin
  159. createNewFileWithUrl(reader, infoPage, AppB.webRoot + PageU.cmptPageFileName(infoPage), true);
  160. */
  161. /* 再增加支持多线程 -- PMS 需要。Lin
  162. createNewFileWithUrl(reader, infoPage, AppB.webRoot + PageU.cmptPageFileName(infoPage));
  163. */
  164. /* 再调整为 PMS 编译项目的部件。Lin
  165. * 增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程
  166. * pageObj(PageB) 移到 prjApp 前面
  167. createNewFileWithUrl(reader, infoPage, prjApp.webRoot + PageU.cmptPageFileName(infoPage));
  168. */
  169. tgtPageName = (prjApp.inDebug)? infoPageName : PageU.md5PageName(infoPageName); // MD5 部件名。Lin
  170. doCompPage(compPage.srcFileName,
  171. prjApp.webRoot + PageU.cmptPageFileName(tgtPageName), infoPage, prjApp);
  172. }
  173. ///
  174. }
  175. } catch (Exception e) {
  176. /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
  177. e.printStackTrace();
  178. */ log4j.error("PageComper.compPage( 异常", e);
  179. ThdLog.wrMsg(String.format(AppC.TITLE_errLine, "编译部件错误"), e.toString(), e.getCause()); // RlsLoger.。Lin
  180. return false;
  181. }
  182. return true;
  183. /////
  184. }
  185. // 生成 Info PageB。Lin
  186. // 参考自 pms-core:PmsUtil.(Wj) addRealate_baseinfo(Wj wj, Long yhid, GeneralDBAccess gdba)。Lin
  187. // 再增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程 -- PMS 需要。Lin
  188. private static PageB makeInfoPageB(PageB pageObj, String infoPageName, PrjApp prjApp) {
  189. /* 改。Lin
  190. ViewObject vo = PmsFinder.findViewObject(wj.getDxm(), wj.getXmslid(), gdba);
  191. */ ObjB vo = prjApp.objMap.get(pageObj.objName); // 一定有 .objName。Lin // PrjApp.。再增加支持多线程。Lin
  192. String infoDesc = vo.desc +"基本情况";
  193. /* 再去掉,即使有细分部件,也叫 "文书基本情况"。Lin
  194. * 即使用改成了 "文书来文基本情况" 也是没用的,"查看文书"/"查看文书.来文" 是在 ??? 重新生成的。Lin
  195. for (ObjFuncB f : vo.funcMap.values()) { // .getFuns()。Lin
  196. for (ObjFuncPluginB plu : f.pluginList) {
  197. if (infoPageName.equals(plu.name)) {
  198. infoDesc = vo.desc + plu.desc +"基本情况";
  199. break;
  200. }
  201. }
  202. }
  203. */
  204. PageB info = new PageB(); // 与 PageB 的成员变量一致。Lin
  205. info.biz = pageObj.biz;
  206. info.objName = pageObj.objName;
  207. info.isEnv = true;
  208. info.isInfo = true;
  209. info.isInp = false;
  210. info.bySys = true;
  211. /* 去掉 PageB.type 了。同时,MD 的部件名,加前缀 mp_/pad_/ext_(外部访问,微信) 了。Lin
  212. * 去掉 <page type="12101",改为 插件主页面 写 type="info"/"task"/"urge"(插件类别名)
  213. info.type = PageC.PAGE_baseInfoType; // 不会有 迷你录入部件(miniInp),所以是 基本情况部件(baseInfo)。Lin
  214. */
  215. info.md5Name = null; // MD 首页部件名
  216. info.name = infoPageName;
  217. info.md5Name = PageU.md5PageName(infoPageName);
  218. info.desc = infoDesc;
  219. info.width = pageObj.width;
  220. info.height = pageObj.height;
  221. info.fixHeight = pageObj.fixHeight;
  222. info.rowNumPer = pageObj.rowNumPer;
  223. return info;
  224. }
  225. //// 来自 FileTranslator
  226. /////
  227. // 来自 FileTranslator.createNewFileWithUrl(StringReader reader,// 被替换的源文件路径(此文件不会被修改)
  228. // String newFilePath)// 替换后生成的新文件路径。Lin
  229. // 兜兜转转,直接点 -- 去掉 FileTranslator
  230. // 去掉 public,改为私有 private
  231. // FileTranslator.pageobj(PageObject) 改为用入口参数 pageobj(PageB)传递
  232. // reader 改为 fileName,在 compFile() 里读入
  233. // 增加 bySys -- 根据 dw_inp.jsp 生成 dw_baseInfo.jsp -- 增加 <html>、<body> 等。Lin
  234. // 再去掉 bySys,原来的程序有增加 <html>、<body> 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin
  235. // 再增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程
  236. // pageObj(PageB) 移到 prjApp 前面
  237. private static void doCompPage(String srcFileName, // 被替换的源文件路径(此文件不会被修改)
  238. String tgtFileName, // 替换后生成的新文件路径
  239. PageB pageobj, // 被替换的源 PageB
  240. PrjApp prjApp
  241. /* 再去掉 bySys。Lin
  242. boolean bySys // 根据 dw_inp.jsp 生成 dw_baseInfo.jsp -- 增加 <html>、<body> 等。Lin
  243. */
  244. ) throws Exception {
  245. /* 再改,IDEA:'StringBuffer result' may be declared as 'StringBuilder'。Lin
  246. StringBuffer result=new StringBuffer();
  247. */ StringBuilder result = new StringBuilder();
  248. // CACHE = new ThreadLocal<Map<String, WdFitHeightParam>>();
  249. /* 去掉,没有 _view.jsp 了。Lin
  250. boolean isViewJsp = ConstVars.VIEW.equals(japSuffix);
  251. */
  252. boolean isHelpJsp = false;
  253. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  254. * List<String> 改为 List<StringBuilder>
  255. List<String> fileContentStrList = new LinkedList<>();// 包含文件中所有内容的字符串
  256. */ List<StringBuilder> fileContentStrList = new LinkedList<>();// 包含文件中所有内容的字符串
  257. // 发布程序自动添加html、head、body start 150209 by ye
  258. /*
  259. * fileContentStrList.add("<html>"); fileContentStrList.add("<head>");
  260. * fileContentStrList.add("<LINK href=\"/wd/theme/standard/style.css\"
  261. * rel=\"stylesheet\" type=\"text/css\">");
  262. * fileContentStrList.add("</head>"); fileContentStrList.add("<body>");
  263. */
  264. // 发布程序自动添加html、head、body end 150209 by ye
  265. /// 改为在这添加,且只对 dw_inp.jsp 生成 dw_baseInfo.jsp 时。Lin
  266. /* 再去掉,原来的程序有增加 <html>、<body> 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin
  267. if (bySys) {
  268. fileContentStrList.add("<html>");
  269. fileContentStrList.add("<head>");
  270. // fileContentStrList.add("<skin@ss file='/ss/main'/>");
  271. fileContentStrList.add("</head>");
  272. fileContentStrList.add("<body>");
  273. }
  274. */
  275. ///
  276. List<String> jsFileList = new ArrayList<>();
  277. List<String> tbodyFileList = new ArrayList<>();
  278. Map<String, String> tldFileMap = new HashMap<>();
  279. BufferedReader in = null;
  280. String s;
  281. // PrintStream ps = null;
  282. try {
  283. /* 再改,IDEA:Type may be primitive。Lin
  284. Boolean pageExist = (pageobj != null);
  285. */ boolean pageExist = (pageobj != null);
  286. // String yyxtidSql="select yyxt_id from ejlm where ymid="+ymid;
  287. // gdba.select( yyxtidSql);
  288. // String yyxtid=null;
  289. // if (gdba.getNowselect().getRowCount() > 0) {
  290. // yyxtid=gdba.getColumnAsString("yyxt_id");
  291. // }
  292. // String dm = WebUtil.getYyhByWzid(gdba, wzid);
  293. // 读取源文件的所有内容
  294. // System.out.println(new File(srcFilePath).exists());
  295. /* 去掉,移到 jspUpdate() 里 -- 只有这里用到。Lin
  296. String[] array = { WebC.SS_name, PrjApp.prjName }; // "wd",appName。Lin
  297. */
  298. /// 帮助功能变量准备start ///
  299. // String bjdm = pageobj.getName();
  300. // String gdgd = null;
  301. // Bj bj = new Bj();
  302. // bj.setBjid(Long.valueOf(bjId));
  303. //
  304. // gdba.selectById(bj);
  305. // bjdm = bj.getDm();
  306. // if (bjdm != null && bjdm.startsWith("help_")) {
  307. // isHelpJsp = true;
  308. // }
  309. /* 去掉 csc(保存所有属性的键值对),已经写到 .name、.width 等了。Lin
  310. Map<String, String> json = pageExist?pageobj.getCsc():new HashMap();
  311. */
  312. // gdgd = json.get("gdgd");
  313. // DesignOutSide dots = new DesignOutSide(Long.parseLong(ymid), gdba);
  314. /* 去掉 csc(保存所有属性的键值对),已经写到 .name、.width 等了 -- 用 .isMakeBySys。Lin
  315. boolean systemCreate = "1".equals(json.get("sfxtcj") + "");
  316. */
  317. /* 再改,IDEA:Variable 'systemCreate' is never used。Lin
  318. boolean systemCreate = pageExist? pageobj.bySys : false;
  319. */
  320. // Ym ym = new Ym();
  321. // ym.setYmid(Long.parseLong(ymid));
  322. // gdba.selectById(ym);
  323. // if (bjId != null) {
  324. // String bjdmSql = "select dm,bqgd from bj where bjid = :bjid";
  325. // SqlCommandImpl sqlCmd = new SqlCommandImpl(bjdmSql);
  326. // sqlCmd.setInt("bjid", Long.valueOf(bjId));
  327. // gdba.select(sqlCmd);
  328. // if (gdba.getRowCount() > 0) {
  329. // bjdm = gdba.getColumnAsString("dm");
  330. // bqgd = gdba.getColumnAsString("bqgd");
  331. // }
  332. // }
  333. // List<String> wdHelpExecutableJsStringList = new
  334. // ArrayList<String>();
  335. // String wdhelpForPagejs = new
  336. // WdHelpForWholePage().getExecutableJsString("", dm, bjdm);
  337. // // 整个页面的帮助
  338. // if (wdhelpForPagejs != null) {
  339. // wdHelpExecutableJsStringList.add(wdhelpForPagejs);
  340. // }
  341. /// 存储帮助功能的可执行js代码段 ///
  342. /// 帮助功能变量准备 end ///
  343. // StringReader reader = null;
  344. /* 去掉入口参数 ymid、wzid、gdba(wdgdba)。Lin
  345. * 去掉 appName,直接用 PrjApp.prjName
  346. * 移到 PageCompU,reader 改为 fileName -- 在 compFile() 里读入
  347. reader = transformCommonwrite(reader, appName, null, null, wdgdba);
  348. */
  349. StringReader reader = PageCompU.compFile(srcFileName);
  350. //noinspection SuspiciousIndentAfterControlStatement
  351. if (pageExist)
  352. if (pageobj.isInfo || pageobj.isInp) {
  353. // if (isMobile()) {
  354. //// reader = addMobileViewObjectTools(reader, dm, ym.getObject(), bj.getDm(), ymid, wzid, isViewJsp, systemCreate, gdba);
  355. // } else {
  356. /* 去掉 appName,不支持多个应用。Lin
  357. * 去掉 isViewJsp,没有 ViewJsp 了。Lin
  358. * 去掉 pageobj.getObjectName(),有 pageobj 就够了。Lin
  359. * 去掉 wdgdba,需要时再获取数据库连接。Lin
  360. * 去掉 ymid、wzid -- 两个 null。Lin
  361. * 去掉 appName,直接用 PrjApp.prjName
  362. * 再增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程。Lin
  363. reader = addViewObjectTools(reader, appName , pageobj.getObjectName(),pageobj, null, null, isViewJsp, systemCreate, wdgdba);
  364. */ reader = addViewObjectTools(reader, pageobj, prjApp);
  365. // }
  366. }
  367. if (reader == null)
  368. return;
  369. in = new BufferedReader(reader);
  370. boolean hasTab = false;
  371. boolean wdFitHeight = false;
  372. boolean wdDragHeight = false;
  373. boolean wdDragWidth = false;
  374. boolean showMsgPopup=false;
  375. // 新增,修改,变动三合一部件:没有html,body,head,form
  376. boolean isObjectInput = true;
  377. String reg_applicationcode = "@applicationCode";
  378. // String reg_pagewrite = "<page:write\\s*.*?\\s*/>"; // 去掉,归入 JspTagComper。Lin
  379. /* 再改,规范命名。Lin
  380. * wdOddClass > ssOddClazz
  381. * wdEvenClass > ssEvenClazz
  382. * wdHoverClass > ssHovClazz
  383. String reg_tbody = "<(tbody\\s*.*)(wdOddClass.*|wdEvenClass.*|wdHoverClass.*)>";
  384. */ String reg_tbody = "<(tbody\\s*.*)(ssOddClazz.*|ssEvenClazz.*|ssHovClazz.*)>";
  385. String reg_goto = "@goto\\{.*?\\}@";
  386. // String reg_wdpage = "<wd:page\\s*.*?\\s*/>"; // 去掉,归入 JspTagComper。Lin
  387. // String common_write_regexp =
  388. // "<wd:write([^>]*?)(/>|(>[\\s\\S]*?</wd:write>))";
  389. // String jsonStr=null;
  390. int index = 0;
  391. while ((s = in.readLine()) != null) {
  392. /// ???
  393. // if (s.contains("${delete}"))
  394. // System.out.println("in.readLine()");
  395. ///???
  396. // String strUrl = ""; // 再,移到下面用到的地方。按 IDEA 规范 -- Variable 'strUrl' initializer '""' is redundant。Lin
  397. // ArrayList<String> list = matchAll(ss,reg,0);
  398. // 判断是否有wdSecondaryTab
  399. if (s.contains("tab-div"))
  400. hasTab = true;
  401. if (s.contains("ssFith")) // ("wdFitHeight"))。Lin
  402. wdFitHeight = true;
  403. if (s.contains("ssDragh")) // ("wdDragHeight"))。Lin
  404. wdDragHeight = true;
  405. if (s.contains("ssDragw")) // ("wdDragWidth"))。Lin
  406. wdDragWidth = true;
  407. if (s.contains("wd.display.showMsgPopup"))
  408. showMsgPopup = true;
  409. //noinspection SuspiciousIndentAfterControlStatement
  410. if(pageExist)
  411. if (isHelpJsp // isHelpJsp 没有被赋值 -- false???Lin
  412. && (s.contains("<img") || s.contains("video"))) {
  413. s = s.replace("wdSrc=\"", "src=\"${sessionScope['ssUser'].skinDir}/help/PC/"+ pageobj.biz +"/");
  414. // s=s.replaceAll(Pattern.quote("wdSrc=\""),Matcher.quoteReplacement(
  415. // "src=\"${sessionScope['wd.yh'].pflj}/help/PC/"+ym.getBusiness()+"/"));
  416. System.out.println(s);
  417. }
  418. // 新增,修改,变动三合一部件:没有html,body,head,form
  419. if (isObjectInput &&
  420. (s.contains("<html") || s.contains("<body") || s.contains("<head") || s.contains("<form")))
  421. isObjectInput = false;
  422. String strUrl; // 再,从上面移到这。Lin
  423. /* 只有 "run"("_run.jsp")了,没有 "view" 了。Lin
  424. * 去掉 replaceStr(),直接用 .replaceAll(replacedStr, "")
  425. * 去掉 appName,直接用 PrjApp.prjName
  426. * replacedStrs(String[]) 值为 [START_TAG, END_TAG]
  427. if (CoreConstVars.RUN.equals(japSuffix)) {
  428. strUrl = s.replaceAll(reg_applicationcode, appName);
  429. strUrl = replaceStr(strUrl, // 被替换的目标字符串
  430. replacedStrs);// 被替换掉的字符串数组
  431. } else {
  432. strUrl = s;
  433. }
  434. */
  435. strUrl = s.replaceAll(reg_applicationcode, prjApp.name); // , PrjApp.。再,支持多线程。Lin
  436. strUrl = strUrl.replaceAll(PageCompC.HTML_begTag, "");
  437. strUrl = strUrl.replaceAll(PageCompC.HTML_endTag, "");
  438. // if (MobileSupport.isMobileYm(ymid)
  439. // && CoreConstVars.VIEW.equals(japSuffix)
  440. // && strUrl.indexOf("base.css") != -1) {
  441. // strUrl = strUrl.replace("base.css", "base_view.css");
  442. // }
  443. /* 去掉 appName,直接用 PrjApp.prjName。Lin
  444. strUrl = transFormAtService(strUrl, appName, null, null, wdgdba);
  445. strUrl = transwdPluginsrc(strUrl, appName, null, null, wdgdba);
  446. */
  447. // strUrl = transFormAtService(strUrl); // 归入 XxxTagComper 了。Lin
  448. strUrl = transwdPluginsrc(strUrl);
  449. /* 去掉,归入 JspTagComper。Lin
  450. List<Map<String, Object>> pageList = StrU.findMatch2(strUrl, reg_pagewrite, 0);
  451. List<Map<String, Object>> wdpageList = StrU.findMatch2(strUrl, reg_wdpage, 0);
  452. */
  453. List<Map<String, Object>> tbodyList = StrU.findMatch2(strUrl, reg_tbody, 0);
  454. List<Map<String, Object>> gotoList = StrU.findMatch2(strUrl, reg_goto, 0);
  455. // ArrayList<Map<String, Object>> matchedCommonWriteList =
  456. // new ArrayList<Map<String, Object>>();
  457. // if (CoreConstVars.TRANSFORM_COMMONWRITE_TAG)
  458. // matchedCommonWriteList.addAll(matchAll2(strUrl,
  459. // common_write_regexp, 0));
  460. // 获取帮助功能的js代码段 start
  461. // if (bjdm != null) {
  462. // String executableJsString = new
  463. // WdHelpAssistAjaxImpl().getExecutableJsString(strUrl, dm,
  464. // bjdm);
  465. // if (executableJsString != null) {
  466. // wdHelpExecutableJsStringList.add(executableJsString);
  467. // }
  468. // }
  469. // 获取帮助功能的js代码段 end
  470. /* 去掉,归入 JspTagComper。Lin
  471. if (pageList.size() > 0)
  472. strUrl = pageUpdate(strUrl, pageList);
  473. if (wdpageList.size() > 0)
  474. strUrl = pageUpdate(strUrl, wdpageList);
  475. */
  476. /* 再改,IDEA:'tbodyList.size() > 0' can be replaced with '!tbodyList.isEmpty()'。Lin
  477. if (tbodyList.size() > 0) {
  478. */ if (!(tbodyList.isEmpty())) {
  479. String tmpe;
  480. for (Map<String, Object> map : tbodyList) {
  481. // String tmpe = ""; // 再,移到 for 上面。IDEA -- Variable 'tmpe' initializer '""' is redundant。Lin
  482. String content = (String) map.get("content");
  483. /* 再改,去掉 id="wdTbody?",好像没用到。Lin
  484. * .ss.jsp 的 <tbody 里,也不写 id="wdTbody0" 了
  485. if (!content.matches(".*id=.*")) {
  486. tmpe = content.replaceAll(">", " id=\"wdTbody" + index++ + "\">");
  487. /// 另,content 里的 <tbody ssOddClazz= ... ssFith='{list:true,rowHeight:35}'> 里的 {} 会导致 java.util.regex.PatternSyntaxException。Lin
  488. strUrl = strUrl.replaceAll(content, tmpe);
  489. ///
  490. content = tmpe;
  491. }
  492. */
  493. tbodyUpdate(tbodyFileList, content);
  494. }
  495. }
  496. /* 再改,IDEA:'gotoList.size() > 0' can be replaced with '!gotoList.isEmpty()'。Lin
  497. if (gotoList.size() > 0) { // new
  498. */ if (!(gotoList.isEmpty())) // new
  499. /* 去掉 appName、ymid、wzid、gdba。Lin
  500. * null = ymid,null = wzid
  501. strUrl = gotoUpdate(strUrl, gotoList, appName, null, null, wdgdba);
  502. */ strUrl = gotoUpdate(strUrl, gotoList);
  503. // if (matchedCommonWriteList.size() > 0) {
  504. // strUrl = updateCommonWriteStr(strUrl,
  505. // matchedCommonWriteList, dm, ymid, wzid);
  506. // }
  507. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  508. * List<String> 改为 List<StringBuilder>
  509. fileContentStrList.add(strUrl);
  510. */ fileContentStrList.add(new StringBuilder(strUrl));
  511. }
  512. // 发布程序自动添加html、head、body start 150209 by ye
  513. /*
  514. * fileContentStrList.add("</body>");
  515. * fileContentStrList.add("</html>");
  516. */
  517. // 发布程序自动添加html、head、body end 150209 by ye
  518. /// 改为在这添加,且只对 dw_inp.jsp 生成 dw_baseInfo.jsp 时。Lin
  519. /* 再去掉,原来的程序有增加 <html>、<body> 等 -- 在 main/sheji/object/baseInfo/init.jsp 里。Lin
  520. if (bySys) {
  521. fileContentStrList.add("</body>");
  522. fileContentStrList.add("</html>");
  523. }
  524. */
  525. ///
  526. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  527. * List<String> 改为 List<StringBuilder>
  528. for (String ss : fileContentStrList) {
  529. */ for (StringBuilder ss : fileContentStrList) {
  530. /// ???
  531. //if (ss.contains("${delete}"))
  532. // System.out.println("fileContentStrList");
  533. ///???
  534. /* 去掉 array 入口参数,直接在方法里定义。Lin
  535. jspUpdate(ss, array, jsFileList, tldFileMap);
  536. */
  537. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  538. * List<String> 改为 List<StringBuilder>
  539. loadExtFileName(ss, jsFileList, tldFileMap, prjApp); // 再增加 PrjApp。Lin
  540. */ loadExtFileName(String.valueOf(ss), jsFileList, tldFileMap, prjApp); // 再增加 PrjApp。Lin
  541. }
  542. boolean tldInited = false;
  543. // ps = new PrintStream(newFilePath);
  544. /* 去掉,isLastOne 没用到。Lin
  545. * 因为 isLastOne 没用到,lastcount 也没用到了
  546. // 计算输出最后一行
  547. int lastcount = 0;
  548. boolean isLastOne = false;
  549. */
  550. // 系统部件
  551. /* 去掉 PageConfig.systemComponent(),直接在 page.xml 里的 <page cat=> 写 "website"/"phome"。Lin
  552. * 去掉 cat,改回用 type 了
  553. * systemComponent(),原:true = 除 "18=PC,80=MD,90=Pad,85=MD Home,95=Pad Home" 外
  554. boolean sysPage = pageExist && PageConfig.systemComponent(pageobj.getType());
  555. */
  556. /* 去掉 isHomep(PageB.type 和 isWebsite(PageB.type,增加 .isHomep 和 .isSitep -- 来自插件的 <pages homep="true"/sitep="true"。Lin
  557. boolean sysPage = pageExist && (isWebsite(pageobj.type, null) // null = DevType。Lin
  558. || isHomep(pageobj.type, null)); // null = DevType。Lin
  559. */ boolean sysPage = pageExist && (pageobj.isSitep || pageobj.isHomep); // null = DevType。Lin
  560. //网站部件不加tld
  561. //属性,预览部件需要
  562. /* 直接用 pageobj.cat 来写判断。Lin
  563. * 去掉 PageObject.tempcode(TempCode) 了
  564. if(sysPage && Long.parseLong(pageobj.getType())<5000l)
  565. tldInited=!pageobj.getTempcode().getName().matches("(property|preview|style)\\_.*");
  566. */
  567. if (pageExist) // 加 pageExist。Lin
  568. /* 去掉 isHomep(PageB.type 和 isWebsite(PageB.type,增加 .isHomep 和 .isSitep -- 来自插件的 <pages homep="true"/sitep="true"。Lin
  569. if (isWebsite(pageobj.type, null)) // null = DevType。Lin
  570. */ if (pageobj.isSitep)
  571. /* 再改,IDEA:Redundant character escape '\\_' in RegExp。Lin
  572. tldInited = !((pageobj.name).matches("(property|preview|style)\\_.*"));
  573. */ tldInited = !((pageobj.name).matches("(property|preview|style)_.*"));
  574. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  575. * List<String> 改为 List<StringBuilder>
  576. for (String str : fileContentStrList) {
  577. */ for (StringBuilder str : fileContentStrList) {
  578. /// ???
  579. //if (str.contains("<equal@ss"))
  580. // System.out.println("fileContentStrList");
  581. ///???
  582. /* 去掉,isLastOne 没用到。Lin
  583. * 因为 isLastOne 没用到,lastcount 也没用到了
  584. lastcount++;
  585. if (fileContentStrList.size() == lastcount) {
  586. isLastOne = true;
  587. }
  588. */
  589. // js自动补充项目代码 <script src="js/a/b.js">---<script
  590. // src="/zzfb_/js/a/b.js">
  591. // String ss[] = findLabelName(str, "script", "src");
  592. // if (ss != null) {
  593. // String src = ss[1];
  594. // String srcV = ss[1];
  595. // if (!src.startsWith("/wd") && !src.startsWith("/")) {
  596. // str = str.replace(srcV, "/" + appName + "/" + srcV);
  597. // }
  598. // }
  599. /* 去掉 appName,直接用 PrjApp.prjName。Lin
  600. str = translateScriptSrc(str, appName);
  601. */
  602. // str = translateScriptSrc(str); // 再去掉,不支持多个应用。Lin
  603. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  604. * List<String> 改为 List<StringBuilder>
  605. if (!tldInited && (("<html>".equalsIgnoreCase(str.trim())) || (isObjectInput)
  606. */ if (!tldInited && (("<html>".equalsIgnoreCase(str.toString().trim())) || (isObjectInput)
  607. // ||(dots.isOutSidePage())
  608. ||(pageExist&&sysPage))) {
  609. /* 再改,IDEA:String concatenation '+=' in loop。Lin。Lin
  610. String top = PageCompC.INTERPOLE_JSPTOP_BEGIN +"\r\n";
  611. */ StringBuilder top = new StringBuilder(PageCompC.INTERPOLE_JSPTOP_BEGIN +"\r\n");
  612. /* 用 PageCompC.HTML_page。Lin
  613. top += "<%@ page language=\"java\" pageEncoding=\"UTF-8\" isELIgnored=\"false\" %>\n";
  614. */
  615. /* 再改,IDEA:String concatenation '+=' in loop。Lin。Lin
  616. top += PageCompC.HTML_page +"\r\n";
  617. */ top.append(PageCompC.HTML_page +"\r\n");
  618. // Set<Entry<String, String>> set = tldFileMap.entrySet();
  619. // Iterator<Entry<String, String>> it = set.iterator();
  620. if (sysPage) {
  621. /* 先去掉,网站页面用到再弄。Lin
  622. * 合并为一个 ss:xxx
  623. top += "<%@ taglib uri=\"/WEB-INF/struts-html.tld\" prefix=\"html\"%>\r\n";
  624. top += "<%@ taglib uri=\"/WEB-INF/struts-bean.tld\" prefix=\"bean\"%>\r\n";
  625. top += "<%@ taglib uri=\"/WEB-INF/struts-logic.tld\" prefix=\"logic\"%>\r\n";
  626. top += "<%@ taglib uri=\"/wd/tld/webcommon.tld\" prefix=\"webcommon\"%>\r\n";
  627. top += "<%@ taglib uri=\"/wd/tld/validation.tld\" prefix=\"validation\" %>\r\n";
  628. top += "<%@ taglib uri=\"/wd/tld/codebook.tld\" prefix=\"codebook\" %>\r\n";
  629. top += "<%@ taglib uri=\"/wd/tld/wd.tld\" prefix=\"wd\" %>\r\n";
  630. top += "<%@ taglib uri=\"/wd/tld/common.tld\" prefix=\"common\" %>\r\n";
  631. top += "<%@ taglib uri=\"/wd/tld/cw.tld\" prefix=\"cw\"%>\r\n";
  632. */
  633. ///// top += PageCompC.HTML_ssTagLib +"\r\n";
  634. top.append(PageCompC.HTML_ssTagLib + "\r\n");
  635. //
  636. } else {
  637. for (Entry<String, String> entry : tldFileMap.entrySet()) {
  638. if ("common".equals(entry.getKey()))
  639. continue;
  640. /* 用 PageCompC.PAGE_taglib。Lin
  641. top += "<%@ taglib uri=\"" + entry.getValue().toString() + "\" prefix=\"" + entry.getKey().toString() + "\"%>\n";
  642. */
  643. /* 再改,IDEA:String concatenation '+=' in loop。Lin。Lin
  644. top += String.format(PageCompC.HTML_tagLib, entry.getValue(), entry.getKey()) +"\r\n";
  645. */ top.append(String.format(PageCompC.HTML_tagLib, entry.getValue(), entry.getKey())).append("\r\n");
  646. }
  647. /* 统一用 ss。Lin
  648. if (!top.contains("prefix=\"wd\"%>"))
  649. top += "<%@ taglib uri=\"/wd/tld/wd.tld\" prefix=\"wd\"%>\n";
  650. if (!top.contains("prefix=\"common\"%>"))
  651. top += "<%@ taglib uri=\"/wd/common.tld\" prefix=\"common\"%>\n";
  652. if (!top.contains("prefix=\"cw\"%>"))
  653. top += "<%@ taglib uri=\"/wd/tld/cw.tld\" prefix=\"cw\"%>\n";
  654. */
  655. /* 再改,IDEA:String concatenation '+=' in loop。Lin。Lin
  656. if (!top.contains("prefix=\"ss\"%>"))
  657. top += PageCompC.HTML_ssTagLib +"\r\n";
  658. */
  659. if (!top.toString().contains("prefix=\"ss\"%>"))
  660. top.append(PageCompC.HTML_ssTagLib + "\r\n");
  661. }
  662. // if (CoreConstVars.TRANSFORM_COMMONWRITE_TAG)
  663. // top +=
  664. // "<%@ taglib uri=\"/wd/cw.tld\" prefix=\"cw\"%>\n";
  665. /* 去掉 getSetAppNameStr(),直接用 readJspCont(String jspPath, String defaultCont, String reg, String replace)。Lin
  666. * 去掉 appName,直接用 PrjApp.prjName
  667. top += getSetAppNameStr(appName);
  668. */
  669. // 再去掉,不写应用名。Lin
  670. // top += PageU.readJspCont(SET_APPNAME_JSP, SET_APPNAME_SCRIPT, "#{APPNAME}#", PrjApp.prjName);
  671. if (pageExist && (StringUtils.isNotBlank(pageobj.objName))) {
  672. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  673. /* 去掉 CoreConstVars.PAGE_CONTEXT_VIEWOBJECT,用 。Lin
  674. top+="\r\n<% pageContext.setAttribute(wd.core.common.CoreConstVars.PAGE_CONTEXT_VIEWOBJECT,\""+pageobj.getObjectName()+"\");%>\r\n";
  675. */
  676. /* 再改,IDEA:String concatenation '+=' in loop。Lin。Lin
  677. top+="\r\n<% pageContext.setAttribute(ss.page.PageC.PAGE_objName,\""
  678. + pageobj.objName +"\");%>\r\n";
  679. */ top.append("\r\n<% pageContext.setAttribute(ss.page.PageC.PAGE_objName,\"")
  680. .append(pageobj.objName).append("\");%>\r\n");
  681. }
  682. if (pageExist) {
  683. Map<String,String> a = new HashMap<>();
  684. a.put("hastab", (hasTab? "1" : "0")); // UrlEntry.RUNNING_CONDITION_HAS_TAB
  685. /* toJsonStr() 的串里,\" 改用 '。Lin
  686. * 原 "{\"hastab\":\"0\"}",改为 ,"{'hastab':'0'}"
  687. top += "\r\n<%pageContext.setAttribute(\"wdpageinformation\",\""
  688. + StrJson.toJsonStr(a).replaceAll("\"","\\\\\"")+"\");%>\r\n";
  689. */
  690. /* 再改,IDEA:String concatenation '+=' in loop。Lin。Lin
  691. top += "<%pageContext.setAttribute(\"wdpageinformation\",\""
  692. + new Gson().toJson(a).replaceAll("\"", "'") +"\");%>\r\n";
  693. */ top.append("<%pageContext.setAttribute(\"wdpageinformation\",\"")
  694. .append(new Gson().toJson(a).replaceAll("\"", "'")).append("\");%>\r\n");
  695. // 去掉 StrJson.toJsonStr(),直接用 new Gson().toJson()。Lin
  696. }
  697. /* 用 PageCompC.。Lin
  698. top += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
  699. */
  700. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  701. top += PageCompC.HTML_docType +"\r\n";
  702. */ top.append(PageCompC.HTML_docType +"\r\n");
  703. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  704. top += PageCompC.INTERPOLE_JSPTOP_END +"\r\n";
  705. */ top.append(PageCompC.INTERPOLE_JSPTOP_END +"\r\n");
  706. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  707. * List<String> 改为 List<StringBuilder>
  708. str = top + str;
  709. */ str = top.append(str);
  710. tldInited = true;
  711. /* 去掉,没有 _view.jsp 了。Lin
  712. if (isViewJsp && isObjectInput) {
  713. // str += "<wd:write type='skin'></wd:write>\n";
  714. str += new CommonWriteFactory(appName, null, null, wdgdba).transform("<wd:write type='skin'></wd:write>");
  715. str += "<script type=\"text/javascript\" src=\"/wd/js/jquery.js\"></script>\r\n";
  716. str += "<script type=\"text/javascript\" src=\"/wd/js/wdDialogInit.js\"></script>\r\n";
  717. str += "<script type=\"text/javascript\" src=\"/wd/js/common.js\"></script>\r\n";
  718. str += "<script type=\"text/javascript\" src=\"/wd/display.js\"></script>\r\n";
  719. str += "<script type=\"text/javascript\" src=\"/wd/edit.js\"></script>\r\n";
  720. }
  721. */
  722. }
  723. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  724. * List<String> 改为 List<StringBuilder>
  725. if ("<head>".equalsIgnoreCase(str.trim())) {
  726. str += "\r\n"+ PageCompC.INTERPOLE_HEAD_BEGIN;
  727. */
  728. if ("<head>".equalsIgnoreCase(str.toString().trim())) {
  729. str.append("\r\n"+ PageCompC.INTERPOLE_HEAD_BEGIN);
  730. /* 改为新UI。Lin
  731. * "新UI,所有head引入的内容,都放到/page/clip/header.jsp文件中"
  732. /// * 用 PageCompC.PAGE_meta。Lin
  733. // str += "<meta http-equiv=\"pragma\" content=\"no-cache\">\n"
  734. // + "<meta http-equiv=\"cache-control\" content=\"no-cache\">\n"
  735. // + "<meta http-equiv=\"expires\" content=\"0\">\n";
  736. /// *
  737. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  738. // * List<String> 改为 List<StringBuilder>
  739. // str += "\r\n"+ PageCompC.HTML_meta;
  740. /// *
  741. str.append("\r\n"+ PageCompC.HTML_meta);
  742. // 移动端分支 移动端标准样式 update by Rd 2016-03-29
  743. // if (isMobile()) {
  744. // str += "<LINK href=\"/wd/theme/standard/mobileStyle.css\" rel=\"stylesheet\" type=\"text/css\">\n";
  745. // } else {
  746. // style.css只有一个2017-08-07
  747. // 暂时写死 20150210
  748. /// * 去掉 getSetAppNameStr(),用 readJspCont(String jspPath, String defaultCont, String reg, String replace)。Lin
  749. // * 去掉 appName,直接用 PrjApp.prjName
  750. // str += getSetXmdmJspCode(appName);
  751. /// *
  752. /// * 去掉,不写应用名。Lin
  753. // str += PageU.readJspCont(SET_XMDM_JSP, SET_XMDM_SCRIPT, "#{XMDM}#", PrjApp.prjName);
  754. /// *
  755. /// * 用 PageCompC.。Lin
  756. // str += "<script>window.loginStatus='${empty sessionScope[\"wd.yh\"]?'0':'1'}'</script>\r\n";
  757. /// *
  758. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  759. // * List<String> 改为 List<StringBuilder>
  760. // str += "\r\n"+ PageCompC.SCR_loginState;
  761. /// *
  762. str.append("\r\n"+ PageCompC.SCR_loginState);
  763. /// * 用 @ss。Lin
  764. // String strSkinString = "<wd:write type='skin' t='general'></wd:write>";
  765. /// *
  766. /// * 再改为 .ss,用 @ 导致 IDEA -- Tag start is not closed。Lin
  767. // String strSkinString = "<skin@ss file='/ss/main'/>";
  768. /// *
  769. String strSkinString = "<skin.ss file='/ss/main'/>";
  770. // if (CoreConstVars.TRANSFORM_COMMONWRITE_TAG) {
  771. /// * 去掉了 CommonWriteFactory() 结构函数。Lin
  772. // * 去掉 appName,直接用 PrjApp.prjName
  773. // * 去掉 CommonWriteFactory,归入 TagComper
  774. // * 用 TagComper.transform(str),SkinTagComper 没盖写过
  775. // str += new CommonWriteFactory(appName, null, null, wdgdba).getTransformer("skin").transform(strSkinString) + "\r\n";
  776. /// *
  777. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  778. // * List<String> 改为 List<StringBuilder>
  779. // str += "\r\n"+ TagComper.compTag(strSkinString);
  780. /// *
  781. str.append("\r\n").append(TagComper.compTag(strSkinString));
  782. // } else {
  783. // str += strSkinString;
  784. // }
  785. // 跟页面样式有关的语句,请勿胡乱注释
  786. // str +=
  787. // "<LINK href=\"/wd/theme/standard/style.css\"
  788. // rel=\"stylesheet\" type=\"text/css\">\n";
  789. // }
  790. /// 不写死引入 JS、CSS,自动找到并引入 -- 以后再弄。Lin
  791. /// 添加帮助功能的css和js start ///
  792. // if (bjdm != null) {
  793. // str +=
  794. // "<link rel=\"stylesheet\" type=\"text/css\" href=\"/env/js/artDialog/skins/chrome_red.css\"/>\n";
  795. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  796. // * List<String> 改为 List<StringBuilder>
  797. // str += "\r\n<script type=\"text/javascript\" src=\"/ss/jquery/jquery.js\"></script>";
  798. // // /wd/js/。Lin
  799. /// *
  800. str.append("\r\n<script type=\"text/javascript\" src=\"/ss/jquery/jquery.js\"></script>");
  801. // str +=
  802. // "<script type=\"text/javascript\" src=\"/wd/js/artDialog/artDialog.js\"></script>\r\n";
  803. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  804. // * List<String> 改为 List<StringBuilder>
  805. // str += "\r\n<script type=\"text/javascript\" src=\"/ss/artdialog/artDialogUtil.js\"></script>";
  806. // // /wd/js/artDialog/。Lin
  807. /// *
  808. str.append("\r\n<script type=\"text/javascript\" src=\"/ss/artdialog/artDialogUtil.js\"></script>");
  809. // str +=
  810. // "<script type=\"text/javascript\" src=\"/env/js/clipboard/clipboard.min.js\"></script>\r\n";//
  811. // 剪切板js
  812. // }
  813. /// 添加帮助功能的css和js end ///
  814. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  815. // * List<String> 改为 List<StringBuilder>
  816. // str += "\r\n<script type=\"text/javascript\" src=\"/ss/js/base.js\"></script>"
  817. // // /wd/。Lin
  818. // + "\r\n<script> if(!window.wd) var wd={}; if(!wd.display) wd.display={}; wd.display.wdDialogId=\""
  819. // + (pageExist? pageobj.name : 1) // pageobj.getId()。用 name,不用 id。Lin
  820. // + "\"; if(!wd.app) wd.app={}; wd.app.name='"
  821. // + prjApp.name // 去掉 appName,直接用 PrjApp.prjName。Lin // + PrjApp.。再,支持多线程。Lin
  822. // + "';"
  823. // // "\r\nif(!wd.topWindow.wd.display.wdDialogWindows)wd.topWindow.wd.display.wdDialogWindows
  824. // // = {};"
  825. // // +"wd.topWindow.wd.display.wdDialogWindows["+bjId+"]=window;"+
  826. // + "</script>";
  827. // str += "\r\n<script type=\"text/javascript\" src=\"/ss/js/masklayer.js\"></script>";
  828. // // /wd/js/。Lin
  829. /// *
  830. str.append("\r\n<script type=\"text/javascript\" src=\"/ss/js/base.js\"></script>")
  831. .append("\r\n<script> if(!window.wd) var wd={}; if(!wd.display) wd.display={}; wd.display.wdDialogId=\"")
  832. .append(pageExist? pageobj.name : 1)
  833. .append("\"; if(!wd.app) wd.app={}; wd.app.name='")
  834. .append(prjApp.name) // 去掉 appName,直接用 PrjApp.prjName。Lin // + PrjApp.。再,支持多线程。Lin
  835. .append("';</script>");
  836. str.append("\r\n<script type=\"text/javascript\" src=\"/ss/js/masklayer.js\"></script>");
  837. // str += "<script
  838. // type=\"text/javascript\">document.ready(function(){
  839. // window.top.clearToken();});</script>\r\n ";
  840. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  841. // * List<String> 改为 List<StringBuilder>
  842. // str += "\r\n<script type=\"text/javascript\" src=\"/ss/js/wdDialogInit.js\"></script>";
  843. // // /wd/js/。Lin
  844. // str += "\r\n<script type=\"text/javascript\" src=\"/ss/js/common.js\"></script>";
  845. // // /wd/js/。Lin
  846. // str += "\r\n<script type=\"text/javascript\" src=\"/ss/js/display.js\"></script>";
  847. // // /wd/。Lin
  848. // str += "\r\n<script type=\"text/javascript\" src=\"/ss/js/edit.js\"></script>";
  849. // // /wd/。Lin
  850. /// *
  851. str.append("\r\n<script type=\"text/javascript\" src=\"/ss/js/wdDialogInit.js\"></script>");
  852. str.append("\r\n<script type=\"text/javascript\" src=\"/ss/js/common.js\"></script>");
  853. str.append("\r\n<script type=\"text/javascript\" src=\"/ss/js/display.js\"></script>");
  854. str.append("\r\n<script type=\"text/javascript\" src=\"/ss/js/edit.js\"></script>");
  855. // 伪滚动条
  856. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  857. // * List<String> 改为 List<StringBuilder>
  858. // str += "\r\n<script type=\"text/javascript\" src=\"/ss/nicescroll/jquery.nicescroll.js\"></script>";
  859. // // /wd/js/nicescroll376/。Lin
  860. // str += "\r\n<script type=\"text/javascript\" src=\"/ss/nicescroll/jquery.nicescroll.iframehelper.min.js\"></script>";
  861. // // /wd/js/nicescroll376/。Lin
  862. /// *
  863. str.append("\r\n<script type=\"text/javascript\" src=\"/ss/nicescroll/jquery.nicescroll.js\"></script>");
  864. str.append("\r\n<script type=\"text/javascript\" src=\"/ss/nicescroll/jquery.nicescroll.iframehelper.min.js\"></script>");
  865. // System.out.println("...<script> var
  866. // wdDialogId="+bjId+"; </script>");
  867. for (String file : jsFileList) {
  868. if (StringUtils.isBlank(file)) // 去掉 StrU.isNull(),直接用 StringUtils.isBlank()。Lin
  869. continue;
  870. String fileLower = file.toLowerCase();
  871. // System.out.println("file:"+file);
  872. if (fileLower.endsWith(".js"))
  873. /// * 用 PageCompC.。Lin
  874. // str += "<script type=\"text/javascript\" src=\"" + file + "\"></script>\r\n";
  875. /// *
  876. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  877. // * List<String> 改为 List<StringBuilder>
  878. // str += "\r\n"+ String.format(PageCompC.HTML_js, file);
  879. /// *
  880. str.append("\r\n").append(String.format(PageCompC.HTML_js, file));
  881. else
  882. /// * 用 PageCompC.。Lin
  883. // str += "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + file + "\">\r\n";
  884. /// *
  885. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  886. // * List<String> 改为 List<StringBuilder>
  887. // str += "\r\n"+ String.format(PageCompC.HTML_css, file);
  888. /// *
  889. str.append("\r\n").append(String.format(PageCompC.HTML_css, file));
  890. }
  891. */ str.append("\r\n" + PageCompU.getIncludeTag(PageCompC.PAGE_CLIP_PATH_header));
  892. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  893. * List<String> 改为 List<StringBuilder>
  894. str += "\r\n"+ PageCompC.INTERPOLE_HEAD_END;
  895. */ str.append("\r\n" + PageCompC.INTERPOLE_HEAD_END);
  896. }
  897. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  898. * List<String> 改为 List<StringBuilder>
  899. if ("</body>".equalsIgnoreCase(str.trim())) {
  900. */ if ("</body>".equalsIgnoreCase(str.toString().trim())) {
  901. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  902. String script = ""; // 定义放在增加的 if {} 外面。Lin
  903. */ StringBuilder script = new StringBuilder(); // 定义放在增加的 if {} 外面。Lin
  904. /* 再改,IDEA:'tbodyFileList.size() > 0' can be replaced with '!tbodyFileList.isEmpty()'。Lin
  905. if (tbodyFileList.size() > 0) { // 增加判断,避免输出空的 <script> </script>。Lin
  906. */ if (!(tbodyFileList.isEmpty())) { // 增加判断,避免输出空的 <script> </script>。Lin
  907. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  908. script = "<script type=\"text/javascript\">\r\n";
  909. */ script.append("<script type=\"text/javascript\">\r\n");
  910. for (String tbodyStr : tbodyFileList) {
  911. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  912. script += tbodyStr +"\r\n";
  913. */ script.append(tbodyStr).append("\r\n");
  914. }
  915. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  916. script+="</script>";
  917. */ script.append("</script>");
  918. }
  919. //script += "</script>\n\r" + "<%@include file=\"/wd/page/glbjRunJspCommonEnd.jsp\"%>\n\r";
  920. // script +=
  921. // "<script type=\"text/javascript\">(function(){var
  922. // _onunload=window.onunload;window.onunload =
  923. // function(){_onunload&&_onunload();window.top.clearToken('<wd:token
  924. // service='wd.removePageToken' dest='' param=''
  925. // />',{'tokenList':'<%=
  926. // pageContext.getAttribute(wd.core.common.CoreConstVars.WD_PAGE_TOKENLIST)%>'});};})()</script>\r\n";
  927. if(pageExist)
  928. /* 去掉 Tempcode。Lin
  929. if (wdFitHeight || wdDragHeight || pageobj.getTempcode().isEnvPage()) {
  930. */ if (wdFitHeight || wdDragHeight || pageobj.isEnv) {
  931. if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  932. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  933. script += "\r\n"; // 增加。Lin
  934. */ script.append("\r\n"); // 增加。Lin
  935. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  936. script += "<script type=\"text/javascript\" src=\"/ss/js/wdFitHeight.js\"></script>\r\n";
  937. script += "<script type=\"text/javascript\">initWdFitHeight("
  938. + pageobj.fixHeight +")</script>\r\n";
  939. script += "<script type=\"text/javascript\">initWdFitHeightFunction=function(){initWdFitHeight("
  940. + pageobj.fixHeight +");};</script>";
  941. */
  942. script.append("<script type=\"text/javascript\" src=\"/ss/js/wdFitHeight.js\"></script>\r\n");
  943. script.append("<script type=\"text/javascript\">initWdFitHeight(")
  944. .append(pageobj.fixHeight).append(")</script>\r\n");
  945. script.append("<script type=\"text/javascript\">initWdFitHeightFunction=function(){initWdFitHeight(")
  946. .append(pageobj.fixHeight).append(");};</script>");
  947. }
  948. // if ("env".equals(ym.getDm())) {
  949. // script += "<script type=\"text/javascript\" src=\"/wd/js/EnvPublic.js\"></script>\r\n";
  950. // }
  951. if (wdDragHeight) {
  952. if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  953. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  954. script += "\r\n"; // 增加。Lin
  955. */ script.append("\r\n"); // 增加。Lin
  956. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  957. script += "<script type=\"text/javascript\" src=\"/ss/js/wdDragHeight.js\"></script>\r\n";
  958. script += "<script type=\"text/javascript\">initWdDragHeight("
  959. + pageobj.fixHeight + ")</script>";
  960. */
  961. script.append("<script type=\"text/javascript\" src=\"/ss/js/wdDragHeight.js\"></script>\r\n");
  962. script.append("<script type=\"text/javascript\">initWdDragHeight(")
  963. .append(pageobj.fixHeight).append(")</script>");
  964. }
  965. if (wdDragWidth) {
  966. if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  967. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  968. script += "\r\n"; // 增加。Lin
  969. */ script.append("\r\n"); // 增加。Lin
  970. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  971. script += "<script type=\"text/javascript\" src=\"/ss/js/wdDragWidth.js\"></script>\r\n";
  972. script += "<script type=\"text/javascript\">initWdDragWidth(null)</script>";
  973. */
  974. script.append("<script type=\"text/javascript\" src=\"/ss/js/wdDragWidth.js\"></script>\r\n");
  975. script.append("<script type=\"text/javascript\">initWdDragWidth(null)</script>");
  976. }
  977. /// 添加可配置二级选项卡js start ///
  978. //noinspection SuspiciousIndentAfterControlStatement
  979. if (pageExist)
  980. if (hasTab) {
  981. if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  982. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  983. script += "\r\n"; // 增加。Lin
  984. */ script.append("\r\n"); // 增加。Lin
  985. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  986. script += "<script type='text/javascript'>wd.display.wdTabNo='${wdTabNo}';</script>";
  987. script += "<script type=\"text/javascript\" src=\"/ss/js/wdDrag.js\"></script>\r\n";
  988. script += "<script type=\"text/javascript\" src=\"/ss/js/configurableTab.js\"></script>\r\n";
  989. script += String.format("<script type=\"text/javascript\"> \nwd.configurableTab.init(%s,\"%s\");</script>",
  990. 1, pageobj.name); // 不用 id -- pageobj.getId()。Lin
  991. */
  992. script.append("<script type='text/javascript'>wd.display.wdTabNo='${"+ TabC.TAB_nextNo +"}';</script>");
  993. script.append("<script type=\"text/javascript\" src=\"/ss/js/wdDrag.js\"></script>\r\n");
  994. script.append("<script type=\"text/javascript\" src=\"/ss/js/configurableTab.js\"></script>\r\n");
  995. script.append(String.format("<script type=\"text/javascript\"> \r\n"+
  996. "wd.configurableTab.init(%s,\"%s\");</script>", 1, pageobj.name));
  997. }
  998. if (pageExist) {
  999. /* 用 PageCompC.。Lin
  1000. script += "<wd:equal leftValue=\"${empty resizeComponent}\" rightValue=\"false\">\r\n";
  1001. script += "<script>"
  1002. + "{var iframe = wd.display.getFrameOfWindow();"
  1003. + "if(iframe&&iframe.contentWindow == window)wd.display.resizeComponent(${resizeComponent.width}, ${resizeComponent.height}, ${empty resizeComponent.minHeight?'null':resizeComponent.minHeight}, ${empty resizeComponent.maxHeight?'null':resizeComponent.maxHeight});"
  1004. + "}" + "</script>\r\n";
  1005. script += "</wd:equal>\r\n";
  1006. */
  1007. if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  1008. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1009. script += "\r\n"; // 增加。Lin
  1010. */ script.append("\r\n"); // 增加。Lin
  1011. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1012. script += PageCompC.SCR_resizeWin;
  1013. */ script.append(PageCompC.SCR_resizeWin);
  1014. }
  1015. // }else{
  1016. // script +=
  1017. // "<script type=\"text/javascript\">
  1018. // \nwd.display.initTab();</script>\r\n";
  1019. // }
  1020. /// 添加帮助功能的js start ///
  1021. // script += "<script type=\"text/javascript\">";
  1022. // for (int i = 0; i < wdHelpExecutableJsStringList.size();
  1023. // i++) {
  1024. // script += wdHelpExecutableJsStringList.get(i);
  1025. // }
  1026. // script += "</script>\r\n";
  1027. // if (StringUtil.notNull(bjdm))
  1028. /* 去掉 appName,直接用 PrjApp.prjName。Lin
  1029. * 用 @ss
  1030. * 移到 PageCompU
  1031. str = "\r\n" + transformCommonwrite("<common:write type=\"wdhelp\" />", appName, null, null, wdgdba) + "\r\n" + str;
  1032. */
  1033. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1034. * List<String> 改为 List<StringBuilder>
  1035. str = PageCompU.compTag("<help@ss/>") +"\r\n"+ str;
  1036. */
  1037. /* 再改为 .ss,用 @ 导致 IDEA -- Tag start is not closed。Lin
  1038. str = new StringBuilder(PageCompU.compTag("<help@ss/>") +"\r\n"+ str);
  1039. */ str = new StringBuilder(PageCompU.compTag("<help.ss/>") +"\r\n"+ str);
  1040. if (StringUtils.isNotBlank(script)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  1041. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1042. * List<String> 改为 List<StringBuilder>
  1043. str = script +"\r\n" + str;
  1044. */ str = new StringBuilder(script).append("\r\n").append(str);
  1045. /// 添加帮助功能的js end ///
  1046. /// 添加字段初始化功能 start ///
  1047. if(pageExist){//判断是否需要添加字段初始化的js
  1048. /* 用 PageCompC.。Lin
  1049. StringBuilder wdRecordJs = new StringBuilder();
  1050. wdRecordJs.append("<script type='text/javascript'>var wdRecordValue='${wdRecordValue}';</script>\n");
  1051. wdRecordJs.append("<script type='text/javascript' src='/wd/js/wdRecord/wdRecord.js'></script>");
  1052. wdRecordJs.append("<script type=\"text/javascript\">");
  1053. wdRecordJs.append("(function(){wdRecord('" + pageobj.name + "');})();"); // pageobj.getId()
  1054. wdRecordJs.append("</script>\r\n");
  1055. str = wdRecordJs.toString() + str;
  1056. */
  1057. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1058. * List<String> 改为 List<StringBuilder>
  1059. str = String.format(PageCompC.SCR_pval, pageobj.name) +"\r\n" + str;
  1060. */ str = new StringBuilder(String.format(PageCompC.SCR_pval, pageobj.name)).append("\r\n").append(str);
  1061. }
  1062. /// 添加字段初始化功能 end ///
  1063. String stript="";
  1064. if(pageExist && !showMsgPopup){
  1065. /* 用 PageCompC.。Lin
  1066. * 增加 <script> </script>
  1067. stript +=
  1068. "try{\r\n"
  1069. + "wd.display.showMsgPopup('${msg}');\r\n"
  1070. +"}catch(err){\r\n"
  1071. +"console.error(err);\r\n"
  1072. +"}";
  1073. */
  1074. stript += PageCompC.SCR_popupMsg;
  1075. }
  1076. if(pageExist){
  1077. /* 用 PageCompC.。Lin
  1078. * 增加 <script> </script>
  1079. stript +=
  1080. "<wd:equal leftValue=\"${empty "+PageC.WIN_closeParm+"}\" rightValue=\"false\">"
  1081. +"try{\r\n"
  1082. + "wd.display.setCloseWindowParam('${"+PageC.WIN_closeParm+"}');\r\n"
  1083. +"}catch(err){\r\n"
  1084. +"console.error(err);\r\n"
  1085. +"}"
  1086. +"</wd:equal>";
  1087. */
  1088. if (StringUtils.isNotBlank(stript)) // 增加。去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  1089. stript += "\r\n"; // 增加。Lin
  1090. stript += String.format(PageCompC.SCR_wrCloseWinParm, PageC.WIN_closeParm, PageC.WIN_closeParm);
  1091. }
  1092. /* 去掉,已含 <script> </script>。Lin
  1093. if(StrU.notNull(stript)){
  1094. str+="<script type='text/javascript'>\r\n"
  1095. +stript
  1096. +"\r\n</script>\r\n";
  1097. }
  1098. */
  1099. if (StringUtils.isNotBlank(stript)) // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  1100. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1101. * List<String> 改为 List<StringBuilder>
  1102. str = str +"\r\n"+ stript;
  1103. */ str.append("\r\n").append(stript);
  1104. }
  1105. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1106. * List<String> 改为 List<StringBuilder>
  1107. if ("</html>".equalsIgnoreCase(str.trim())) {
  1108. */ if ("</html>".equalsIgnoreCase(str.toString().trim()))
  1109. /* 去掉 getClearTokenScript(),统一用 PageUtil.readJspCont()。Lin
  1110. str += getClearTokenScript();
  1111. */
  1112. /* 再改用 PageCompC.SCR_clearToken。Lin
  1113. str += PageU.readJspCont(CLEAR_TOKEN_JSP, CLEAR_TOKEN_SCRIPT, null, null); // null = 不替换
  1114. */
  1115. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1116. * List<String> 改为 List<StringBuilder>
  1117. str += "\r\n"+ PageCompC.SCR_clearPageToken;
  1118. */
  1119. // str.append("\r\n"+ PageCompC.SCR_clearPageToken); 固定的页面尾片断,改为引入/page/clip/footer.jsp Ben(20251225)
  1120. str.append("\r\n" + PageCompU.getIncludeTag(PageCompC.PAGE_CLIP_PATH_footer));
  1121. String strStr = str.toString(); // 增加,不改原 String.replace(。Lin
  1122. //noinspection SuspiciousIndentAfterControlStatement
  1123. if (pageExist)
  1124. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1125. * List<String> 改为 List<StringBuilder>
  1126. if (str.contains("</form>")) {
  1127. str = str.replace("</form>", "<input name='wdComponentID' type='hidden' value='"
  1128. + pageobj.name +"'/></form>"); // pageobj.getId()
  1129. }
  1130. result.append(str +"\r\n");
  1131. */
  1132. if (strStr.contains("</form>"))
  1133. strStr = strStr.replace("</form>", "<input name='wdComponentID' type='hidden' value='"
  1134. + pageobj.name +"'/></form>"); // pageobj.getId()
  1135. result.append(strStr).append("\r\n");
  1136. // ps.println();// 输出到新文件
  1137. }
  1138. String sourceHtml = result.toString();
  1139. /* 去掉 bjlbm,直接用 .cat 来判断。Lin
  1140. * 去掉 cat 改回用 type 判断
  1141. Long bjlbm=pageExist?Long.parseLong(pageobj.getBjlbm()):null;
  1142. if (pageExist&&bjlbm >= 5000 && bjlbm <= 10000) {
  1143. */
  1144. /* 去掉 isHomep(PageB.type 和 isWebsite(PageB.type,增加 .isHomep 和 .isSitep -- 来自插件的 <pages homep="true"/sitep="true"。Lin
  1145. if (pageExist && isHomep(pageobj.type, null)) { // null = DevType。Lin
  1146. */ if (pageExist && pageobj.isHomep) { // null = DevType。Lin
  1147. StringBuilder sb = new StringBuilder();
  1148. int start = sourceHtml.indexOf(PageCompC.INTERPOLE_JSPTOP_BEGIN);
  1149. int end = sourceHtml.indexOf(PageCompC.INTERPOLE_JSPTOP_END);
  1150. if (start != -1 && end != -1)
  1151. /* 再改,IDEA:Call to 'substring()' is redundant。Lin
  1152. sb.append(sourceHtml.substring(start + PageCompC.INTERPOLE_JSPTOP_BEGIN.length(), end));
  1153. */ sb.append(sourceHtml, start + PageCompC.INTERPOLE_JSPTOP_BEGIN.length(), end);
  1154. start = sourceHtml.indexOf(PageCompC.INTERPOLE_HEAD_END);
  1155. end = sourceHtml.indexOf("</head");
  1156. if (start != -1 && end != -1)
  1157. /* 再改,IDEA:Call to 'substring()' is redundant。Lin
  1158. sb.append(sourceHtml.substring(start + PageCompC.INTERPOLE_HEAD_END.length(), end));
  1159. */ sb.append(sourceHtml, start + PageCompC.INTERPOLE_HEAD_END.length(), end);
  1160. start = sourceHtml.indexOf("<body");
  1161. start = sourceHtml.indexOf("<", start + 5);
  1162. end = sourceHtml.indexOf("</body");
  1163. sb.append("\n");
  1164. /* 再改,IDEA:Call to 'substring()' is redundant。Lin
  1165. sb.append(sourceHtml.substring(start, end));
  1166. */ sb.append(sourceHtml, start, end);
  1167. /* 去掉 getClearTokenScript(),统一用 PageUtil.readJspCont()。Lin
  1168. sb.append(getClearTokenScript());
  1169. */
  1170. /* 再改,用 PageCompC.SCR_clearToken。Lin
  1171. sb.append(PageU.readJspCont(CLEAR_TOKEN_JSP, CLEAR_TOKEN_SCRIPT, null, null)); // null = 不替换
  1172. */
  1173. // sb.append("\r\n"+ PageCompC.SCR_clearPageToken +"\r\n"); 固定的页面尾片断,改为引入/page/clip/footer.jsp Ben(20251225)
  1174. sb.append("\r\n" + PageCompU.getIncludeTag(PageCompC.PAGE_CLIP_PATH_footer));
  1175. sourceHtml=sb.toString();
  1176. } else {
  1177. // 去除 辅助标签
  1178. sourceHtml = sourceHtml.replace(PageCompC.INTERPOLE_JSPTOP_BEGIN +"\r\n", "");
  1179. sourceHtml = sourceHtml.replace(PageCompC.INTERPOLE_JSPTOP_END +"\r\n", "");
  1180. sourceHtml = sourceHtml.replace(PageCompC.INTERPOLE_HEAD_BEGIN +"\r\n", "");
  1181. sourceHtml = sourceHtml.replace(PageCompC.INTERPOLE_HEAD_END +"\r\n", "");
  1182. }
  1183. Map<String, String> csc = new HashMap<>();
  1184. /* 不支持多个应用。Lin
  1185. * 去掉 ApplicationConfig(application.xml),归入 SsC
  1186. * 去掉 appName,直接用 PrjApp.prjName
  1187. WebApp app=WD.getApp(appName);
  1188. csc.put("projectDesc", app.getApplicationConfig().getProjectDesc());
  1189. csc.put("appName", appName);
  1190. */
  1191. csc.put("appName", prjApp.name); // , PrjApp.。再,支持多线程。Lin
  1192. csc.put("projectDesc", prjApp.desc); // , PrjApp.。再,支持多线程。Lin
  1193. sourceHtml = PageU.paseSymbol(csc, sourceHtml); // DesignOutSide.paseSymbol()
  1194. /* 再改,IDEA:'new File(tgtFileName).getParentFile().exists()==false'
  1195. * can be simplified to '!new File(tgtFileName).getParentFile().exists()'。Lin
  1196. if(new File(tgtFileName).getParentFile().exists()==false)
  1197. */ if (!(new File(tgtFileName).getParentFile().exists()))
  1198. new File(tgtFileName).getParentFile().mkdirs();
  1199. FileU.wrStr(tgtFileName, sourceHtml);
  1200. } catch (Exception e) {
  1201. /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
  1202. e.printStackTrace();
  1203. */ log4j.error("PageComper.doCompPage( 异常", e);
  1204. ThdLog.wrMsg(String.format(AppC.TITLE_errLine, "编译部件错误"), e.toString(), e.getCause()); // RlsLoger.。Lin
  1205. throw e;
  1206. } finally {
  1207. if (in != null)
  1208. in.close();
  1209. }
  1210. // return; // 去掉,不必要 -- 按 IDEA 规范。Lin
  1211. }
  1212. /// **
  1213. // *
  1214. // * script script补充项目代码
  1215. // * @param srcStr
  1216. // * @param appName
  1217. // * @return
  1218. /// *
  1219. /* 去掉,不支持多个应用。Lin
  1220. // 来自 FileTranslator.translateScriptSrc()。Lin
  1221. // 去掉 appName,直接用 PrjApp.prjName
  1222. // public static String translateScriptSrc(String srcStr,String appName) {
  1223. private static String translateScriptSrc(String srcStr){
  1224. String ss[] = StrWeb.findLabelName(srcStr, "script", "src");
  1225. if (ss != null) {
  1226. String src = ss[1];
  1227. String srcV = ss[1];
  1228. if (!src.startsWith("/")) {
  1229. srcStr = srcStr.replace(srcV, "/"+ PrjApp.prjName +"/"+ srcV); // appName。Lin
  1230. }
  1231. }
  1232. return srcStr;
  1233. }
  1234. */
  1235. // 来自 FileTranslator.jspUpdate(String s, String[] array, List<String> jsFileList, Map<String, String> tldFileMap)。Lin
  1236. // 合并 toLeadJsMap 和 toLeadTldMap 到 grpMapMap
  1237. // 去掉 array,直接在 jspUpdate() 里定义
  1238. // 再增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程。Lin
  1239. private static void loadExtFileName(String s, List<String> jsFileList, Map<String, String> tldFileMap,
  1240. PrjApp prjApp) {
  1241. String[] array = { "wd", prjApp.name }; // "wd",appName。从 createNewFileWithUrl() 里移下来。Lin
  1242. // , PrjApp.。再,支持多线程。Lin
  1243. // 先用 "wd",不用 WebC.SS_name -- 改动太大。Lin
  1244. String jspReg;
  1245. // String tldReg = ""; // 去掉,改用 PageCompC.PAGE_tldReg。Lin
  1246. for (String yym : array) {
  1247. /* 用 PageCompC.PAGE_JsCssReg。Lin
  1248. jspReg = "([\\W" + yym + "]\\.)([\\w*\\.]*)?(\\W)";
  1249. */ jspReg = String.format(PageCompC.PAGE_jsCssReg, yym);
  1250. // tldReg = "<(\\w+:)(\\w+\\s*?.*?)>"; // 去掉,改用 PageCompC.PAGE_tldReg。Lin
  1251. List<Map<String, Object>> jspList = StrU.findMatch2(s, jspReg, 2);
  1252. List<Map<String, Object>> tldList = StrU.findMatch2(s, PageCompC.PAGE_tldReg, 1); // tldReg。Lin
  1253. // System.out.println("应用名:"+yym+"--:"+WD.getApp(yym));
  1254. /* 去掉,不支持多个应用。Lin
  1255. * WD 用 SsApp.grpMapSsMap,项目用 PrjApp.grpMapMap
  1256. * 不区分 toLeadJsMap 和 toLeadTldMap,用 .grpMapMap
  1257. WebApp app = WD.getApp(yym);
  1258. if (app == null)
  1259. continue;
  1260. Map<String, List<String>> toLeadJsMap = app.getToLeadJsMap();
  1261. Map<String, List<String>> toLeadTldMap = app.getToLeadTldMap();
  1262. */
  1263. Map<String, List<String>> grpMapMap;
  1264. if (yym.equals("wd")) // "wd"
  1265. // 先用 "wd",不用 WebC.SS_name -- 改动太大。Lin
  1266. grpMapMap = PageCompC.grpMapSsMap; // SsApp.。Lin // = PrjApp.。移到 PageCompC 了。Lin
  1267. else
  1268. grpMapMap = prjApp.grpMapMap; // = PrjApp.。再,支持多线程。Lin
  1269. Map<String, List<String>> map = new HashMap<>();
  1270. List<String> jsList = new ArrayList<>();
  1271. int index = 0;
  1272. /* 再改,IDEA:'jspList.size() != 0' can be replaced with '!jspList.isEmpty()'。Lin
  1273. if (jspList.size() != 0) {
  1274. */ if (!(jspList.isEmpty())) {
  1275. for (Map<String, Object> m : jspList) {
  1276. String content = yym +"."+ m.get("content");
  1277. jsList.add(content);
  1278. /* 不支持多个应用。Lin
  1279. * 不区分 toLeadJsMap 和 toLeadTldMap,用 SsApp.grpMapMap
  1280. * 提到最外面,不用几个地方都赋值 set -- 只确定到 .grpMapMap
  1281. Set<Entry<String, List<String>>> set = toLeadJsMap.entrySet();
  1282. */
  1283. Set<Entry<String, List<String>>> set = grpMapMap.entrySet();
  1284. /* 再改,IDEA:'while' loop can be replaced with enhanced 'for'。Lin
  1285. Iterator<Entry<String, List<String>>> it = set.iterator();
  1286. while (it.hasNext()) {
  1287. Entry<String, List<String>> entry = it.next();
  1288. */ for (Entry<String, List<String>> entry : set) {
  1289. String key = entry.getKey();
  1290. if (key.endsWith(".*")) {
  1291. String temp = key.replaceAll("\\.\\*", "");
  1292. if (content.startsWith(temp)) {
  1293. List<String> list = new ArrayList<>();
  1294. int tmpe = key.split("\\.").length;
  1295. /* 再改,IDEA:Can be replaced with 'Math.max()' call。Lin
  1296. index = tmpe > index ? tmpe : index;
  1297. */ index = Math.max(tmpe, index);
  1298. if (null == map.get(tmpe + "")) {
  1299. list.add(key);
  1300. map.put(tmpe + "", list);
  1301. } else {
  1302. if (!map.get(tmpe + "").contains(key))
  1303. map.get(tmpe + "").add(key);
  1304. }
  1305. }
  1306. }
  1307. }
  1308. }
  1309. }
  1310. for (int i = 2; i <= index; i++) {
  1311. if (map.get(i +"") != null) {
  1312. for (String key : map.get(i +"")) {
  1313. /* 不区分 toLeadJsMap 和 toLeadTldMap,用 SsApp.grpMapMap。Lin
  1314. List<String> tempList = toLeadJsMap.get(key);
  1315. */
  1316. List<String> tempList = grpMapMap.get(key);
  1317. for (String file : tempList) {
  1318. if (!jsFileList.contains(file))
  1319. jsFileList.add(file);
  1320. }
  1321. }
  1322. }
  1323. }
  1324. /* 再改,IDEA:'jsList.size() != 0' can be replaced with '!jsList.isEmpty()'。Lin
  1325. if (jsList.size() != 0) {
  1326. */ if (!(jsList.isEmpty())) {
  1327. for (String key : jsList) {
  1328. /* 不区分 toLeadJsMap 和 toLeadTldMap,用 SsApp.grpMapMap。Lin
  1329. List<String> tempList = toLeadJsMap.get(key);
  1330. */
  1331. List<String> tempList = grpMapMap.get(key);
  1332. if (tempList != null) {
  1333. for (String file : tempList) {
  1334. if (!jsFileList.contains(file))
  1335. jsFileList.add(file);
  1336. }
  1337. }
  1338. }
  1339. }
  1340. /* 再改,IDEA:'jsList.size() != 0' can be replaced with '!jsList.isEmpty()'。Lin
  1341. if (tldList.size() != 0) {
  1342. */ if (!(tldList.isEmpty())) {
  1343. for (Map<String, Object> m : tldList) {
  1344. String content = (String) m.get("content");
  1345. /* 不区分 toLeadJsMap 和 toLeadTldMap,用 SsApp.grpMapMap。Lin
  1346. Set<Entry<String, List<String>>> set = toLeadTldMap.entrySet();
  1347. */
  1348. Set<Entry<String, List<String>>> set = grpMapMap.entrySet();
  1349. /* 再改,IDEA:'while' loop can be replaced with enhanced 'for'。Lin
  1350. Iterator<Entry<String, List<String>>> it = set.iterator();
  1351. while (it.hasNext()) {
  1352. Entry<String, List<String>> entry = it.next();
  1353. */ for (Entry<String, List<String>> entry : set) {
  1354. String key = entry.getKey();
  1355. if (key.startsWith(content)) {
  1356. /* 不区分 toLeadJsMap 和 toLeadTldMap,用 SsApp.grpMapMap。Lin
  1357. List<String> tldArr = toLeadTldMap.get(key);
  1358. */
  1359. List<String> tldArr = grpMapMap.get(key);
  1360. for (String file : tldArr) {
  1361. tldFileMap.put(content.replaceAll(":", ""), file);
  1362. }
  1363. }
  1364. }
  1365. }
  1366. }
  1367. }
  1368. }
  1369. /**
  1370. * 替换@goto
  1371. *
  1372. * @param srcStr;
  1373. * @param resList;
  1374. * @return String
  1375. */
  1376. // 来自 FileTranslator.gotoUpdate()。Lin
  1377. // 去掉 appName、ymid、wzid、gdba
  1378. // private static String gotoUpdate(String srcStr, List<Map<String, Object>> resList, String appName, String ymid, String wzid, GeneralDBAccess gdba) {
  1379. private static String gotoUpdate(String srcStr, List<Map<String, Object>> resList) {
  1380. List<String> list = new ArrayList<>();
  1381. int i = 0; // i 没有被赋值???-- 永远等于 0。Lin
  1382. int start = 0;
  1383. /* 再改,IDEA:Variable 'end' initializer '-1' is redundant。Lin
  1384. int end = -1;
  1385. */ int end;
  1386. for (Map<String, Object> m : resList) {
  1387. end = Integer.parseInt(m.get("start").toString());
  1388. String subStr = srcStr.substring(start, end);
  1389. list.add(subStr);
  1390. start = Integer.parseInt(m.get("end").toString());
  1391. }
  1392. end = srcStr.length();
  1393. String subStr = srcStr.substring(start, end);
  1394. list.add(subStr);
  1395. /* 去掉,没用到。Lin
  1396. int j = -1;
  1397. */
  1398. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1399. * String 改为 StringBuilder
  1400. String newStr = list.get(0);// 最终输出到页面的字符串
  1401. */ StringBuilder newStr = new StringBuilder(list.get(0));// 最终输出到页面的字符串
  1402. for (Map<String, Object> m : resList) {
  1403. // j++;
  1404. String gotoStr = m.get("content").toString();
  1405. try {
  1406. // String rs = translateServiceStr(serviceStr,// 要翻译的@service字符串
  1407. // appName, ymid, wzid, gdba, false);
  1408. /* 去掉结构函数了。Lin
  1409. * 去掉 appName、ymid、wzid 了
  1410. * 入口参数的 false 为 runWithoutJSP,不用设置 runWithoutJSP -- 可以直接 new GotoTranslator()
  1411. String rs = new GotoTranslator(appName, ymid, wzid, false).translate(gotoStr);
  1412. */ String rs = new GotoTranslator().translate(gotoStr);
  1413. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1414. * String> 改为 StringBuilder
  1415. newStr += rs;
  1416. */ newStr.append(rs);
  1417. /* 再改,IDEA:'catch' branch identical to 'RuntimeException' branch。Lin
  1418. } catch (RuntimeException e) {
  1419. e.printStackTrace();
  1420. } catch (Exception e) {
  1421. e.printStackTrace();
  1422. }
  1423. */ } catch (Exception e) {
  1424. /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
  1425. e.printStackTrace();
  1426. */ log4j.error("PageComper.gotoUpdate() 异常", e);
  1427. }
  1428. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  1429. * String> 改为 StringBuilder
  1430. * i 没有被赋值???-- 永远等于 0。Lin
  1431. newStr += list.get(i + 1);
  1432. */ newStr.append(list.get(i +1));
  1433. }
  1434. ///// return newStr;
  1435. return newStr.toString();
  1436. }
  1437. // 来自 FileTranslator.tbodyUpdate()。Lin
  1438. private static void tbodyUpdate(List<String> tbodyFileList, String strUlr) throws Exception {
  1439. strUlr = strUlr.replaceAll(">", "/>");
  1440. Document document = DocumentHelper.parseText(strUlr);
  1441. Element rootElement = document.getRootElement();
  1442. String wdOddClass = rootElement.attributeValue("ssOddClazz"); // ("wdOddClass")。Lin
  1443. String wdEvenClass = rootElement.attributeValue("ssEvenClazz"); // ("wdEvenClass")。Lin
  1444. String wdHoverClass = rootElement.attributeValue("ssHovClazz"); // ("wdHoverClass")。Lin
  1445. String id = rootElement.attributeValue("id");
  1446. tbodyFileList.add("wd.display.initTrDisplay("
  1447. + (id == null? "null" : ("\"")+ id +"\"") +","
  1448. + (wdOddClass == null? "null" : ("\""+ wdOddClass +"\"")) +","
  1449. + (wdEvenClass == null? "null" : ("\""+ wdEvenClass +"\"")) +","
  1450. + (wdHoverClass == null? "null" : ("\""+ wdHoverClass +"\"")) +");");
  1451. }
  1452. /* 去掉,归入 xxxTagComper。Lin
  1453. // 来自 FileTranslator.pageUpdate(String s, List<Map<String, Object>> pageList)。Lin
  1454. private static String pageUpdate(String s, List<Map<String, Object>> pageList) {
  1455. String newStr = "";
  1456. int start = 0;
  1457. int end = 0;
  1458. String content = null;
  1459. for (Map<String, Object> map : pageList) {
  1460. content = map.get("content").toString();
  1461. start = Integer.parseInt(map.get("start").toString());
  1462. newStr += s.substring(end, start);
  1463. end = Integer.parseInt(map.get("end").toString());
  1464. if (content.matches("<page:write name=\"*.*?\" />")) {
  1465. newStr += "<span style='color:red;font-weight:bold;'>" + StringEscapeUtils.escapeHtml3("<这里有个旧的分页标签,用wd:page>") + "</span>";
  1466. } else if (content.matches("<wd:page name=\"*.*?\" />")) {
  1467. String name = content.split("\"")[1];
  1468. ///* 去掉,不支持多个应用。Lin
  1469. ///* 去掉加载时加的 "/<应用名>/" 前缀了,含 "/wd/"。Lin
  1470. /// String yym = name.split("/")[1];
  1471. /// WebApp webApp = WD.getApp(yym);
  1472. /// // System.out.println("WD.getApp(yym);:"
  1473. /// // + WD.getApp(yym));
  1474. /// // System.out.println(name + "--webApp.getJsCssRealPathMap():"
  1475. /// // + webApp.getJsCssRealPathMap());
  1476. /// String path = webApp.getJsCssRealPathMap().get(name);
  1477. /// end。Lin
  1478. String path = TagComper.readRealFileName(name);
  1479. newStr += "<%@include file=\""+ path +"\"%>";
  1480. } else {
  1481. newStr += content;
  1482. }
  1483. }
  1484. return newStr;
  1485. }
  1486. */
  1487. /**
  1488. *
  1489. * 发布前: <iframe wdPlugin="ry_cx" /> 发布后: <iframe src="…" />
  1490. *
  1491. * @param srcStr;
  1492. * @return String
  1493. */
  1494. // 来自 FileTranslator.transwdPluginsrc(String srcStr, String appName,
  1495. // String ymid, String wzid, GeneralDBAccess gdba)。Lin
  1496. // 去掉 appName、ymid、wzid、gdba
  1497. public static String transwdPluginsrc(String srcStr) {
  1498. /* 再去掉 -- 最终,删空了,可以直接用最后面的 return srcStr 了。Lin
  1499. if (srcStr == null)
  1500. return null;
  1501. */
  1502. // try { // 再去掉,IDEA -- Empty 'try' block。Lin
  1503. /* 再改,IDEA:'\'' is unnecessarily escaped。Lin
  1504. String reg_Aservice = "wdPlugin=[\'\"](.*?)[\'\"]";
  1505. */
  1506. /* 再去掉,没用到。Lin
  1507. String reg_Aservice = "wdPlugin=['\"](.*?)['\"]";
  1508. */
  1509. // Pattern p = Pattern.compile(reg_Aservice); // 再去掉,没用到。Lin
  1510. // Matcher m1=
  1511. // p.matcher(" <iframe wdPlugin='ry_cx' /> height=\"100px\" ");
  1512. // Matcher m1 = p.matcher(srcStr); // 再去掉,没用到。Lin
  1513. /* 再去掉,按 IDEA 规范。Lin
  1514. * Empty 'try' block > 'while' statement has empty body
  1515. while (m1.find()) {
  1516. // try {
  1517. /// * 去掉,没用到。Lin
  1518. // String attrV = m1.group();
  1519. // String dest = m1.group(1);
  1520. /// *
  1521. // Long bjid = new BjDaoImpl().selectBjid(dest, appName, gdba, false);
  1522. // if (bjid == null) {
  1523. // System.out.println(attrV + " not foud dest");
  1524. // } else {
  1525. //// Bj bj = new Bj();
  1526. //// bj.setBjid(bjid);
  1527. // Map<String, String> json = DesignOutSide.beansToMap(bj);
  1528. // String csfw = json.get("csfw");
  1529. //
  1530. // if (StringUtil.isNull(csfw)) {
  1531. // csfw = "dest:" + bjid;
  1532. // } else {// name:"ry_cx"
  1533. // csfw += ",dest:" + bjid;
  1534. // }
  1535. // String src = new UrlTranslator(appName, ymid, wzid, false, gdba).translate("@service{" + csfw + "}@");
  1536. //
  1537. // srcStr = srcStr.replace(attrV, "src=\"" + src + "\"");
  1538. //
  1539. // }
  1540. // } catch (Exception e) {
  1541. // e.printStackTrace();
  1542. // }
  1543. }
  1544. */
  1545. /* 再去掉,IDEA -- Empty 'try' block。Lin
  1546. } catch (Exception e) {
  1547. e.printStackTrace();
  1548. }
  1549. */
  1550. return srcStr;
  1551. }
  1552. /// **
  1553. // * 翻译@service{service:xxxx,dest:cccccc,param:{vvv:1314}}
  1554. // *
  1555. // * @param srcStr
  1556. // * @param appName
  1557. // * @param ymid
  1558. // * @param wzid
  1559. // * @return
  1560. /// *
  1561. /* 去掉,用 TagComper.transform(str)。Lin
  1562. // 来自 FileTranslator.transFormAtService(String srcStr, String appName, String ymid, String wzid, GeneralDBAccess gdba)。Lin
  1563. // 去掉 ymid、wzid、gdba
  1564. // 去掉 appName,直接用 PrjApp.prjName。Lin
  1565. public static String transFormAtService(String srcStr) {
  1566. if (srcStr == null) return null;
  1567. ///* 改为 <serv@ss name= />。Lin
  1568. /// String reg_Aservice = "@service\\{.*?\\}@";// 此正则中的“?”用于最小匹配
  1569. /// end。Lin
  1570. String reg_Aservice = "<[a-z]*@ss[^>]*?/>";
  1571. List<Map<String, Object>> atServicelist = StrU.findMatch2(srcStr, reg_Aservice, 0);
  1572. for (Map<String, Object> m : atServicelist) {
  1573. String serviceStr = m.get("content").toString();
  1574. try {
  1575. ///* 去掉结构函数,runWithoutJSP 放到 new 之后赋值 -- false 的话,不用赋值(默认值为 false)。Lin
  1576. ///* 去掉 appName,直接用 PrjApp.prjName。Lin
  1577. /// String rs = new UrlTranslator(appName, ymid, wzid, false, gdba).translate(serviceStr);
  1578. /// end。Lin
  1579. ///* 再改,归入 xxxTagComper。Lin
  1580. ///* 用 TagComper.transform() -- UrlServTranslator.translate() 移到 ServTagComper
  1581. /// String rs = new UrlServTranslator().translate(serviceStr);
  1582. /// end。Lin
  1583. String rs = TagComper.transform(serviceStr);
  1584. srcStr = srcStr.replace(serviceStr, rs);
  1585. } catch (RuntimeException e) {
  1586. e.printStackTrace();
  1587. } catch (Exception e) {
  1588. if (e.getMessage().contains("查找部件失败:")) {
  1589. SsLog.print("发布异常:"+e.getMessage());
  1590. // PmsUtilCache.addErrorlog("发布异常:"+e.getMessage()); // 先去掉,需要再弄。Lin
  1591. } else {
  1592. e.printStackTrace();
  1593. }
  1594. }
  1595. }
  1596. return srcStr;
  1597. }
  1598. */
  1599. // 来自 pms-core:FileTranslator.(StringReader) addViewObjectTools(StringReader reader, String appName,
  1600. // String dxm, PageObject pageobj, String ymid, String wzid, boolean isViewJsp,
  1601. // boolean systemCreate11, GeneralDBAccess gdba)。Lin
  1602. // Info、Input 页面才会调用
  1603. // 去掉入口参数 appName,直接用 PrjApp.prjName
  1604. // 去掉 isViewJsp,没有 ViewJsp 了
  1605. // 去掉 dxm,有 pageobj 就够了
  1606. // 去掉 wdgdba,需要时再获取数据库连接
  1607. // 去掉 ymid、wzid
  1608. // 再增加 prjApp(PrjApp) 入口参数 -- 增加支持多线程。Lin
  1609. // 再去掉 systemCreate11(boolean),没用到 -- 按 IDEA 规范。Lin
  1610. private static StringReader addViewObjectTools(StringReader reader, PageB pageobj, PrjApp prjApp) throws Exception {
  1611. /* 改,去掉 ViewObjectUtil.findViewObjectByName(,直接用 SsApp.objMap.get(。Lin
  1612. * 去掉 appName,直接用 PrjApp.
  1613. ViewObject vo = ViewObjectUtil.findViewObjectByName(appName, dxm);
  1614. */
  1615. String dxm = pageobj.objName;
  1616. ObjB vo = prjApp.objMap.get(pageobj.objName); // = PrjApp.。再,支持多线程。Lin
  1617. if (vo == null
  1618. // || StringUtil.isNull(vo.getObjClass())
  1619. )
  1620. return reader;
  1621. // if (bjdm.contains(dxm + "_printInfo") || bjdm.equals(dxm +
  1622. // "_baseInfo")
  1623. // || bjdm.equals(dxm + "_input")
  1624. // || bjdm.contains(dxm + "_input_")
  1625. // || bjdm.contains(dxm + "_baseInfo_")) {
  1626. // } else {
  1627. // return reader;
  1628. // }
  1629. // boolean needValidation=pageobj.getTempcode().isInputPage();
  1630. /* 去掉 TempCode 了 -- 移到 PageB 里。Lin
  1631. boolean isInfo = pageobj.getTempcode().isInfoPage();
  1632. */
  1633. boolean isInfo = pageobj.isInfo;
  1634. /* 去掉 TempCode 了,改用 PageB.name。Lin
  1635. //baseinfo包上数据授权标签
  1636. boolean isBaseInfo=pageobj.getTempcode().getName().contains("_baseInfo");
  1637. boolean isminiBaseInfo=pageobj.getTempcode().getName().contains("_miniBaseInfo");
  1638. boolean isminiInput=pageobj.getTempcode().getName().contains("_miniInput");
  1639. */
  1640. boolean isBaseInfo = pageobj.name.contains(PageC.PAGE_baseInfoSfx);
  1641. boolean isminiBaseInfo = pageobj.name.contains(PageC.PAGE_miniInfoSfx);
  1642. boolean isminiInput = pageobj.name.contains("_miniInput");
  1643. String fieldNamePrefix="";
  1644. String fieldNameValPrefix="";
  1645. if(isminiInput||isminiBaseInfo){
  1646. //miniInput miniBaseInfo
  1647. // js变量不能带"。"
  1648. fieldNameValPrefix = dxm +"${wdgroup}";
  1649. fieldNamePrefix = fieldNameValPrefix +".";
  1650. }
  1651. /* 去掉 appName,不支持多个应用。Lin
  1652. * webapp 改用 SsApp。Lin
  1653. WebApp webapp = WD.getApp(appName);
  1654. */
  1655. // 已经处理过的字段,info部件不再处理
  1656. List<String> filterNames=new ArrayList<>();
  1657. // // 处理printInfo
  1658. // if (bjdm.contains(dxm + "_printInfo")) {
  1659. // isInfo = true;
  1660. // systemCreate11 = false;
  1661. // }
  1662. //
  1663. // if (isInfo && systemCreate11) {
  1664. // Long inputid = new BjDaoImpl().selectBjid(
  1665. // bjdm.replace("baseInfo", "input"), appName, gdba);
  1666. // String inputxgwj = CoreConstVars.webRoot
  1667. // + new BjDaoImpl().getXgwj(inputid, gdba);
  1668. // if (new File(inputxgwj).isFile())
  1669. // reader = new StringReader(FileUtils.readFileToString(new File(
  1670. // inputxgwj), "utf-8"));
  1671. // }
  1672. // ######################################################################
  1673. {
  1674. // check and get baseInfo,input
  1675. // main/object/_input/zgz_dev/fake_input.jsp
  1676. // main/object/_baseInfo/zgz_dev/fake_input.jsp
  1677. /* 再改,IDEA:'StringBuffer sb' may be declared as 'StringBuilder'。Lin
  1678. StringBuffer sb = new StringBuffer();
  1679. */ StringBuilder sb = new StringBuilder();
  1680. BufferedReader in = new BufferedReader(reader);
  1681. // String s = ""; // 移到下面用到的地方。按 IDEA 规范 -- Variable 's' initializer '""' is redundant 。Lin
  1682. /* 去掉 WDGrowHigh 结构函数。Lin
  1683. * 改用 TagComper 的 transform(String str),没有改写父类的
  1684. WDGrowHigh growHeightTransformer = new WDGrowHigh(appName, wzid, ymid, gdba);
  1685. */
  1686. List<String[]> allInputTab = new LinkedList<>();
  1687. Map<String, List<String[]>> onoffbutton_inputs = new HashMap<>();
  1688. // Map<String, String[]> cascadingTag = new HashMap();
  1689. // Map<String, CascadingSelectObject> cascadingObjects = webapp.getCascadingSelectObject();
  1690. Set<ObjFieldB> captchaField = new HashSet<>();
  1691. List<String[]> wdTabNoList=new ArrayList<>();
  1692. String s; // 从上面移到这。Lin
  1693. while ((s = in.readLine()) != null) {
  1694. // input
  1695. String[] inputTab = StrWeb.findLabelName(s, "input", null);
  1696. if (inputTab != null) {
  1697. String name = inputTab[1];
  1698. Map<String, String> m = inputElementProperties_input(inputTab[0]);
  1699. // String wdCascadingSelect = m.get("wdCascadingSelect");
  1700. String wdRadio = m.get("ssRad"); // ("wdRadio")。Lin
  1701. String wdCheckbox = m.get("wdCheckbox");
  1702. String wdTabNo = m.get(ObjC.FIELD_no); // ("wdTabNo")。Lin
  1703. if (StringUtils.isNumeric(wdTabNo)) // (StrU.isNum(wdTabNo))。Lin
  1704. wdTabNoList.add(new String[]{name, wdTabNo});
  1705. ObjFieldB f = vo.fieldMap.get(name);
  1706. /* 去掉 ObjFieldB.captchaLength,改用 ObjFieldB.hasCaptcha。Lin
  1707. if (f != null && f.getCaptchaLength() > 0) {
  1708. */
  1709. if (f != null && f.hasCaptcha) {
  1710. captchaField.add(f);
  1711. }
  1712. if (StringUtils.isNotBlank(wdRadio) // StrU.notNull()。Lin
  1713. || StringUtils.isNotBlank(wdCheckbox)) { // StrU.notNull()。Lin
  1714. /* 再改,IDEA:Can be replaced with single 'Map.computeIfAbsent' method call。Lin
  1715. if (onoffbutton_inputs.get(name) == null)
  1716. onoffbutton_inputs.put(name, new ArrayList<>());
  1717. */ onoffbutton_inputs.computeIfAbsent(name, k -> new ArrayList<>());
  1718. onoffbutton_inputs.get(name).add(inputTab);
  1719. }
  1720. // else if (StringUtil.notNull(wdCascadingSelect)) {
  1721. // try {
  1722. // // name:’ cxlbjl’, filter:{cslbdl:’0000’}
  1723. // JsonObject json = new JsonParser().parse("{" + wdCascadingSelect + "}").getAsJsonObject();
  1724. // String cascadingname = json.get("name").getAsString();
  1725. // String cascadingfilter = json.get("filter") != null ? json.get("filter").toString() : null;
  1726. // CascadingSelectObject mm = cascadingObjects.get(cascadingname);
  1727. // if (mm != null) {
  1728. // int si = mm.getInputs().getInputList().size() - 1;
  1729. // String lastInputName = mm.getInputs().getInputList().get(si).getName();
  1730. // String filterStr = StringUtil.notNull(cascadingfilter) ? ("filter=\"" + cascadingfilter + "\"") : "";
  1731. // cascadingTag.put(lastInputName, new String[] { "<wd:cascadingSelect value=\"" + cascadingname + "\" " + filterStr + "/>",
  1732. // "<wd:cascadingSelect value=\"" + cascadingname + "\" " + filterStr + "/>" });
  1733. // }
  1734. // } catch (Exception e) {
  1735. // e.printStackTrace();
  1736. // System.out.println("not a json string: " + wdCascadingSelect);
  1737. // }
  1738. //
  1739. // // allInputTab.add(inputTab);
  1740. //
  1741. // }
  1742. // else if (f == null) {
  1743. // allInputTab.add(inputTab);
  1744. // } else if (Field.TYPE_HTML.equals(f.getType())) {
  1745. // allInputTab.add(inputTab);
  1746. // } else if (Field.TYPE_PICTURE.equals(f.getType())) {
  1747. // allInputTab.add(inputTab);
  1748. // } else if (Field.TYPE_PHOTO.equals(f.getType())) {
  1749. // allInputTab.add(inputTab);
  1750. // } else if (Field.TYPE_TIME.equals(f.getType())
  1751. // && f.isEnrolDate()) {
  1752. // allInputTab.add(inputTab);
  1753. // }else if(Field.TYPE_PASSWORD.equals(f.getType())){
  1754. // allInputTab.add(inputTab);
  1755. // }
  1756. allInputTab.add(inputTab);
  1757. }
  1758. /* 再改,IDEA:String concatenation as argument to 'StringBuilder.append()' call。Lin
  1759. sb.append(s + "\r\n");
  1760. */ sb.append(s).append("\r\n");
  1761. }
  1762. /* 再改,IDEA:Can be replaced with 'Comparator.comparingInt'。Lin
  1763. wdTabNoList.sort((a,b)->{
  1764. return Integer.parseInt(a[1])-Integer.parseInt(b[1]);
  1765. });
  1766. */ wdTabNoList.sort(Comparator.comparingInt(a -> Integer.parseInt(a[1])));
  1767. /* 再改,IDEA:'wdTabNoList.size()>0' can be replaced with '!wdTabNoList.isEmpty()'。Lin
  1768. if(wdTabNoList.size()>0){
  1769. */ if (!(wdTabNoList.isEmpty())) {
  1770. sb.append("<script>window.wdTabNoList=[\"");
  1771. List<String> wdTabNoList2= wdTabNoList.stream().map(a->a[0]).collect(Collectors.toList());
  1772. sb.append(String.join("\",\"", wdTabNoList2));
  1773. sb.append("\"];");
  1774. sb.append("</script>\r\n");
  1775. }
  1776. String inputContent = sb.toString();
  1777. String baseInfoContent = sb.toString();
  1778. List<ObjFieldB> defaultValueField=new ArrayList<>();
  1779. // BaseBean bean = (BaseBean) Class.forName(vo.getObjClass())
  1780. // .newInstance();
  1781. // String tableName = bean.getDbTableName().toLowerCase();
  1782. // create new content
  1783. for (String[] temp : allInputTab) {
  1784. Map<String, String> inputproperties = inputElementProperties_input(temp[0]);
  1785. String fieldname = temp[1];
  1786. ObjFieldB f = vo.fieldMap.get(fieldname);
  1787. /* 去掉 Field.defaultValue(含名和参数),改用 dictName + dictParm。Lin
  1788. if(f!=null && StrUtil.notNull(f.getDefaultValue()) ){
  1789. */
  1790. if (f != null && StringUtils.isNotBlank(f.dictName)) {
  1791. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  1792. defaultValueField.add(f);
  1793. }
  1794. /// 很奇怪的截取,"mswj"、"fjid"还有点道理???Lin
  1795. // 应该是为了获得字段名 "sltwj"/"mswj"/"fjid" 里的 <ulImg.ss name="slt"/<editor.ss name="ms"/<cms.ss name=" -- 原约定了隐藏字段 <上传名>wj
  1796. String sname = (fieldname.length() > 2) ? fieldname.substring(0, fieldname.length() -2) : fieldname;
  1797. ///
  1798. String snameVal = fieldNameValPrefix + sname;
  1799. sname = fieldNamePrefix + sname;
  1800. String widthStr = getAttributeStr(inputproperties, "width");
  1801. String heightStr = getAttributeStr(inputproperties, "height");
  1802. String classStr = getAttributeStr(inputproperties, "class");
  1803. String styleStr = getAttributeStr(inputproperties, "style");
  1804. boolean wdReadonly = "true".equals(inputproperties.get("wdReadonly"));
  1805. // if (StringUtil.notNull(inputproperties.get("type")) && !"text".equals(inputproperties.get("type")))
  1806. // continue;
  1807. // if (cascadingTag.get(fieldname) != null) {
  1808. // inputContent = inputContent.replace(temp[0], temp[0] + "\r\n" + cascadingTag.get(fieldname)[0]);
  1809. // baseInfoContent = baseInfoContent.replace(temp[0], temp[0] + "\r\n" + cascadingTag.get(fieldname)[1]);
  1810. // } else
  1811. if (SearchC.FIELD_ssKeywordName.equalsIgnoreCase(fieldname)) { // ("wdKeyword".。Lin
  1812. /* 再改,IDEA:Can be replaced with single 'Map.computeIfAbsent' method call。Lin
  1813. if (inputproperties.get("value") == null)
  1814. inputproperties.put("value", "<txt@ss val='${"+ fieldname +"}'/>"); // <wd:write value=。Lin
  1815. */
  1816. inputproperties.computeIfAbsent("value", k -> "<txt.ss val='${" + fieldname + "}'/>"); // <wd:write value=。Lin
  1817. String valueStr = inputproperties.get("value");
  1818. /// 增加,转为新标准。Lin
  1819. String buttonStr = getAttributeStr(inputproperties, "button");
  1820. if (StringUtils.isNotBlank(buttonStr))
  1821. buttonStr = buttonStr.replace("button=", "btn=");
  1822. ///
  1823. // <div id="ms" width="100%"
  1824. // height="100px"><wd:write value='${ry.ms}'/></div>
  1825. // <wd:write type="growHeight" name="ms" mode="edit"
  1826. // maxHeight="300px"/>
  1827. String c = "";
  1828. c += "<div id=\"" + fieldname + "\" " + getAttributeStr(inputproperties, "placeholder") + " " + getAttributeStr(inputproperties, "width") + " "
  1829. + getAttributeStr(inputproperties, "height") + ">" + valueStr + "</div>\r\n";
  1830. /* 用 TagComper.transform(str),growHeightTransformer 没盖写过。Lin
  1831. c += growHeightTransformer.transform("<wd:write multiLine=\"false\" type=\"growHeight\" "
  1832. */
  1833. c += TagComper.compTag("<growh.ss multiline=\"false\" "
  1834. + getAttributeStr(inputproperties, "name") + " "
  1835. /* 改,转为新标准。Lin
  1836. + getAttributeStr(inputproperties, "button") + " "
  1837. */ + buttonStr + " "
  1838. + getAttributeStr(inputproperties, "maxHeight") + " mode=\"edit\" />\r\n");
  1839. String d = "";
  1840. d += "<div id=\""+ fieldname +"\" "+ getAttributeStr(inputproperties, "placeholder") +" "+
  1841. getAttributeStr(inputproperties, "width") +" "+
  1842. getAttributeStr(inputproperties, "height") +">"+
  1843. getAttributeStr(inputproperties, "value") +"</div>\r\n";
  1844. /* 用 TagComper.transform(str),growHeightTransformer 没盖写过。Lin
  1845. d += growHeightTransformer.transform("<wd:write multiLine=\"false\" type=\"growHeight\" "
  1846. */
  1847. d += TagComper.compTag("<growh.ss multiline=\"false\" "+
  1848. getAttributeStr(inputproperties, "name") +" "+
  1849. /* 改,转为新标准。Lin
  1850. getAttributeStr(inputproperties, "button") + " "+
  1851. */ buttonStr +" "+
  1852. getAttributeStr(inputproperties, "maxHeight") +" mode=\"play\" />\r\n");
  1853. inputContent = inputContent.replace(temp[0], c);
  1854. baseInfoContent = baseInfoContent.replace(temp[0], d);
  1855. filterNames.add(fieldname);
  1856. /* 再改为 IDEA 规范。Lin
  1857. * 'if' statement has empty body
  1858. * 'continue' is unnecessary as the last statement in a loop > 'if' statement has empty body
  1859. } else if (f == null) {
  1860. }else if (StringUtils.isNotBlank(inputproperties.get("type")) // StrU.notNull()。Lin
  1861. && !"text".equals(inputproperties.get("type"))) {
  1862. // if("hidden".equals(inputproperties.get("type"))){
  1863. // String value="${##tableName.##fileName}";
  1864. // if(inputproperties.get("value")!=null)
  1865. // value=inputproperties.get("value");
  1866. // String c = "";
  1867. // c += "<input name=\"##fieldNamePrefix##fileName\" type=\"hidden\" value=\""+value+"\">\r\n";
  1868. // c = c.replaceAll("##fileName", f.getName()).replaceAll("##tableName", dxm).replaceAll("##fieldNamePrefix",Matcher.quoteReplacement(fieldNamePrefix)).replaceAll("##fieldNameValPrefix",Matcher.quoteReplacement(fieldNameValPrefix));
  1869. // inputContent = inputContent.replace(temp[0], c);
  1870. // baseInfoContent = baseInfoContent.replace(temp[0], "");
  1871. // }
  1872. continue; // 再去掉,按 IDEA 规范 -- 'continue' is unnecessary as the last statement in a loop。Lin
  1873. /// * String 改为 int。Lin
  1874. // } else if (f.type.equals(ObjC.FIELD_htmlType)) { // Field.TYPE_HTML。Lin
  1875. /// *
  1876. } else if (f.type == ObjC.FIELD_htmlType) {
  1877. */
  1878. } else if (f != null &&
  1879. (StringUtils.isBlank(inputproperties.get("type"))
  1880. || "text".equals(inputproperties.get("type")))) {
  1881. /// 改为新UI,增加。Lin
  1882. /**
  1883. * 新UI发布程序:
  1884. * 富文本:
  1885. * 原程序是录入页和baseInfo发布,都写在下面这个分支
  1886. *
  1887. */
  1888. ///
  1889. if (f.type == ObjC.FIELD_htmlType) {
  1890. // <div id='msEdit' width="167px" height=”100px”/>
  1891. // <input type="hidden" name="mswj" value="${xxxx} "/>
  1892. // <common:write type="UEditor" name="ms" button=“’加粗’,
  1893. // {name:’附件’,key:’fjid’,value:'附件ID的值'}”
  1894. // mode=”${用EL表达式输出edit(录入)或者change(变动)}”
  1895. // value='{"template":"wz"}' />
  1896. // if ("hidden".equals(inputproperties.get("type")))
  1897. // continue;
  1898. /// 改为新UI,增加。Lin
  1899. //录入页,用新UI
  1900. if(pageobj.isInp) {
  1901. if (inputproperties.get("value") == null){//这里必需用下面的办法获取value
  1902. inputproperties.put("value","${"+dxm+"."+f.name+"}");
  1903. }
  1904. String richTextInputContent = PageCompU.getInputCode(PageCompC.FORM_PLUGIN_JS_TYPE_html, //组件类弄
  1905. inputproperties,//组件属性
  1906. vo,
  1907. fieldname
  1908. );
  1909. inputContent = inputContent.replace(temp[0], richTextInputContent);
  1910. filterNames.add(fieldname);
  1911. } else if (isBaseInfo) {
  1912. ///
  1913. /* 再改,内容 表增加 对象名、对象ID 字段 -- 对象的附件 -- 还有审核时的附件,在 TagComper。Lin
  1914. String c = "<div id=\""+ sname +"Edit\" "+ widthStr +" "+ heightStr +" "+ classStr +"></div>\r\n";
  1915. */ String c = "<div id=\""+ sname +"Edit\""+
  1916. " data-ss-nr-obj-name=\"${ssObjName}\" data-ss-nr-obj-id=\"${ssObjId}\""+
  1917. " "+ widthStr +" "+ heightStr +" "+ classStr +"></div>\r\n";
  1918. c += "<input type=\"hidden\" name=\""+ fieldname +"\" value=\"${"+ dxm +"."+ fieldname +"}\"/>\r\n";
  1919. /* 改。Lin
  1920. c += "<wd:write type=\"UEditor\" name=\"" + sname + "\" "
  1921. + (StringUtil.isNull(inputproperties.get("wdButton")) ?
  1922. "" : ("button=\"" + inputproperties.get("wdButton") + "\""))
  1923. + " mode=\"${dataType=='change'?'change':'edit'}\""
  1924. + " value='{\"template\":\"" + vo.getName() + "\"}' />\r\n";
  1925. */ c += "<editor.ss name=\""+ sname + "\" "+
  1926. ((StringUtils.isBlank(inputproperties.get("ssBtn"))) ?
  1927. "" : ("btn=\""+ inputproperties.get("ssBtn") +"\"")) +
  1928. " mode=\"${dataType=='"+ ObjC.CHILD_chgType +"'?'"+ ObjC.CHILD_chgType +"':'edit'}\""+
  1929. " val='{\"template\":\""+ vo.name +"\"}'/>\r\n";
  1930. // c+="<script>wd.edit.addClearTextButton(\""+fieldname+"\");</script>\r\n";
  1931. // <div name=' msPlay' width="167px" height=”100px”/>
  1932. // <input type="hidden" name="mswj" value="${xxxx} ">
  1933. // <common:write type="html" name="ms" button=“’加粗’, {name:
  1934. // ’附件’,value:'附件ID的值' }” mode=”play”
  1935. // value='{"template":"wz"}'
  1936. // />
  1937. String d = "<div id=\""+ sname +"Play\" "+ widthStr +" "+ heightStr +" "+ classStr +"></div>\r\n";
  1938. d += "<input type=\"hidden\" name=\""+ fieldname +"\" value=\"${"+ dxm +"."+ fieldname +"}\"/>\r\n";
  1939. // d+="<script>\r\n";
  1940. // d+="wd.display.initGrowHeightHtml('"+sname+"Play',300,'"+inputproperties.get("wdButton")+"');\r\n";
  1941. // d+="</script>\r\n";
  1942. /* 改。Lin
  1943. d += "<wd:write type=\"UEditor\" name=\"" +sname + "\" "
  1944. + (StringUtil.isNull(inputproperties.get("wdButton")) ?
  1945. "" : ("button=\"" + inputproperties.get("wdButton") + "\""))
  1946. + " mode=\"play\" value='{\"template\":\"" + vo.getName() + "\"}' />\r\n";
  1947. */ d += "<editor.ss name=\""+ sname +"\" "+
  1948. ((StringUtils.isBlank(inputproperties.get("ssBtn")))?
  1949. "" : ("btn=\""+ inputproperties.get("ssBtn") +"\"")) +
  1950. " mode=\"play\""+
  1951. " val='{\"template\":\""+ vo.name +"\"}'/>\r\n";
  1952. inputContent = inputContent.replace(temp[0], wdReadonly ? d : c);
  1953. if (isBaseInfo)
  1954. /* 改。Lin
  1955. d="<wd:permission name=\""+fieldname+"\">\r\n"+d+"\r\n</wd:permission>";
  1956. */ d = "<auth.ss field=\""+ fieldname +"\">\r\n"+ d +"\r\n</auth.ss>";
  1957. baseInfoContent = baseInfoContent.replace(temp[0], d);
  1958. filterNames.add(fieldname);
  1959. } // 改为新UI,增加。Lin
  1960. /// 改为新UI,增加。Lin
  1961. /**
  1962. * 新UI:
  1963. * 图片部件,如:<field name="zjzwj" desc="证件照" type="img" width="100" height="140"/>
  1964. *
  1965. * 旧UI的图片部件发布程序,是baseInfo和录入页,都是调用下面的程序的
  1966. */
  1967. ///
  1968. /* String 改为 int。Lin
  1969. } else if (f.type.equals(ObjC.FIELD_photoType)) { // Field.TYPE_PHOTO。Lin
  1970. */
  1971. /* 再改,先改 FIELD_photoType("photo") 为 FIELD_imgType("img"),原 FIELD_imgType("img") 暂时改为 FIELD_img1Type("img1")。Lin
  1972. * "picture" 用到再弄 -- 只有 wz.object.xml 用到,"标题图片文件"、"滚动图片文件":type="picture" width= height=
  1973. } else if (f.type == ObjC.FIELD_photoType) { // 考虑去掉 photo,共用 img???Lin
  1974. */ } else if (f.type == ObjC.FIELD_imgType) { // "photo"。Lin
  1975. /// 改为新UI,增加。Lin
  1976. //录入页,用新UI
  1977. if(pageobj.isInp) {
  1978. if (inputproperties.get("value") == null){//这里必需用下面的办法获取value
  1979. inputproperties.put("value","${"+dxm+"."+f.name+"}");
  1980. }
  1981. String imgInputContent = PageCompU.getInputCode(PageCompC.FORM_PLUGIN_JS_TYPE_img, //组件类弄
  1982. inputproperties,//组件属性
  1983. vo,
  1984. fieldname
  1985. );
  1986. inputContent = inputContent.replace(temp[0], imgInputContent);
  1987. filterNames.add(fieldname);
  1988. }
  1989. else if (isBaseInfo) {//查看页先用回老UI的
  1990. ///
  1991. // <input name="zjzwj" placeholder=" default-photo.png "
  1992. // class="photo" style="float: left;" />
  1993. // <div class="photo" style="float: left;" id="zjzEdit">
  1994. // <wd:equal leftValue="${empty ry.zjzwj}"
  1995. // rightValue="false">
  1996. // <img
  1997. // src="@service{name:'getData',param:{path:'${ry.zjzwj}'}}@"
  1998. // onerror_="this.src='${sessionScope['wd.yh'].pflj}image/default-photo.png'"
  1999. // id="zjzimg" />
  2000. // </wd:equal>
  2001. // <wd:equal leftValue="${empty ry.zjzwj}"
  2002. // rightValue="true">
  2003. // <img
  2004. // src="${sessionScope['wd.yh'].pflj}image/default-photo.png"
  2005. // id="zjzimg" />
  2006. // </wd:equal>
  2007. // </div>
  2008. // <input name="zjzwj" type="hidden" value="${ry.zjzwj}">
  2009. // <wd:write name="zjz" type="upload" value=""
  2010. // callback="updateZjzimg"></wd:write>
  2011. // <script type="text/javascript">
  2012. // function updateZjzimg() {
  2013. // $("#zjzImg").attr('src',
  2014. // "@service{name:'getData'}@&path="+encodeURIComponent($("input[name='zjzwj']").val()));
  2015. // }
  2016. // </script>
  2017. // String fileType = " fileType='\"JPG\",\"JPEG\",\"PNG\",\"BPM\",\"GIF\"' ";
  2018. // String c = "<div " + classStr + " " + styleStr + " id=\"" + sname + "Edit\">\r\n";
  2019. // c += "<wd:equal leftValue=\"${empty ##tableName.##fileName}\" rightValue=\"false\">\r\n";
  2020. // c += "<img src=\"@service{name:'getData',param:{path:'${##tableName.##fileName}'}}@\" onerror_=\"this.src='${sessionScope['wd.yh'].pflj}image/"
  2021. // + inputproperties.get("placeholder") + "'\" id=\"" + snameVal + "Img\" />\r\n";
  2022. // c += "</wd:equal>\r\n";
  2023. // c += "<wd:equal leftValue=\"${empty ##tableName.##fileName}\" rightValue=\"true\">\r\n";
  2024. // c += "<img src=\"${sessionScope['wd.yh'].pflj}image/" + inputproperties.get("placeholder") + "\" id=\"" + snameVal + "Img\" />\r\n";
  2025. // c += "</wd:equal>\r\n";
  2026. // c += "</div>\r\n";
  2027. // c += "<script type=\"text/javascript\">\r\n";
  2028. // c += " function update" + snameVal + "img() {\r\n";
  2029. // c += " $(\"#" + snameVal + "Img\").attr('src', \"@service{name:'getData'}@&path=\"+encodeURIComponent($(\"input[name='##fieldNamePrefix##fileName']\").val()));\r\n";
  2030. // c += " }\r\n";
  2031. // c += "</script>\r\n";
  2032. // c += "<input name=\"##fieldNamePrefix##fileName\" type=\"hidden\" value=\"${##tableName.##fileName}\">\r\n";
  2033. // c += "<wd:write name=\"" + sname + "\" type=\"upload\" " + fileType + " value=\"\" callback=\"update" + snameVal + "img\" width=\"" + f.getWidth()
  2034. // + "\" height=\"" + f.getHeight() + "\"></wd:write>\r\n";
  2035. String value = "${##tableName.##fileName}";
  2036. if (inputproperties.get("value") != null)
  2037. value = inputproperties.get("value");
  2038. String c = "<div "+ classStr +" "+ styleStr +" id=\""+ sname +"Edit\">\r\n";
  2039. c += "<img defaultSrc=\"${sessionScope['ssUser'].skinDir}image/"
  2040. + inputproperties.get("placeholder") +"\" id=\""+ sname +"Img\" />\r\n";
  2041. c += "</div>\r\n";
  2042. c += "<input name=\"##fieldNamePrefix##fileName\" type=\"hidden\" value=\""+ value +"\">\r\n";
  2043. /* 改。Lin
  2044. c += "<wd:write name=\"" + sname + "\" type=\"editphoto\" "
  2045. + " width=\"" + f.getWidth()+"\" height=\"" + f.getHeight() + "\"></wd:write>\r\n";
  2046. */ c += "<ulImg.ss name=\""+ sname +"\" width=\""+ f.width +"\" height=\""+ f.height +"\"/>\r\n";
  2047. // c+="<input value=\"xxxx\" type=\"button\" onclick='@service{dest:\"img_crop\",show:\"wdDialog\",param:{}}@'></input>";
  2048. // <div class="photo" style="float: left;">
  2049. // <wd:equal leftValue="${empty ry.zjzwj}"
  2050. // rightValue="false">
  2051. // <img
  2052. // src="@service{name:'getData',param:{path:'${ry.zjzwj}'}}@"
  2053. // id="zjzimg"
  2054. // onerror_="this.src='${sessionScope['wd.yh'].pflj}image/default-photo.png'"
  2055. // />
  2056. // </wd:equal>
  2057. // <wd:equal leftValue="${empty ry.zjzwj}"
  2058. // rightValue="true">
  2059. // <img
  2060. // src="${sessionScope['wd.yh'].pflj}image/default-photo.png"
  2061. // id="zjzimg"
  2062. // onerror_="this.src='${sessionScope['wd.yh'].pflj}image/default-photo.png'"
  2063. // />
  2064. // </wd:equal>
  2065. // </div>
  2066. String d = "<div id=\"##fieldNameValPrefix##fileNameDiv\" " + classStr + " " + styleStr + ">";
  2067. /* 改。Lin
  2068. d += "<wd:equal leftValue=\"${empty ##tableName.##fileName}\" rightValue=\"false\">";
  2069. */ d += "<equal.ss val=\"${empty ##tableName.##fileName}\" val2=\"false\">";
  2070. /* 改。Lin
  2071. d += "<img src=\"@service{name:'getData',param:{path:'${##tableName.##fileName}'}}@\" id=\"" + snameVal
  2072. + "img\" onerror_=\"this.src='${sessionScope['wd.yh'].pflj}image/" + inputproperties.get("placeholder") + "'\" />";
  2073. */
  2074. /* 再改,增加 type="img",分开处理图片的 上传、下载 -- sltwj 字段 -- <ulImg.ss、dlByHttp。Lin
  2075. * 上传,只保存相对文件名 -- D:/pms/data/img/xxx/yyy 里的 xxx/yyy
  2076. * 下载,使用 AppB.imgBaseDir,不使用 AppB.appRoot
  2077. d += "<img src=\"<serv.ss name='dlByHttp' parm='{path:&quot;${##tableName.##fileName}&quot;}'/>\""
  2078. + " id=\""+ snameVal
  2079. + "img\" onerror_=\"this.src='${sessionScope['wd.yh'].skinDir}image/"
  2080. + inputproperties.get("placeholder") +"'\" />";
  2081. */ d += "<img src=\"<serv.ss name='dlByHttp' parm='{type:&quot;img&quot;,path:&quot;${##tableName.##fileName}&quot;}'/>\""
  2082. + " id=\""+ snameVal
  2083. + "img\" onerror_=\"this.src='${sessionScope['ssUser'].skinDir}image/"
  2084. + inputproperties.get("placeholder") +"'\" />";
  2085. /* 改。Lin
  2086. d += "</wd:equal>";
  2087. d += "<wd:equal leftValue=\"${empty ##tableName.##fileName}\" rightValue=\"true\">";
  2088. */
  2089. d += "</equal.ss>";
  2090. d += "<equal.ss val=\"${empty ##tableName.##fileName}\" val2=\"true\">";
  2091. d += "<img src=\"${sessionScope['ssUser'].skinDir}image/"+ inputproperties.get("placeholder")
  2092. + "\" id=\""+ snameVal
  2093. + "img\" onerror_=\"this.src='${sessionScope['ssUser'].skinDir}image/"
  2094. + inputproperties.get("placeholder") +"'\" />";
  2095. /* 改。Lin
  2096. d += "</wd:equal>";
  2097. */ d += "</equal.ss>";
  2098. d += "</div>";
  2099. d += "<script type=\"text/javascript\">\r\n";
  2100. d += "$(\"###fieldNameValPrefix##fileNameDiv\").click(function(){\r\n";
  2101. /* 改。Lin
  2102. d += "var url =\"@service{name:'getData',param:{path:'${##tableName.##fileName}'}}@\";\r\n";
  2103. */
  2104. /* 再改,增加 type="img",分开处理图片的 上传、下载 -- sltwj 字段 -- <ulImg.ss、dlByHttp。Lin
  2105. * 上传,只保存相对文件名 -- D:/pms/data/img/xxx/yyy 里的 xxx/yyy
  2106. * 下载,使用 AppB.imgBaseDir,不使用 AppB.appRoot
  2107. d += "var url =\"<serv.ss name='dlByHttp' parm='{path:&quot;${##tableName.##fileName}&quot;}'/>\";\r\n";
  2108. */ d += "var url =\"<serv.ss name='dlByHttp' parm='{type:&quot;img&quot;,path:&quot;${##tableName.##fileName}&quot;}'/>\";\r\n";
  2109. d += "var errorPhoto='${sessionScope['ssUser'].skinDir}image/"
  2110. + inputproperties.get("placeholder") + "'; \r\n";
  2111. d += "wd.display.previewPicture(url,errorPhoto);\r\n";
  2112. d += " })\r\n";
  2113. d += "</script>\r\n";
  2114. d = d.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm)
  2115. .replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix))
  2116. .replaceAll("##fieldNameValPrefix", Matcher.quoteReplacement(fieldNameValPrefix));
  2117. c = c.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm)
  2118. .replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix))
  2119. .replaceAll("##fieldNameValPrefix", Matcher.quoteReplacement(fieldNameValPrefix));
  2120. /// 改为新UI,增加。Lin
  2121. //原来录入页的html代码
  2122. ///
  2123. inputContent = inputContent.replace(temp[0], wdReadonly ? d : c);
  2124. if (isBaseInfo)
  2125. /* 改。Lin
  2126. d="<wd:permission name=\""+fieldname+"\">\r\n"+d+"\r\n</wd:permission>";
  2127. */ d = "<auth.ss field=\""+ fieldname +"\">\r\n"+ d +"\r\n</auth.ss>";
  2128. /// 改为新UI,增加。Lin
  2129. //原来查看页的html代码
  2130. ///
  2131. baseInfoContent = baseInfoContent.replace(temp[0], d);
  2132. filterNames.add(fieldname);
  2133. } // 改为新UI,增加。Lin
  2134. /* String 改为 int。Lin
  2135. } else if (f.type.equals(ObjC.FIELD_imgType)) { // Field.TYPE_PICTURE。Lin
  2136. */
  2137. /* 再改,先改 FIELD_photoType("photo") 为 FIELD_imgType("img"),原 FIELD_imgType("img") 暂时改为 FIELD_img1Type("img1")。Lin
  2138. * "picture" 用到再弄 -- 只有 wz.object.xml 用到,"标题图片文件"、"滚动图片文件":type="picture" width= height=
  2139. } else if (f.type == ObjC.FIELD_imgType) {
  2140. */ } else if (f.type == ObjC.FIELD_img1Type) { // "picture"。Lin
  2141. // <span id="zjzwjmc"></span>
  2142. // <input name="zjzwj" type="hidden" value="${ry.zjzwj}">
  2143. // <input class="content-button" id="zjzEdit" type="button"
  2144. // value="上传"/>
  2145. // <script type="text/javascript" charset="utf-8"
  2146. // src="/wd/js/jquery.form.min.js"></script>
  2147. // <script type="text/javascript" charset="utf-8"
  2148. // src="/wd/js/upload.js"></script>
  2149. // <script>var
  2150. // wd=wd||{};wd.uploadFile=wd.uploadFile||{}</script><script>$(document).ready(function(){$("#zjzEdit").uploadFile({validation:'null',width:98,height:98,size:null,name:'zjz',callback:updatezjzwjimg});})</script>
  2151. //
  2152. // <script type="text/javascript">
  2153. // function updatezjzwjimg() {
  2154. // $("#zjzwjmc").empty();
  2155. // var arr = $("input[name='zjzwj']").val().split("/");
  2156. // $("#zjzwjmc").append(arr.length>0?arr[arr.length-1]:"");
  2157. // }
  2158. // $("#zjzwjmc").parent().click(function(){
  2159. // var path=$("input[name='zjzwj']").val();
  2160. // var url
  2161. // ="<wd:token service='zgz.getData' dest='' param='' test='' />&path="+encodeURIComponent(path);
  2162. // var
  2163. // errorPhoto='${sessionScope['wd.yh'].pflj}image/default-personalPhoto.png';
  2164. // wd.display.previewPicture(url,errorPhoto);
  2165. // });
  2166. // updatezjzwjimg();
  2167. // </script>
  2168. /* 改。Lin
  2169. String fileType = " fileType='\"JPG\",\"JPEG\",\"PNG\",\"BPM\",\"GIF\"' ";
  2170. */
  2171. /* 再改,改了 upload.js,去掉 ""。Lin
  2172. String fileType = " type='\"JPG\",\"JPEG\",\"PNG\",\"BPM\",\"GIF\"' ";
  2173. */ String fileType = " type='jpg,jpeg,png,bpm,gif' ";
  2174. String c = "<span id=\"##fieldNamePrefix##fileNamemc\"></span>\r\n"
  2175. + "<script type=\"text/javascript\">\r\n"
  2176. + "function update" + sname + "img() {\r\n"
  2177. + "$(\"###fieldNamePrefix##fileNamemc\").empty();\r\n"
  2178. + "var arr = $(\"input[name='##fieldNamePrefix##fileName']\").val().split(\"/\");\r\n"
  2179. + "$(\"###fieldNamePrefix##fileNamemc\").append(arr.length>0?arr[arr.length-1]:\"\");\r\n"
  2180. + "}\r\n"
  2181. + "$(\"###fileNamemc\").parent().click(function(){\r\n"
  2182. + "var path=$(\"input[name='##fieldNamePrefix##fileName']\").val();\r\n"
  2183. /* 改。Lin
  2184. * 先不改 type="img",用到再弄 -- 见上面的 ObjC.FIELD_img1Type("photo")
  2185. + "var url =\"@service{name:'getData'}@&path=\"+encodeURIComponent(path);\r\n"
  2186. */ + "var url =\"<serv.ss name='dlByHttp'/>&path=\"+encodeURIComponent(path);\r\n"
  2187. + "var errorPhoto='${sessionScope['ssUser'].skinDir}image/"
  2188. + inputproperties.get("placeholder") + "';\r\n"
  2189. + "wd.display.previewPicture(url,errorPhoto);\r\n"
  2190. + "});\r\n"
  2191. + "update" + sname + "img();\r\n"
  2192. + "</script>\r\n"
  2193. + "<input name=\"##fieldNamePrefix##fileName\" type=\"hidden\" value=\"${##tableName.##fileName}\">\r\n"
  2194. + "<input class=\"content-button\" id=\"" + sname + "Edit\""
  2195. + " type=\"button\" value=\"上传\"/>\r\n"
  2196. /* 改。Lin
  2197. + "<wd:write name=\""+ sname +"\" type=\"upload\" "
  2198. */ + "<ul.ss name=\"" + sname + "\" "
  2199. + fileType
  2200. /* 改。Lin
  2201. + " value=\"\" callback=\"update"+ sname
  2202. */ + " run=\"update" + sname
  2203. + "img\" width=\"" + f.width
  2204. + "\" height=\"" + f.height
  2205. /* 改。Lin
  2206. + "\"></wd:write>\r\n";
  2207. */ + "\"/>\r\n";
  2208. String d = "<div id=\"##fieldNameValPrefix##fileNameDiv\" " + classStr + " " + styleStr + ">";
  2209. /* 改。Lin
  2210. * 先不改 type="img",用到再弄 -- 见上面的 ObjC.FIELD_img1Type("photo")
  2211. d += "<wd:equal leftValue=\"${empty ##tableName.##fileName}\" rightValue=\"false\">";
  2212. d += "<img src=\"@service{name:'getData',param:{path:'${##tableName.##fileName}'}}@\" id=\"" + snameVal
  2213. + "img\" onerror_=\"this.src='${sessionScope['wd.yh'].pflj}image/" + inputproperties.get("placeholder") + "'\" />";
  2214. d += "</wd:equal>";
  2215. d += "<wd:equal leftValue=\"${empty ##tableName.##fileName}\" rightValue=\"true\">";
  2216. */
  2217. d += "<equal.ss val=\"${empty ##tableName.##fileName}\" val2=\"false\">";
  2218. d += "<img src=\"<serv.ss name='dlByHttp' parm='{path:&quot;${##tableName.##fileName}&quot;}'/>\""
  2219. + " id=\"" + snameVal
  2220. + "img\" onerror_=\"this.src='${sessionScope['ssUser'].skinDir}image/" + inputproperties.get("placeholder") + "'\" />";
  2221. d += "</equal.ss>";
  2222. d += "<equal.ss val=\"${empty ##tableName.##fileName}\" val2=\"true\">";
  2223. d += "<img src=\"${sessionScope['ssUser'].skinDir}image/" + inputproperties.get("placeholder") + "\" id=\"" + snameVal
  2224. + "img\" onerror_=\"this.src='${sessionScope['ssUser'].skinDir}image/" + inputproperties.get("placeholder") + "'\" />";
  2225. /* 改。Lin
  2226. d += "</wd:equal>";
  2227. */ d += "</equal.ss>";
  2228. d += "</div>";
  2229. d += "<script type=\"text/javascript\">\r\n";
  2230. d += "$(\"###fieldNameValPrefix##fileNameDiv\").click(function(){\r\n";
  2231. /* 改。Lin
  2232. * 先不改 type="img",用到再弄 -- 见上面的 ObjC.FIELD_img1Type("photo")
  2233. d += "var url =\"@service{name:'getData',param:{path:'${##tableName.##fileName}'}}@\";\r\n";
  2234. */ d += "var url =\"<serv.ss name='dlByHttp' parm='{path:&quot;${##tableName.##fileName}&quot;}'/>\";\r\n";
  2235. d += "var errorPhoto='${sessionScope['ssUser'].skinDir}image/" + inputproperties.get("placeholder") + "'; \r\n";
  2236. d += "wd.display.previewPicture(url,errorPhoto);\r\n";
  2237. d += " })\r\n";
  2238. d += "</script>\r\n";
  2239. d = d.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm).replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix)).replaceAll("##fieldNameValPrefix", Matcher.quoteReplacement(fieldNameValPrefix));
  2240. c = c.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm).replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix)).replaceAll("##fieldNameValPrefix", Matcher.quoteReplacement(fieldNameValPrefix));
  2241. inputContent = inputContent.replace(temp[0], wdReadonly ? d : c);
  2242. if (isBaseInfo)
  2243. /* 改。Lin
  2244. d="<wd:permission name=\""+fieldname+"\">\r\n"+d+"\r\n</wd:permission>";
  2245. */ d = "<auth.ss field=\""+ fieldname +"\">\r\n"+ d +"\r\n</auth.ss>";
  2246. baseInfoContent = baseInfoContent.replace(temp[0], d);
  2247. filterNames.add(fieldname);
  2248. /* String 改为 int。Lin
  2249. } else if (f.type.equals(ObjC.FIELD_timeType) && f.isDate39) { // Field.TYPE_TIME。春季/秋季入学。Lin
  2250. */
  2251. /* 再改,FIELD_date39Type 再改为转为 FIELD_dateType 了。Lin
  2252. } else if (f.type == ObjC.FIELD_timeType && f.isDate39) {
  2253. */ } else if (f.type == ObjC.FIELD_dateType && f.isDate39) {
  2254. // 入学年度
  2255. // <td><input type="hidden" name="csrq" value="${ry.csrq}"
  2256. // />
  2257. // <input type="text" name="csrq_year"
  2258. // onClick="wd.edit.datePicker({dateFmt:'yyyy'});"/>
  2259. // <input name="csrq_month" type="button" value="春季"
  2260. // wdValue="3"/>
  2261. // <input name="csrq_month" type="button" value="秋季"
  2262. // wdValue="9"/>
  2263. // <script>(function(){wd.edit.onoffInit('radio','csrq_month','',false,null,null,null,'edit');})();</script>
  2264. // <script>
  2265. // (function(){
  2266. // if(!document.querySelector("[name=csrq_year]").value){
  2267. // document.querySelector("[name=csrq_year]").value=new
  2268. // Date().getUTCFullYear();
  2269. // }
  2270. // var
  2271. // hiddenEle=document.querySelector("[name=csrq][type=hidden]");
  2272. // var year=new Date().getUTCFullYear();
  2273. // var month=new Date().getMonth()+1;
  2274. // if(hiddenEle.value){
  2275. // year=parseInt( hiddenEle.value.split("-")[0]);
  2276. // month=parseInt( hiddenEle.value.split("-")[1]);
  2277. // }
  2278. // document.querySelector("[name=csrq_year]").value=year;
  2279. // function rebuildingValue(){
  2280. // var
  2281. // hiddenvalue=document.querySelector("[name=csrq_year]").value+"-"+document.querySelector("[name=csrq_month][type=hidden]").value
  2282. // console.log(hiddenvalue);
  2283. // document.querySelector("[name=csrq][type=hidden]").value=hiddenvalue;
  2284. // }
  2285. // $("[name=csrq_month][type=button]").on("click",rebuildingValue)
  2286. // $("[name=csrq_year][type=text]").on("click",function(){
  2287. // wd.edit.datePicker({dateFmt:'yyyy',ychanged:rebuildingValue});
  2288. // });
  2289. // $("[name=csrq_month][type=button][wdValue="+(month<7?3:9)+"]").trigger("click");
  2290. // })()
  2291. // </script></td>
  2292. /* 再改,IDEA:Can be replaced with single 'Map.putIfAbsent' method call。Lin
  2293. if (inputproperties.get("value") == null)
  2294. inputproperties.put("value", "${empty ##tableName.##fileName ?0:##tableName.##fileName}");
  2295. */ inputproperties.putIfAbsent("value", "${empty ##tableName.##fileName ?0:##tableName.##fileName}");
  2296. String d = "<input type=\"hidden\" name=\"##fieldNamePrefix##fileName\" "
  2297. + getAttributeStr(inputproperties, "value")
  2298. + " " + getAttributeStr(inputproperties, "placeholder")
  2299. + " />\r\n";
  2300. // d += "<input type=\"text\" name=\"##fileName_year\" style=\"width:30px;\" />\r\n";
  2301. // d += "<input name=\"##fileName_month\" type=\"button\" value=\"春季\" wdValue=\"3\"/>\r\n";
  2302. // d += "<input name=\"##fileName_month\" type=\"button\" value=\"秋季\" wdValue=\"9\"/>\r\n";
  2303. // d += "<wd:write type=\"radio\" name=\"##fileName_month\" nullable=\"false\" mode=\"##edit\" value=\"\"/>\r\n";
  2304. // d += "<script>";
  2305. // d += "(function(){\r\n";
  2306. // // d +=
  2307. // // "if(!document.querySelector(\"[name=##fileName_year]\").value){\r\n";
  2308. // // d +=
  2309. // // " document.querySelector(\"[name=##fileName_year]\").value=new Date().getUTCFullYear();\r\n";
  2310. // // d += "}\r\n";
  2311. // d += " var hiddenEle=document.querySelector(\"[name=##fileName][type=hidden]\")\r\n";
  2312. // d += " var year,month;\r\n";
  2313. // d += " if(\"0\"==hiddenEle.value){\r\n";
  2314. // d += " year=new Date().getUTCFullYear();\r\n";
  2315. // d += " month=new Date().getMonth()+1;\r\n";
  2316. // d += " }else if(hiddenEle.value&&hiddenEle.value.split(\"-\").length>0){\r\n";
  2317. // d += " year=parseInt( hiddenEle.value.split(\"-\")[0]);\r\n";
  2318. // d += " month=parseInt( hiddenEle.value.split(\"-\")[1]);\r\n";
  2319. // d += " }\r\n";
  2320. // d += " if(year&&month){\r\n";
  2321. // d += " document.querySelector(\"[name=##fileName_year]\").value=year;\r\n";
  2322. // d += " $(\"[name=##fileName_month][type=button][wdValue=\"+(month<7?3:9)+\"]\").trigger(\"click\");\r\n";
  2323. // d += " }\r\n";
  2324. // d += " \r\n";
  2325. //
  2326. // d += " function ##fileNameRebuildingValue(){\r\n";
  2327. // d += " var yy=document.querySelector(\"[name=##fileName_year]\").value;\r\n";
  2328. // d += " var mm=document.querySelector(\"[name=##fileName_month][type=hidden]\").value;\r\n";
  2329. // d += " var hiddenvalue=\"\";\r\n";
  2330. // d += " if(yy&&mm){hiddenvalue=yy+\"-0\"+mm};\r\n";
  2331. // d += " console.log(hiddenvalue);\r\n";
  2332. // d += " document.querySelector(\"[name=##fileName][type=hidden]\").value=hiddenvalue;\r\n";
  2333. // d += " } \r\n";
  2334. // d += " ##fileNameRebuildingValue();\r\n";
  2335. // d += " $(\"[name=##fileName_month][type=button]\").on(\"click\",##fileNameRebuildingValue)\r\n";
  2336. // d += " $(\"[name=##fileName_year][type=text]\").on(\"click\",function(){\r\n";
  2337. // d += " wd.edit.datePicker({dateFmt:'yyyy',onpicked:##fileNameRebuildingValue,oncleared:##fileNameRebuildingValue});\r\n";
  2338. // d += " });\r\n";
  2339. // d += "})()\r\n";
  2340. // d += "</script>"
  2341. /* 改。Lin
  2342. d+="<wd:write type=\"enrolDate\" name=\"##fieldNamePrefix##fileName\" mode=\"edit\"/>\r\n";
  2343. */ d += "<date39.ss name=\"##fieldNamePrefix##fileName\" mode=\"edit\"/>\r\n";
  2344. // <td wdCombine="true"><input type="hidden" name="csrq"
  2345. // value="${ry.csrq}"/>
  2346. // <script>(function(){
  2347. // var
  2348. // hiddenEle=document.querySelector("[name=csrq][type=hidden]")
  2349. // if(!hiddenEle.value)return;
  2350. // year=parseInt( hiddenEle.value.split("-")[0]);
  2351. // month=parseInt( hiddenEle.value.split("-")[1]);
  2352. // $(hiddenEle).before('<span>'+year+'('+(month<7?'春季':'秋季')+')</span>');
  2353. // })()
  2354. // </script></td>
  2355. String c = "";
  2356. c += "<input type=\"hidden\" name=\"##fieldNamePrefix##fileName\" "
  2357. + getAttributeStr(inputproperties, "value")
  2358. + " " + getAttributeStr(inputproperties, "placeholder")
  2359. + " />\r\n";
  2360. // c += "<script>(function(){\r\n";
  2361. // c += "var hiddenEle=document.querySelector(\"[name=##fileName][type=hidden]\")\r\n";
  2362. // c += " if(!hiddenEle.value)return;\r\n";
  2363. // c += " year=parseInt( hiddenEle.value.split(\"-\")[0]);\r\n";
  2364. // c += " month=parseInt( hiddenEle.value.split(\"-\")[1]);\r\n";
  2365. // c += " $(hiddenEle).before('<span>'+year+'('+(month<7?'春季':'秋季')+')</span>');\r\n";
  2366. // c += "})()\r\n";
  2367. // c += "</script>\r\n"
  2368. /* 改。Lin
  2369. c+="<wd:write type=\"enrolDate\" name=\"##fieldNamePrefix##fileName\" mode=\"play\"/>\r\n";
  2370. */ c += "<date39.ss name=\"##fieldNamePrefix##fileName\" mode=\"play\"/>\r\n";
  2371. // wdEdit=
  2372. // String g = "";
  2373. // g += "<input type=\"hidden\" name=\"##fileName\" "
  2374. // + (inputproperties.get("value") == null ? "value=\"${##tableName.##fileName}\"" : getAttributeStr(inputproperties, "value")) + "/>\r\n";
  2375. // g += "<script>(function(){\r\n";
  2376. // g += "var hiddenEle=document.querySelector(\"[name=##fileName][type=hidden]\")\r\n";
  2377. // g += " if(!hiddenEle.value)return;\r\n";
  2378. // g += " year=parseInt( hiddenEle.value.split(\"-\")[0]);\r\n";
  2379. // g += " month=parseInt( hiddenEle.value.split(\"-\")[1]);\r\n";
  2380. // g += " $(hiddenEle).before('<span>'+year+'('+(month<7?'春季':'秋季')+')</span>');\r\n";
  2381. // g += "})()\r\n";
  2382. // g += "</script>\r\n";
  2383. d = d.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm).replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix));
  2384. c = c.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm).replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix));
  2385. // g = g.replaceAll("##fileName", f.getName()).replaceAll("##tableName", dxm);
  2386. /* 再改,IDEA:'f.isWdEdit == false' can be simplified to '!f.isWdEdit'。Lin
  2387. String xxx = ((wdReadonly || f.isWdEdit == false) ? c : d);
  2388. */ String xxx = ((wdReadonly || !(f.isWdEdit)) ? c : d);
  2389. inputContent = inputContent.replace(temp[0], xxx.replace("##edit", "edit"));
  2390. // if(isBaseInfo){
  2391. // d="<wd:permission name=\""+fieldname+"\">\r\n"+d+"\r\n</wd:permission>";
  2392. // }
  2393. /* 改。Lin
  2394. c="<wd:permission name=\""+fieldname+"\">\r\n"+c.replace("##edit", "play")+"\r\n</wd:permission>";
  2395. */ c = "<auth.ss field=\"" + fieldname + "\">\r\n"
  2396. + c.replace("##edit", "play") + "\r\n</auth.ss>";
  2397. // System.out.println(c);
  2398. baseInfoContent = baseInfoContent.replace(temp[0], c);
  2399. // today
  2400. filterNames.add(fieldname);
  2401. /* String 改为 int。Lin
  2402. } else if (f.type.equals(ObjC.FIELD_pwdType)) { // Field.TYPE_PASSWORD。Lin
  2403. */ } else if (f.type == ObjC.FIELD_pwdType) {
  2404. /* 此段程序有错,对 inputContent,用的是 =,导致页面前、后的字段都被去掉了 -- 只剩 "密码" 这个字段。Lin
  2405. inputContent = "<input type=\"password\" name=\"" + f.name + "\" "
  2406. + (inputproperties.get("value") == null ? "value=\"${##tableName.##fileName}\"" : getAttributeStr(inputproperties, "value")) + "/>";
  2407. inputContent = inputContent.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm);
  2408. */
  2409. String d = "<input type=\"password\" name=\"" + f.name + "\" "
  2410. + ((inputproperties.get("value") == null) ?
  2411. "value=\"${##tableName.##fileName}\""
  2412. : getAttributeStr(inputproperties, "value"))
  2413. + "/>";
  2414. d = d.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm);
  2415. inputContent = inputContent.replace(temp[0], d);
  2416. baseInfoContent = baseInfoContent.replace(temp[0], "");
  2417. filterNames.add(fieldname);
  2418. /* 再改,不能用 == 去比较 ObjFieldB。Lin
  2419. * 改用 .name,准备去掉 ObjB.idField(ObjFieldB) -- 去掉时再跟着改
  2420. } else if (f == vo.idField && (StringUtils.isBlank(f.cbName))) {
  2421. */
  2422. /* 再改,去掉 .idField(ObjFieldB),直接用新加的 .idName(String)。Lin
  2423. } else if (f.name.equals(vo.idField.name) && (StringUtils.isBlank(f.cbName))) {
  2424. */ } else if (f.name.equals(vo.idName) && (StringUtils.isBlank(f.cbName))) {
  2425. // 去掉 StrU.isNull(),直接用 StringUtils.isBlank()。Lin
  2426. /* 再改为 -- 页面有 value= 时,不替换 value。Lin
  2427. String d = "<input type=\"hidden\" name=\"##fieldNamePrefix##fileName\" value=\"${##tableName.##fileName}\" />";
  2428. d = d.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm).replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix));
  2429. */
  2430. String d;
  2431. String valueStr = inputproperties.get("value");
  2432. if (StringUtils.isBlank(valueStr)) {
  2433. d = "<input type=\"hidden\" name=\"##fieldNamePrefix##fileName\" value=\"${##tableName.##fileName}\" />";
  2434. d = d.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm).replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix));
  2435. } else {
  2436. d = "<input type=\"hidden\" name=\"##fieldNamePrefix##fileName\" value=\""+ valueStr +"\" />";
  2437. d = d.replaceAll("##fileName", f.name).replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix));
  2438. }
  2439. inputContent = inputContent.replace(temp[0], d);
  2440. baseInfoContent = baseInfoContent.replace(temp[0], "");
  2441. filterNames.add(fieldname);
  2442. /* String 改为 int。Lin
  2443. }else if(f.type.equals(ObjC.FIELD_cmsType)){ // Field.TYPE_CMS。Lin
  2444. */ } else if (f.type == ObjC.FIELD_cmsType) {
  2445. if (StringUtils.isBlank(widthStr)) // 去掉 StrU.isNull(),直接用 StringUtils.isBlank()。Lin
  2446. widthStr = " width=\"100%\" ";
  2447. if (StringUtils.isBlank(widthStr)) // 去掉 StrU.isNull(),直接用 StringUtils.isBlank()。Lin
  2448. heightStr = " height=\"100%\" ";
  2449. String d = "<input type=\"hidden\" name=\"##fileName\" value=\"${##tableName.##fileName}\" />\r\n";
  2450. d += "<div name='" + sname + "Edit' " + widthStr + " " + heightStr + "></div>\r\n";
  2451. /* 改。Lin
  2452. d+="<wd:write type=\"CMS\" name=\""+sname+"\" jlztm=\"${##tableName.jlztm}\"/>";
  2453. */ d += "<cms.ss name=\"" + sname + "\" rowStat=\"${##tableName.jlztm}\"/>";
  2454. String dd = "<input type=\"hidden\" name=\"##fileName\" value=\"${##tableName.##fileName}\" />\r\n";
  2455. dd += "<div name='" + sname + "Play' " + widthStr + " " + heightStr + "></div>\r\n";
  2456. /* 改。Lin
  2457. dd+="<wd:write type=\"CMS\" name=\""+sname+"\" jlztm=\"${##tableName.jlztm}\"/>";
  2458. */ dd += "<cms.ss name=\"" + sname + "\" rowStat=\"${##tableName.jlztm}\"/>";
  2459. d = d.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm).replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix));
  2460. dd = dd.replaceAll("##fileName", f.name).replaceAll("##tableName", dxm).replaceAll("##fieldNamePrefix", Matcher.quoteReplacement(fieldNamePrefix));
  2461. inputContent = inputContent.replace(temp[0], wdReadonly ? dd : d);
  2462. baseInfoContent = baseInfoContent.replace(temp[0], dd);
  2463. filterNames.add(fieldname);
  2464. // } else { // 再去掉,空 else 程序块 -- 按 IDEA 规范。Lin
  2465. }
  2466. } // if (f != null)。去掉 if (f == null) 空程序块 -- 按 IDEA 规范。Lin
  2467. }
  2468. {
  2469. for (Entry<String, List<String[]>> entry : onoffbutton_inputs.entrySet()) { // onoffbutton_inputs 不含 <input name="sfpm" ssRun= />。Lin
  2470. List<String[]> inputs = entry.getValue();
  2471. boolean isRadio = false;
  2472. boolean nullable = true;
  2473. /* 去掉,没用到。Lin
  2474. boolean checked = false;
  2475. */
  2476. String elValue = "${"+ dxm +"."+ entry.getKey() +"}";
  2477. String wdCallback = null;
  2478. for (int i = 0; i < inputs.size(); i ++) {
  2479. String[] temp = inputs.get(i);
  2480. Map<String, String> m = inputElementProperties_input(temp[0]);
  2481. String wdRadioStr = m.get("ssRad"); // ("wdRadio")。Lin
  2482. if (StringUtils.isBlank(wdRadioStr)) // 去掉 StrU.isNull(),直接用 StringUtils.isBlank()。Lin
  2483. wdRadioStr = m.get("wdCheckbox");
  2484. if (StringUtils.isNotBlank(m.get("ssRun"))) // ("wdCallback")))。Lin
  2485. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  2486. wdCallback = m.get("ssRun"); // ("wdCallback")。Lin
  2487. /* 不加左、右的 "{"、"}"。Lin
  2488. * 待确认源头在哪 -- 在源头加 -- 页面 <input ssRad="{val:1,checked:true}"
  2489. JsonElement btnObj = JsonParser.parseString("{"+ wdRadioStr +"}");
  2490. */ JsonElement btnObj = JsonParser.parseString(wdRadioStr);
  2491. String value = m.get("value"); // 这里的不能改为 "val",是 <input value=。Lin
  2492. String wdValueStr = btnObj.getAsJsonObject().get("val") != null? // ("value")。Lin
  2493. /* 再改,IDEA:'\'' is unnecessarily escaped。Lin
  2494. btnObj.getAsJsonObject().get("value").toString().replaceAll("[\"\']", "")
  2495. */
  2496. /* 再改,在页面表述时去掉 ''/"" 了 -- ssRad="val:1,checked:true"。Lin
  2497. * 再,仍保留 .replaceAll( -- 容错
  2498. btnObj.getAsJsonObject().get("value").toString().replaceAll("[\"']", "")
  2499. */ btnObj.getAsJsonObject().get("val").getAsString().replaceAll("[\"']", "")
  2500. : null;
  2501. if (i == 0) {
  2502. isRadio = StringUtils.isNotBlank(m.get("ssRad")); // ("wdRadio"))。Lin
  2503. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  2504. String nullableStr = btnObj.getAsJsonObject().get("null") != null? // ("nullable") !=。Lin
  2505. btnObj.getAsJsonObject().get("null").getAsString() // ("nullable").。Lin
  2506. : null;
  2507. if (StringUtils.isNotBlank(nullableStr))
  2508. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  2509. nullable = "true".equals(nullableStr);
  2510. /* 去掉,checked 没用到。Lin
  2511. * 因为 checked 没用到,checkedStr 也没用到
  2512. String checkedStr = btnObj.getAsJsonObject().get("checked") != null?
  2513. btnObj.getAsJsonObject().get("checked").getAsString().toString()
  2514. : null;
  2515. if (StrUtil.notNull(checkedStr))
  2516. checked = "true".equals(checkedStr);
  2517. */
  2518. }
  2519. String inputStr = "<input type=\"button\" name=\""+ fieldNamePrefix+ m.get("name")
  2520. +"\" value=\""+ value
  2521. +"\" ssVal=\""+ wdValueStr +"\"/>\r\n"; // +"\" wdValue=\""+。Lin
  2522. if (i == inputs.size() -1) {
  2523. /* 改。Lin
  2524. * 再改,<onoff.ss radio= 改为 rad=
  2525. inputStr += "<wd:write type=\"" + (isRadio? "radio" : "checkbox")
  2526. + "\" name=\""+ fieldNamePrefix + m.get("name") +"\" "
  2527. + ((StringUtils.isNotBlank(wdCallback))? ("callback=\""+ wdCallback +"\"") : "")
  2528. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  2529. + " value=\""+ elValue
  2530. + "\" nullable=\""+ (nullable? "true" : "false")
  2531. + "\" mode=\"##edit\" />\r\n";
  2532. */ inputStr += "<onoff.ss rad=\""+ (isRadio? "true" : "false")
  2533. + "\" name=\""+ fieldNamePrefix + m.get("name") +"\" "
  2534. + ((StringUtils.isNotBlank(wdCallback))? ("run=\""+ wdCallback +"\"") : "")
  2535. + " val=\""+ elValue
  2536. + "\" null=\""+ (nullable? "true" : "false")
  2537. + "\" mode=\"##edit\" />\r\n";
  2538. if (isBaseInfo) {
  2539. /* 改。Lin
  2540. inputStr+="\r\n</wd:permission>";
  2541. */ inputStr += "\r\n</auth.ss>";
  2542. }
  2543. }
  2544. if (i == 0 && isBaseInfo) {
  2545. /* 改。Lin
  2546. inputStr="<wd:permission name=\""+m.get("name")+"\">\r\n"+inputStr;
  2547. */ inputStr = "<auth.ss field=\""+ m.get("name") +"\">\r\n"+ inputStr;
  2548. }
  2549. inputContent = inputContent.replace(temp[0], inputStr.replace("##edit", "edit"));
  2550. baseInfoContent = baseInfoContent.replace(temp[0], inputStr.replace("##edit", "play"));
  2551. }
  2552. }
  2553. }
  2554. {// 自动添加校验标签
  2555. /* 改。Lin
  2556. String[] validations = findLabelName(baseInfoContent, "wd:validation", "name");
  2557. */
  2558. /* 再改。Lin
  2559. * "." 需要被转义 -- StrWeb.findLabelName( 里,嵌到正则表达式里了
  2560. String[] validations = StrWeb.findLabelName(baseInfoContent, "wd:validation", "name");
  2561. */ String[] validations = StrWeb.findLabelName(baseInfoContent, "ichk\\.ss", "name");
  2562. if (validations != null)
  2563. baseInfoContent = baseInfoContent.replace(validations[0], "");
  2564. // validations = findLabelName(inputContent, "wd:validation", "name"); // 去掉,没用到。Lin
  2565. // 改为无论是否校验配置文件存在,都发布校验自定义标签到页面
  2566. // Map<String, ValidationInfo> vmap = webapp
  2567. // .getNameKeyValidationMap();
  2568. // if (validations==null&&vmap != null&&
  2569. // vmap.get(pageobj.getTempcode().getName()) != null) {
  2570. /* 去掉 Tempcode。Lin
  2571. String t = "\r\n" + "<wd:validation name=\"" + pageobj.getTempcode().getName() + "\" />\r\n";
  2572. */
  2573. /* 再改。Lin
  2574. String t = "\r\n"+ "<wd:validation name=\"" + pageobj.name +"\" />\r\n";
  2575. */ String t = "\r\n"+ "<ichk.ss name=\""+ pageobj.name +"\" />\r\n";
  2576. /* 再改为 IDEA 规范。Lin
  2577. * Redundant character escape '\\<' in RegExp
  2578. * Redundant character escape '\\/' in RegExp
  2579. * Redundant character escape '\\>' in RegExp
  2580. String reg = "\\<\\/(body|BODY)\\s*?\\>";
  2581. */ String reg = "</(body|BODY)\\s*?>";
  2582. Pattern pattern = Pattern.compile(reg);
  2583. Matcher matcher = pattern.matcher(inputContent);
  2584. if (matcher.find()) {// 追加到body
  2585. inputContent = inputContent.replaceFirst(reg, Matcher.quoteReplacement(t + matcher.group()));
  2586. } else {
  2587. inputContent += t;
  2588. }
  2589. // }
  2590. }
  2591. // request设置一个标记,之后的的服务,标记为强制校验
  2592. /* 再改,IDEA:'captchaField.size() > 0' can be replaced with '!captchaField.isEmpty()'。Lin
  2593. if (!isInfo && captchaField.size() > 0) {
  2594. */ if (!isInfo && !(captchaField.isEmpty())) {
  2595. /* 去掉 Tempcode。Lin
  2596. if (pageobj.getTempcode().getName().contains("_input")
  2597. && pageobj.getTempcode().getName().endsWith("_public")) {
  2598. */ if ((pageobj.name).contains(PageC.PAGE_inpSfx)
  2599. && (pageobj.name).endsWith(PageC.PAGE_pubEnd)) { // 先保留,没有存在 "_public" 结尾的 JSP 文件。Lin
  2600. inputContent = "\r\n<% request.setAttribute(\""+ ss.WebC.REQ_captcha +"\",\""+ captchaField.size() +"\"); %>\r\n"
  2601. + inputContent;
  2602. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  2603. String t = "";
  2604. t += "<script>\r\n";
  2605. */ StringBuilder t = new StringBuilder("<script>\r\n");
  2606. for (ObjFieldB ff : captchaField) {
  2607. /* 去掉 Field.captchaLength,改为 .hasCaptcha。Lin
  2608. * 验证码位数,统一由 SsConst.CAPTCHA_NUM 控制
  2609. t += "wd.display.inputCaptcha(\"" + ff.getName() + "\",\"" + ff.getCaptchaLength() + "\");\r\n";
  2610. */
  2611. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  2612. t += "wd.display.inputCaptcha(\""+ ff.name +"\",\""+ SsC.CAPTCHA_pcLen + "\");\r\n";
  2613. */ t.append("wd.display.inputCaptcha(\"").append(ff.name).append("\",\"")
  2614. .append(SsC.CAPTCHA_pcLen).append("\");\r\n");
  2615. }
  2616. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  2617. t += "</script>\r\n";
  2618. */ t.append("</script>\r\n");
  2619. /* 再改为 IDEA 规范。Lin
  2620. * Redundant character escape '\\<' in RegExp
  2621. * Redundant character escape '\\/' in RegExp
  2622. * Redundant character escape '\\>' in RegExp
  2623. String reg = "\\<\\/(body|BODY)\\s*?\\>";
  2624. */ String reg = "</(body|BODY)\\s*?>";
  2625. Pattern pattern = Pattern.compile(reg);
  2626. Matcher matcher = pattern.matcher(inputContent);
  2627. if (matcher.find()) {// 追加到body
  2628. inputContent = inputContent.replaceFirst(reg, Matcher.quoteReplacement(t + matcher.group()));
  2629. } else {
  2630. inputContent += t;
  2631. }
  2632. }
  2633. }
  2634. // { // 再去掉,没必要。Lin
  2635. /* 再改,IDEA:'defaultValueField.size()>0' can be replaced with '!defaultValueField.isEmpty()'。Lin
  2636. if(!isBaseInfo && !isInfo && defaultValueField.size()>0){
  2637. */ if(!isBaseInfo && !isInfo && !(defaultValueField.isEmpty())){
  2638. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  2639. String t = "";
  2640. t += "<script>\r\n";
  2641. t+="$(function(){\r\n";
  2642. */ StringBuilder t = new StringBuilder("<script>\r\n$(function(){\r\n");
  2643. for (ObjFieldB ff : defaultValueField) {
  2644. /* 去掉 Field.defaultValue(含名和参数),改用 dictName + dictParm。Lin
  2645. * 仍然拼回 "字典名[参数]" 串
  2646. t += "wd.display.inputDefaultValue('" + ff.getName() + "','" + ff.getDefaultValue() + "');\r\n";
  2647. */
  2648. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  2649. t += "wd.display.inputDefaultValue('"+ ff.name +"','"+ ff.dictName
  2650. /// * 再,.dictParmMap 改为 .dictParmStr -- 页面要拼回 "xq[rxnd]"。Lin
  2651. // + "["+ StringUtils.join((ff.dictParmMap).values().toArray(), ',') +"]"
  2652. // 去掉 StrU.join(),直接用 StringUtils.join()
  2653. /// *
  2654. + "["+ ff.dictParmStr +"]"
  2655. + "');\r\n";
  2656. */ t.append("wd.display.inputDefaultValue('").append(ff.name).append("','").append(ff.dictName)
  2657. .append("[").append(ff.dictParmStr).append("]');\r\n");
  2658. }
  2659. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  2660. t+= "})\r\n";
  2661. t += "</script>\r\n";
  2662. */ t.append("})\r\n</script>\r\n");
  2663. inputContent += t;
  2664. }
  2665. // } // 再去掉,没必要。Lin
  2666. // { // 再去掉,没意义。Lin
  2667. if(!inputContent.toLowerCase().contains("</body>")&&!inputContent.toLowerCase().contains("</html>"))
  2668. inputContent += PageCompC.ADD_REMOVE_TOKEN_SCRIPT;
  2669. // } // 再去掉,没意义。Lin
  2670. /* 去掉 appName,直接用 PrjApp.prjName。Lin
  2671. * 移到 PageCompU
  2672. reader = new StringReader(transformCommonwrite(isInfo ? baseInfoContent : inputContent, appName, ymid, wzid, gdba));
  2673. */
  2674. reader = new StringReader(PageCompU.compTag(isInfo? baseInfoContent : inputContent));
  2675. }
  2676. // #######################################################################
  2677. // 添加objectpicker下拉
  2678. BufferedReader in = new BufferedReader(reader);
  2679. StringBuffer sb = new StringBuffer();
  2680. // String s = ""; // 再去掉,移到下面用到的地方。IDEA -- Variable 's' initializer '""' is redundant。Lin
  2681. /* 去掉,改用 TagComper.transform(str),没改盖过。Lin
  2682. ObjPickerTagComper obectPickerTransformer = new ObjPickerTagComper();
  2683. TxtTagComper textTransformer = new TxtTagComper();
  2684. GrowhTagComper growHeightTransformer = new GrowhTagComper();
  2685. OnoffTagComper onoffbuttonTransform = new OnoffTagComper();
  2686. OptTagComper wdoptionTransform = new OptTagComper();
  2687. */
  2688. /// 改为新UI,增加。Lin
  2689. boolean ccpIsNewUI = true;//如果为真,切换级联菜单是新UI
  2690. ///
  2691. try {
  2692. List<String[]> allInputTab = new LinkedList<>();
  2693. Map<String, List<String[]>> allonoffbutton = new HashMap<>();
  2694. List<String[]> allObjectPicker = new LinkedList<>();
  2695. // 所有页面级联
  2696. // List<String[]> allcascadingTagExist = new LinkedList();//
  2697. List<String[]> allcascadingSelect_input = new LinkedList<>();//
  2698. List<String> allcascadingInputNames = new LinkedList<>();//
  2699. List<String> notHandleCascadingInputNames = new LinkedList<>();//
  2700. Map<String, CcpB> allcascadingInputNamesObject = new HashMap<>();//
  2701. /// 增加,保存 prfx -- 支持共用 ccp 定义。Lin
  2702. Map<String, String> cascadingPrfx = new HashMap<>();
  2703. ///
  2704. Map<String, String> namesValue = new HashMap<>();//
  2705. // Map<String, String> cascadingTagNew = new HashMap();//级联标签
  2706. Map<String, Map<String, String>> cascadingTagNewAttribute = new HashMap<>();//级联标签属性
  2707. String s; // 再,从上面移到这。Lin
  2708. while ((s = in.readLine()) != null) {
  2709. // input
  2710. String[] inputTab = StrWeb.findLabelName(s, "input", null);
  2711. // objectpicker
  2712. /* 去掉 TagTransformerAdapter.prefix,统一用 PageConst.HTML_TAG_PREFIX。Lin
  2713. String[] existObjectPicker = findLabelName(s,
  2714. obectPickerTransformer.prefix +":"+ obectPickerTransformer.getTagType(), null);
  2715. */
  2716. /* 改。Lin
  2717. * "." 需要被转义 -- StrWeb.findLabelName( 里,嵌到正则表达式里了
  2718. String[] existObjectPicker = StrWeb.findLabelName(s, "cw:op", null);
  2719. */ String[] existObjectPicker = StrWeb.findLabelName(s, "objp\\.ss", null);
  2720. // cascading
  2721. /* 改。Lin
  2722. * "." 需要被转义 -- StrWeb.findLabelName( 里,嵌到正则表达式里了
  2723. String[] existcascadingSelect = StrWeb.findLabelName(s, "wd:cascadingSelect", "name");
  2724. */ String[] existcascadingSelect = StrWeb.findLabelName(s, "ccp\\.ss", "name");
  2725. if (inputTab != null){
  2726. allInputTab.add(inputTab);
  2727. Map<String, String> m = inputElementProperties_input(inputTab[0]);
  2728. if (StringUtils.isNotBlank(m.get("value"))) // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  2729. namesValue.put(inputTab[1], m.get("value"));
  2730. boolean wdReadonly="true".equals(m.get("wdReadonly"));
  2731. String wdCascadingSelect = m.get("ssCcp"); // ("wdCascadingSelect")。Lin
  2732. if (StringUtils.isNotBlank(wdCascadingSelect)) { // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  2733. try {
  2734. // name:’ cxlbjl’, filter:{cslbdl:’0000’}
  2735. /* 不加左、右的 "{"、"}"。Lin
  2736. * 待确认源头在哪 -- 在源头加
  2737. JsonObject json = JsonParser.parseString("{"+ wdCascadingSelect +"}").getAsJsonObject();
  2738. */
  2739. /* 再改,<input ssCcp= 增加支持多个 Ccp,支持简写。Lin
  2740. * 简写: "dw_nj"/"dw_nj,dw_bzr"
  2741. * 单个 Json: '{name:"dq",prfx:"hk"}'/"{name:'yw_dx@pwj',filter:'{pxmid:&quot;${pxmid}&quot;}'}"
  2742. * 多个 Json: "['xxx','yyy']"/'[{},{}]'
  2743. JsonObject json = JsonParser.parseString(wdCascadingSelect).getAsJsonObject();
  2744. */
  2745. ///// Start。Lin
  2746. JsonArray ccpJa = new JsonArray();
  2747. if (wdCascadingSelect.matches(".*\\[.*].*")) { // 增加支持多个 Ccp。Lin
  2748. JsonArray ja = JsonParser.parseString(wdCascadingSelect).getAsJsonArray();
  2749. for (JsonElement je : ja) {
  2750. if (je.isJsonPrimitive()) { // "['xxx','yyy']"。Lin
  2751. JsonObject jo = new JsonObject();
  2752. jo.addProperty("name", je.getAsString());
  2753. ccpJa.add(jo);
  2754. } else { // '[{},{}]'。Lin
  2755. ccpJa.add(je);
  2756. }
  2757. }
  2758. } else if (wdCascadingSelect.matches(".*\\{.*\\}.*")) { // 单个 Json。Lin
  2759. JsonObject jo = JsonParser.parseString(wdCascadingSelect).getAsJsonObject();
  2760. ccpJa.add(jo);
  2761. } else { // 简写 "dw_nj"/"dw_nj,dw_bzr"。Lin
  2762. String[] list = wdCascadingSelect.split(",");
  2763. for (String f : list) {
  2764. JsonObject jo = new JsonObject();
  2765. jo.addProperty("name", f.trim());
  2766. ccpJa.add(jo);
  2767. }
  2768. }
  2769. for (JsonElement je : ccpJa) {
  2770. JsonObject json = je.getAsJsonObject();
  2771. ///// End。Lin
  2772. String cascadingname = json.get("name").getAsString();
  2773. /* .toString() 改为 .getAsString(),不然会多出左、右的 ""。如 ""xxx""。Lin
  2774. String cascadingfilter = json.has("filter")? json.get("filter").toString() : null;
  2775. */
  2776. /* 改为新UI。Lin
  2777. * 再改回,大叶 写的 if-else 分支没有不同
  2778. * String cascadingfilter = null;
  2779. * if(ccpIsNewUI) {
  2780. * cascadingfilter = json.has("filter") ? json.get("filter").toString() : null;
  2781. * }else{
  2782. * cascadingfilter = json.has("filter") ? json.get("filter").getAsString() : null;
  2783. * }
  2784. */
  2785. /* 再改,.getAsString( 只有 filter 值为一个字符串才适用,但现在规范后 filter 值是一个 json 对象而不是字符串。Ben(20251208)
  2786. String cascadingfilter = json.has("filter")? json.get("filter").getAsString() : null;
  2787. */ String cascadingfilter = json.has("filter")? json.get("filter").toString() : null;
  2788. /// 增加,支持共用 ccp 定义。如 负责部门 > 负责人员、联系部门 > 联系人员,共用 部门 > 人员。Lin
  2789. String prfx = json.has("prfx")? json.get("prfx").getAsString() : "";
  2790. ///
  2791. /* 去掉 appName,直接用 PrjApp.。Lin
  2792. CascadingSelectObject mm = webapp.getCascadingSelectObject().get(cascadingname);
  2793. */ CcpB mm = prjApp.ccpMap.get(cascadingname); // = PrjApp.。再,支持对象名。Lin
  2794. if (mm != null) { // (mm != null)。Lin
  2795. /* 再,不用 Clone -- 浅克隆没用,深克隆麻烦。Lin
  2796. /// 增加,支持共用 ccp 定义。Lin
  2797. CcpB mm = mmOri.clone();
  2798. mm.combField.name = prfx + mm.combField.name;
  2799. for(CcpFieldB input : mm.combField.fieldList){
  2800. input.name = prfx + input.name;
  2801. }
  2802. ///
  2803. */
  2804. /* <inputs > 支持多个了。Lin
  2805. * 增加了可以直接写单个 Field, <field />(<sglField />) -- 可以没有 <combField >
  2806. if(StringUtil.notNull(mm.getInputs().getName())){
  2807. allcascadingInputNames.add(mm.getInputs().getName());
  2808. allcascadingInputNamesObject.put(mm.getInputs().getName(), mm);
  2809. }
  2810. for(Input input: mm.getInputs().getInputList()){
  2811. allcascadingInputNames.add(input.getName());
  2812. allcascadingInputNamesObject.put(input.getName(), mm);
  2813. }
  2814. */
  2815. /* 暂时只支持有且只有一个 <combField >。Lin
  2816. * 暂时不支持单个Field <field />
  2817. for(CascaderCombFieldB inputs : mm.combFieldMap.values()){
  2818. allcascadingInputNames.add(inputs.name);
  2819. allcascadingInputNamesObject.put(inputs.name, mm);
  2820. for(CascaderFieldB input : inputs.fieldMap.values()){
  2821. allcascadingInputNames.add(input.name);
  2822. allcascadingInputNamesObject.put(input.name, mm);
  2823. }
  2824. }
  2825. for(CascaderSglFieldB sglField : mm.sglFieldMap.values()){ // 单个 Field。Lin
  2826. allcascadingInputNames.add(sglField.name);
  2827. allcascadingInputNamesObject.put(sglField.name, mm);
  2828. }
  2829. */
  2830. /* 再, 增加支持共用 ccp 定义。Lin
  2831. if (StringUtils.isNotBlank(mm.combField.name)) { // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  2832. allcascadingInputNames.add(mm.combField.name);
  2833. allcascadingInputNamesObject.put(mm.combField.name, mm);
  2834. }
  2835. for(CcpFieldB input: mm.combField.fieldList){
  2836. allcascadingInputNames.add(input.name);
  2837. allcascadingInputNamesObject.put(input.name, mm);
  2838. }
  2839. */
  2840. if (StringUtils.isNotBlank(mm.combField.name)) {
  2841. allcascadingInputNames.add(prfx + mm.combField.name);
  2842. allcascadingInputNamesObject.put(prfx + mm.combField.name, mm);
  2843. cascadingPrfx.put(prfx + mm.combField.name, prfx);
  2844. }
  2845. for (CcpFieldB input : mm.combField.fieldList) {
  2846. allcascadingInputNames.add(prfx + input.name);
  2847. allcascadingInputNamesObject.put(prfx + input.name, mm);
  2848. cascadingPrfx.put(prfx +input.name, prfx);
  2849. }
  2850. // int si = mm.getInputs().getInputList().size() - 1;
  2851. // String lastInputName = mm.getInputs().getInputList().get(si).getName();
  2852. // String filterStr = StringUtil.notNull(cascadingfilter) ? ("filter=\"" + cascadingfilter + "\"") : "";
  2853. Map<String, String> map = new HashMap<>();
  2854. map.put("name", cascadingname); // 这里不用加 prfx -- 增加支持共用 ccp 定义。Lin
  2855. if (cascadingfilter != null)
  2856. map.put("filter", cascadingfilter);
  2857. map.put("mode", (wdReadonly||isInfo)?"play":"edit");
  2858. /// 保存 prfx,增加 <ss:ccp prfx= 属性 -- 增加支持共用 ccp 定义。Lin
  2859. map.put("prfx", prfx);
  2860. ///
  2861. /* 再增加,支持共用 ccp 定义。Lin
  2862. cascadingTagNewAttribute.put(cascadingname, map);
  2863. */ cascadingTagNewAttribute.put(prfx + cascadingname, map);
  2864. // cascadingTagNew.put(lastInputName,cascadingname);
  2865. }
  2866. /// 再增加,<input ssCcp= 增加支持多个 Ccp,支持简写。Lin
  2867. } // for (JsonElement je : ccpJa) {
  2868. ///
  2869. } catch (Exception e) {
  2870. /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
  2871. e.printStackTrace();
  2872. */ log4j.error("PageComper.addViewObjectTools( 异常", e);
  2873. SsLog.print("ssCcp= 不是 Json:"+ wdCascadingSelect);
  2874. }
  2875. // allInputTab.add(inputTab);
  2876. }
  2877. }
  2878. if (existObjectPicker != null)
  2879. allObjectPicker.add(existObjectPicker);
  2880. if (existcascadingSelect != null) {
  2881. // allcascadingTagExist.add(existcascadingSelect);
  2882. /* 去掉 appName,直接用 PrjApp.。Lin
  2883. CascadingSelectObject mm =webapp.getCascadingSelectObject().get(existcascadingSelect[1]);
  2884. */ CcpB mm = prjApp.ccpMap.get(existcascadingSelect[1]); // = PrjApp.。再,支持多线程。Lin
  2885. if (mm != null) {
  2886. ///// 下面需要扩展支持共用 ccp 定义 -- 增加 <ccp@ss prfx=???Lin
  2887. // 用到再弄
  2888. /////
  2889. /* <inputs > 支持多个了。Lin
  2890. * 增加了可以直接写单个 Field, <field />(<sglField />) -- 可以没有 <combField >
  2891. if(StringUtil.notNull(mm.getInputs().getName())){
  2892. notHandleCascadingInputNames.add(mm.getInputs().getName());
  2893. allcascadingInputNames.add(mm.getInputs().getName());
  2894. allcascadingInputNamesObject.put(mm.getInputs().getName(), mm);
  2895. }
  2896. for(Input input: mm.getInputs().getInputList()){
  2897. notHandleCascadingInputNames.add(input.getName());
  2898. allcascadingInputNames.add(input.getName());
  2899. allcascadingInputNamesObject.put(input.getName(), mm);
  2900. }
  2901. */
  2902. /* 暂时只支持有且只有一个 <combField >。Lin
  2903. * 暂时不支持单个Field <field />
  2904. for(CascaderCombFieldB inputs : mm.combFieldMap.values()){
  2905. notHandleCascadingInputNames.add(inputs.name);
  2906. allcascadingInputNames.add(inputs.name);
  2907. allcascadingInputNamesObject.put(inputs.name, mm);
  2908. for(CascaderFieldB input : inputs.fieldMap.values()){
  2909. notHandleCascadingInputNames.add(input.name);
  2910. allcascadingInputNames.add(input.name);
  2911. allcascadingInputNamesObject.put(input.name, mm);
  2912. }
  2913. }
  2914. for(CascaderSglFieldB sglField : mm.sglFieldMap.values()){ // 单个 Field。Lin
  2915. notHandleCascadingInputNames.add(sglField.name);
  2916. allcascadingInputNames.add(sglField.name);
  2917. allcascadingInputNamesObject.put(sglField.name, mm);
  2918. }
  2919. */
  2920. if (StringUtils.isNotBlank(mm.combField.name)) {
  2921. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  2922. notHandleCascadingInputNames.add(mm.combField.name);
  2923. allcascadingInputNames.add(mm.combField.name);
  2924. allcascadingInputNamesObject.put(mm.combField.name, mm);
  2925. }
  2926. for(CcpFieldB input: mm.combField.fieldList){
  2927. notHandleCascadingInputNames.add(input.name);
  2928. allcascadingInputNames.add(input.name);
  2929. allcascadingInputNamesObject.put(input.name, mm);
  2930. }
  2931. }
  2932. }
  2933. /* 再改,IDEA:String concatenation as argument to 'StringBuffer.append()' call。Lin
  2934. sb.append(s + "\r\n");
  2935. */ sb.append(s).append("\r\n");
  2936. }
  2937. List<String[]> removeList = new LinkedList<>();
  2938. Set<String> repeatName = new HashSet<>();
  2939. Set<String> repeatName_ = new HashSet<>();
  2940. for (String[] temp : allInputTab) {
  2941. String name = temp[1];
  2942. boolean isRemove = false;
  2943. if (repeatName_.contains(name)) {
  2944. repeatName.add(name);
  2945. }
  2946. repeatName_.add(name);
  2947. for (String[] temp1 : allObjectPicker) {
  2948. if (temp1[1].equals(name) || (temp1[1] + "id").equals(name) || (temp1[1] + "m").equals(name)) {
  2949. isRemove = true;
  2950. break;
  2951. }
  2952. // input=true隐藏字段可能会加id,m
  2953. }
  2954. //noinspection SuspiciousIndentAfterControlStatement
  2955. if(!isRemove)
  2956. try {
  2957. // for (String[] temp1 : allcascadingTagExist) {
  2958. // if (temp1[1].equals(name)) {
  2959. // isRemove = true;
  2960. // break;
  2961. // }
  2962. //
  2963. // CascadingSelectObject m =webapp.getCascadingSelectObject().get(temp1[1]);
  2964. // if (m != null && m.getPrimaryNam().contains(name)) {
  2965. // isRemove = true;
  2966. // break;
  2967. // }
  2968. // }
  2969. if(allcascadingInputNames.contains(name))
  2970. isRemove = true;
  2971. if (isRemove)
  2972. allcascadingSelect_input.add(temp);
  2973. } catch (Exception e) {
  2974. /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
  2975. e.printStackTrace();
  2976. */ log4j.error("PageComper.addViewObjectTools( 异常", e);
  2977. }
  2978. // xxx_1,xxx2为onoffbutton,放到指定集合
  2979. // <input name="sfpm_1"/>、<input name="sfpm_0"/>。Lin
  2980. /* 再改,IDEA:Redundant character escape '\\_' in RegExp。Lin
  2981. if (name.matches(".*?\\_[0-9yesno]+$")) {
  2982. */ if (name.matches(".*?_[0-9yesno]+$")) {
  2983. // String fName = name.split("\\_")[0];
  2984. /* 再改,IDEA:Redundant character escape '\\_' in RegExp。Lin
  2985. String fName = name.replaceAll("\\_[0-9yesno]+$", "");
  2986. */ String fName = name.replaceAll("_[0-9yesno]+$", "");
  2987. /* 再改,IDEA:Can be replaced with single 'Map.computeIfAbsent' method call。Lin
  2988. if (allonoffbutton.get(fName) == null)
  2989. allonoffbutton.put(fName, new LinkedList<>());
  2990. */ allonoffbutton.computeIfAbsent(fName, k -> new LinkedList<>());
  2991. allonoffbutton.get(fName).add(temp);
  2992. isRemove = true;
  2993. }
  2994. /// 增加,支持 <input name="sfpm"/> -- 像普通字段一样写。Lin
  2995. else {
  2996. ObjFieldB field = vo.fieldMap.get(name);
  2997. if (field != null && field.type == ObjC.FIELD_boolType) {
  2998. /* 再改,IDEA:Can be replaced with single 'Map.computeIfAbsent' method call。Lin
  2999. if (allonoffbutton.get(name) == null)
  3000. allonoffbutton.put(name, new LinkedList<>());
  3001. */ allonoffbutton.computeIfAbsent(name, k -> new LinkedList<>());
  3002. allonoffbutton.get(name).add(temp);
  3003. isRemove = true;
  3004. }
  3005. }
  3006. ///
  3007. if (isRemove)
  3008. removeList.add(temp);
  3009. }
  3010. for (String[] temp : allInputTab) {
  3011. if (repeatName.contains(temp[1]))
  3012. removeList.add(temp);
  3013. }
  3014. for (String[] temp1 : removeList) {
  3015. allInputTab.remove(temp1);
  3016. }
  3017. // String tabProgram = ""; // 再去掉,移到下面用到的地方。Lin
  3018. // 判断是否查看部件
  3019. if (isInfo) { //???看 allInputTab、allcascadingSelect_input
  3020. /* 再去掉,按 IDEA 规范 -- Variable is already assigned to this value。Lin
  3021. isInfo = true;
  3022. */
  3023. /* 没有 WD 了,与应用放到一起。Lin
  3024. * 去掉 appName,直接用 PrjApp.
  3025. String foldA = WD.webRoot() + "/main/sheji/object/baseInfo/init.jsp";
  3026. String foldB = WD.webRoot() + "/main/sheji/object/baseInfo/" + appName + "/source.jsp";
  3027. */
  3028. /* 再,不复制,直接用 init.jsp。Lin
  3029. String foldA = AppB.webRoot +"main/sheji/object/baseInfo/init.jsp";
  3030. String foldB = AppB.webRoot +"main/sheji/object/baseInfo/"+ PrjApp.prjName +"/source.jsp";
  3031. if (new File(foldA).exists()) {
  3032. if (new File(foldB).exists() == false) {
  3033. new File(foldB).getParentFile().mkdirs();
  3034. FileU.copyFile(foldA, foldB);
  3035. }
  3036. StringBuffer newsb = new StringBuffer();
  3037. String sourceContent = FileU.rdStr(foldB);
  3038. */
  3039. /* 改为新UI。Lin
  3040. * 与 新UI 的 header.jsp 放在一起
  3041. String foldA = AppB.webRoot +"pms/clip/baseInfo.jsp"; // = AppB.appRoot +。仅出现在 PMS 项目里。Lin
  3042. */ String foldA = AppB.webRoot +"page/clip/baseInfo.jsp"; // = AppB.appRoot +。仅出现在 PMS 项目里。Lin
  3043. if (new File(foldA).exists()) {
  3044. StringBuffer newsb = new StringBuffer();
  3045. String sourceContent = FileU.rdStr(foldA);
  3046. /* 再改,IDEA:Redundant character escape '\\_' in RegExp。Lin
  3047. Pattern p = Pattern.compile("#include\\_baseInfo");
  3048. */ Pattern p = Pattern.compile("#include_baseInfo");
  3049. Matcher m = p.matcher(sourceContent);
  3050. while (m.find()) {
  3051. m.appendReplacement(newsb, Matcher.quoteReplacement(sb.toString()));
  3052. }
  3053. m.appendTail(newsb);
  3054. sb = newsb;
  3055. }
  3056. // input部件
  3057. }
  3058. // else if (bjdm.toLowerCase().matches(vo.getName() + "_.*input")) {
  3059. //
  3060. // } else {
  3061. // // return new StringReader(sb.toString());
  3062. // }
  3063. String content = sb.toString();
  3064. /* 再改为 IDEA 规范。Lin
  3065. * Variable 'tabProgram' initializer '""' is redundant
  3066. * String concatenation '+=' in loop
  3067. String tabProgram = ""; // 再,从上面移到这。Lin
  3068. */ StringBuilder tabProgram; // 再,从上面移到这。Lin
  3069. // BaseBean bean = (BaseBean) Class.forName(vo.getObjClass())
  3070. // .newInstance();
  3071. // 处理单个input类型 wd:translate, objectpicker
  3072. for (String[] temp : allInputTab) {
  3073. String name = temp[1];
  3074. ObjFieldB field = vo.fieldMap.get(name);
  3075. if (field == null)
  3076. continue;
  3077. String value = "${"+ dxm +"."+ field.name +"}";
  3078. Map<String, String> wdWriteproperties = inputElementProperties_WdWrite(temp[0]);
  3079. Map<String, String> inputproperties = inputElementProperties_input(temp[0]);
  3080. boolean wdReadonly="true".equals(inputproperties.get("wdReadonly")); // 用到再弄???Lin
  3081. if (inputproperties.get("ssBtn") != null) { // ("wdButton")
  3082. inputproperties.put("button", inputproperties.get("ssBtn")); // ("wdButton"))。Lin
  3083. }
  3084. // 忽略input type=button/hidden
  3085. // if("button".equals(inputproperties.get("type")))continue;
  3086. if (StringUtils.isNotBlank(inputproperties.get("type"))
  3087. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  3088. && !"text".equals(inputproperties.get("type"))) {
  3089. if (filterNames.contains(name))
  3090. continue;
  3091. if (Arrays.asList(ObjC.FIELD_cmsType, ObjC.FIELD_htmlType).contains(field.type))
  3092. // Field.TYPE_CMS, Field.TYPE_HTML。Lin
  3093. continue;
  3094. /* 改。Lin
  3095. if (!"hidden".equals(inputproperties.get("type")))
  3096. continue;
  3097. */
  3098. if ("hidden".equals(inputproperties.get("type"))) {
  3099. //加上对隐藏字段新UI的发布处理 Ben(20260413)
  3100. //录入页,用新UI
  3101. if(pageobj.isInp) {
  3102. String oneLine = PageCompU.getInputCode(PageCompC.FORM_PLUGIN_JS_TYPE_hiden, //组件类弄
  3103. inputproperties,//组件属性
  3104. vo,
  3105. field.getName()
  3106. );
  3107. content = content.replace(temp[0], oneLine);
  3108. }
  3109. continue;
  3110. }
  3111. /* 下面代码,是对象配置中type="picture"的隐藏字段,替换一下,作发布准备的
  3112. 但是现在对象配置只用"photo",已经取消"picture",所以下面对##这些变量replace一下这个代码已经没用
  3113. 所以注释掉 Ben(20260413)
  3114. if (inputproperties.get("value")!=null)
  3115. value=inputproperties.get("value");
  3116. String c = "";
  3117. c += "<input "+getAttributeStr(inputproperties, "id")+
  3118. " name=\"##fieldNamePrefix##fileName\" type=\"hidden\" value=\""+value+"\">\r\n";
  3119. c = c.replaceAll("##fileName", field.name)
  3120. .replaceAll("##tableName", dxm)
  3121. .replaceAll("##fieldNamePrefix",Matcher.quoteReplacement(fieldNamePrefix))
  3122. .replaceAll("##fieldNameValPrefix",Matcher.quoteReplacement(fieldNameValPrefix));
  3123. content =content.replace(temp[0],(wdReadonly||isInfo)?"": c);
  3124. */
  3125. continue;
  3126. }
  3127. if (wdWriteproperties.get("format") == null &&
  3128. /* String 改为 int。Lin
  3129. field.type.equals(ObjC.FIELD_timeType)) { // Field.TYPE_TIME。Lin
  3130. */
  3131. /* 再改,保留 FIELD_dateType 了 -- 不转为 FIELD_timeType 了。Lin
  3132. field.type == ObjC.FIELD_timeType) {
  3133. */ (field.type == ObjC.FIELD_dateType || field.type == ObjC.FIELD_timeType)) {
  3134. wdWriteproperties.put("miniDate", "false");
  3135. /* 改,去掉 Display(<field display= >) 了,用 <field format= >。Lin
  3136. wdWriteproperties.put("format", field.getDisplay().getFormat());
  3137. */ wdWriteproperties.put("format", field.fmt);
  3138. }
  3139. if (wdReadonly || isInfo) {// 查看部件
  3140. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3141. tabProgram = "\r\n<%--自动生成:"+ dxm +"."+ name +"--%>";
  3142. */ tabProgram = new StringBuilder("\r\n<%--自动生成:"+ dxm +"."+ name +"--%>");
  3143. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3144. String writeStr = "";
  3145. */ StringBuilder writeStr = new StringBuilder();
  3146. // if(inputproperties.get("size")!=null)wdWriteproperties.put("length",
  3147. // inputproperties.get("size"));
  3148. /* 再改,IDEA:Can be replaced with single 'Map.putIfAbsent' method call。Lin
  3149. if (wdWriteproperties.get("value") == null)
  3150. wdWriteproperties.put("value", value);
  3151. */ wdWriteproperties.putIfAbsent("value", value);
  3152. //
  3153. // if (false && inputproperties.get("width") != null) {
  3154. // inputproperties.put("style",
  3155. // "width:" + inputproperties.get("width"));
  3156. // inputproperties.remove("width");
  3157. // }
  3158. // 翻译codebook
  3159. /* 去掉 _view.jsp 了。Lin
  3160. if (isViewJsp) {
  3161. // if(inputproperties.get("size")!=null){
  3162. // tabProgram+=TextTag.trimText(demoText,
  3163. // Integer.parseInt(inputproperties.get("size")));
  3164. // }else{
  3165. if (inputproperties.get("style") != null || inputproperties.get("width") != null)
  3166. writeStr += getDemoText();
  3167. // }
  3168. } else */
  3169. /* String 改为 int。Lin
  3170. if (field.type.equals(ObjC.FIELD_boolType)) { // "boolean" = Field.TYPE_BOOLEAN。Lin
  3171. */ if (field.type == ObjC.FIELD_boolType) {
  3172. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3173. writeStr += TagComper.compTag(
  3174. // wdoptionTransform.transform(str) 移到 transform(tagAtrMap) 后,
  3175. // 就可以用 TagComper.transform(str) 了。Lin
  3176. /// * 改。Lin
  3177. // "<wd:write type=\"option\" object=\""+ vo.name
  3178. // + "\" field=\""+ field.name
  3179. // + "\" value=\""+ value +"\" />");
  3180. /// *
  3181. "<opt@ss obj=\""+ vo.name +"\" field=\""+ field.name +"\" val=\""+ value +"\" />");
  3182. */ writeStr.append(TagComper.compTag(
  3183. "<opt.ss obj=\""+ vo.name +"\" field=\""+ field.name +"\" val=\""+ value +"\" />"));
  3184. } else if (StringUtils.isNotBlank(field.cbName)) {
  3185. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  3186. // String
  3187. // lengthStr=inputproperties.get("size")!=null?("length=\""+inputproperties.get("size")+"\""):("");
  3188. // String lengthStr = ""; // 去掉,没用到。Lin
  3189. /* 改。Lin
  3190. writeStr += "<wd:translate name=\""
  3191. + Optional.ofNullable(inputproperties.get("wdCodebook")).orElse(field.cbName)
  3192. + "\" value=\""+ wdWriteproperties.get("value")
  3193. + "\" filter=\""+ (inputproperties.get("wdFilter") != null? inputproperties.get("wdFilter") : "")
  3194. + "\"/>";
  3195. */
  3196. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3197. writeStr += "<ss:cbTrans cb=\""
  3198. + Optional.ofNullable(inputproperties.get("wdCodebook")).orElse(field.cbName)
  3199. + "\" val=\""+ wdWriteproperties.get("value")
  3200. + "\" filter=\""+ (inputproperties.get("wdFilter") != null? inputproperties.get("wdFilter") : "")
  3201. + "\"/>"; // 不用编译 <cbTrans@ss -- 直接写编译后的。Lin
  3202. */ writeStr.append("<ss:cbTrans cb=\"")
  3203. .append(Optional.ofNullable(inputproperties.get("wdCodebook")).orElse(field.cbName))
  3204. .append("\" val=\"").append(wdWriteproperties.get("value"))
  3205. .append("\" filter=\"")
  3206. .append(inputproperties.get("ssFilter") != null ? inputproperties.get("ssFilter") : "")
  3207. .append("\"/>"); // 不用编译 <cbTrans@ss -- 直接写编译后的。Lin
  3208. } else {// wdwrite
  3209. /* 增加把 "value" 转为 <txt@ss 的 "val","format" 转为 "fmt"。Lin
  3210. * wdWriteproperties 仍为 "value" --
  3211. * IDEA -- String concatenation '+=' in loop
  3212. writeStr += "<wd:write ";
  3213. for (Map.Entry<String, String> entry : wdWriteproperties.entrySet()) {
  3214. writeStr += entry.getKey() + "=\"" + entry.getValue() + "\" ";
  3215. }
  3216. */
  3217. writeStr.append("<txt.ss ");
  3218. String key;
  3219. for (Entry<String, String> entry : wdWriteproperties.entrySet()) {
  3220. key = entry.getKey();
  3221. if ("value".equals(key)) // 增加,转为新标准。Lin
  3222. key = "val";
  3223. else if ("format".equals(key)) // 增加,转为新标准。Lin
  3224. key = "fmt";
  3225. /* 再改用 '',避免与字符串里的 "" 冲突。Lin
  3226. writeStr += (key +"=\""+ entry.getValue() +"\" ");
  3227. */
  3228. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3229. writeStr += (key +"='"+ entry.getValue() +"' ");
  3230. */ writeStr.append(key).append("='").append(entry.getValue()).append("' ");
  3231. }
  3232. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3233. writeStr += "/>";
  3234. writeStr = TagComper.compTag(writeStr);
  3235. // textTransformer.transform(str) 移到 transform(tagAtrMap) 后,
  3236. // 就可以用 TagComper.transform(str) 了。Lin
  3237. */
  3238. writeStr.append("/>");
  3239. writeStr = new StringBuilder(TagComper.compTag(writeStr.toString()));
  3240. }
  3241. String styleStr = getAttributeStr(inputproperties, "style");
  3242. String widthStr = getAttributeStr(inputproperties, "width");
  3243. String heightStr = getAttributeStr(inputproperties, "height");
  3244. /* 去掉,没用到。Lin
  3245. String nameStr = getAttributeStr(inputproperties, "name");
  3246. */
  3247. String buttonStr = getAttributeStr(inputproperties, "button");
  3248. if (StringUtils.isNotBlank(buttonStr)) // 增加,转为新标准。Lin
  3249. buttonStr = buttonStr.replace("button=", "btn=");
  3250. String maxHeightStr = getAttributeStr(inputproperties, "maxHeight");
  3251. /* 去掉,Dead code。Lin
  3252. if (true || field.type.equals(ObjC.FIELD_txtType)) { // field.TYPE_TEXT。Lin
  3253. */
  3254. // 默认值
  3255. // <div id="ms" width="100%" height="100px"><wd:write
  3256. // value='${ry.ms}'/></div>
  3257. // <wd:write type="growHeight" name="ms" mode="edit"
  3258. // maxHeight="300px"/>
  3259. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3260. tabProgram += "<div id=\""+ fieldNamePrefix + inputproperties.get("name")
  3261. + "\" "+ styleStr +" "+ widthStr +" "+ heightStr +">"+ writeStr +"</div>";
  3262. tabProgram += TagComper.compTag(
  3263. // 用 TagComper.transform(),growHeightTransformer 没盖写过。Lin
  3264. /// * 改。Lin
  3265. // "<wd:write type=\"growHeight\" multiLine=\""+ field.isMultiline
  3266. ///*
  3267. "<growh@ss multiline=\""+ field.isMultiline
  3268. + "\" name=\""+ fieldNamePrefix + name
  3269. + "\"" + " mode=\"play\" "+ buttonStr +" "+ maxHeightStr +" />");
  3270. */
  3271. tabProgram.append("<div id=\"").append(fieldNamePrefix).append(inputproperties.get("name"))
  3272. .append("\" ").append(styleStr).append(" ").append(widthStr).append(" ")
  3273. .append(heightStr).append(">").append(writeStr).append("</div>");
  3274. tabProgram.append(TagComper.compTag(
  3275. "<growh.ss multiline=\""+ field.isMultiline
  3276. + "\" name=\""+ fieldNamePrefix + name
  3277. + "\" mode=\"play\" "+ buttonStr +" "+ maxHeightStr +" />"));
  3278. /* 去掉,Dead code。Lin
  3279. } else {
  3280. tabProgram += "<div class=\"text-div\" "+ styleStr +" "+ widthStr
  3281. + " title=\""+ writeStr +"\">"+ writeStr +"</div>";
  3282. }
  3283. */
  3284. if (isBaseInfo)
  3285. /* 改。Lin
  3286. tabProgram = "<wd:permission name=\""+ name +"\">\r\n"
  3287. + tabProgram +"\r\n</wd:permission>";
  3288. */
  3289. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3290. tabProgram = "<ss:auth field=\""+ name +"\">\r\n"
  3291. + tabProgram +"\r\n</ss:auth>"; // 不用编译 <auth@ss -- 直接写编译后的。Lin
  3292. */ tabProgram = new StringBuilder("<ss:auth field=\""+ name +"\">\r\n"
  3293. + tabProgram +"\r\n</ss:auth>"); // 不用编译 <auth@ss -- 直接写编译后的。Lin
  3294. /* 再去掉,移到 if-else 后 -- 按 IDEA 规范 -- Common part can be extracted from 'if'。Lin
  3295. content = content.replace(temp[0], tabProgram);
  3296. */
  3297. } else {// 其他当作录入部件
  3298. // boolean isCascadingInput = allcascadingSelect_input.contains(temp);
  3299. // if (isCascadingInput && !isViewJsp)
  3300. // inputproperties.put("type", "hidden");
  3301. if (inputproperties.get("width") != null) {
  3302. String style_ = inputproperties.get("style");
  3303. style_ = style_ == null ? "" : style_;
  3304. style_ += "width:" + inputproperties.get("width") + ";";
  3305. inputproperties.put("style", style_);
  3306. }
  3307. // inputproperties.remove("width");
  3308. if (StringUtils.isNotBlank(field.cbName)) { // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  3309. /* 再改,IDEA:Can be replaced with single 'Map.putIfAbsent' method call。Lin
  3310. if (inputproperties.get("value") == null)
  3311. inputproperties.put("value", value);
  3312. */ inputproperties.putIfAbsent("value", value);
  3313. /* 改为新UI。Lin
  3314. * "新UI发布程序:"
  3315. * "下拉菜单 objPicker 录入页发布:"
  3316. * "旧UI的发布程序,只是用来参考,已经没用了"
  3317. String hiddenElement = "<input name=\""+ fieldNamePrefix + name
  3318. + "\" type=\"hidden\" value=\""+ inputproperties.get("value")
  3319. + "\" "+ getAttributeStr(inputproperties, "onchange") +" />";
  3320. inputproperties.remove("value");
  3321. inputproperties.remove("onchange");
  3322. inputproperties.put("name", fieldNamePrefix+name + "Name");
  3323. inputproperties.put("type", "text");
  3324. /// * 没有 _view.jsp 了。Lin
  3325. // if (isViewJsp) {
  3326. // inputproperties.put("value", getDemoText());
  3327. // }
  3328. /// *
  3329. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  3330. // String inputElement = "<input ";
  3331. /// *
  3332. StringBuilder inputElement = new StringBuilder("<input ");
  3333. inputproperties.remove("width");
  3334. for (Entry<String, String> entry : inputproperties.entrySet()) {
  3335. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  3336. // inputElement += entry.getKey() + "=\"" + entry.getValue() + "\" ";
  3337. /// *
  3338. inputElement.append(entry.getKey()).append("=\"").append(entry.getValue()).append("\" ");
  3339. }
  3340. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  3341. // inputElement += "/>";
  3342. /// *
  3343. inputElement.append("/>");
  3344. String inputValue = inputproperties.get("wdInput") == null?
  3345. inputproperties.get("input") : inputproperties.get("wdInput");
  3346. if (StringUtils.isBlank(inputValue)) // 去掉 StrU.isNull(),直接用 StringUtils.isBlank()。Lin
  3347. inputValue = ((field.inpable)? "true" : "false");
  3348. // objectpicker
  3349. ///// * 改。Lin
  3350. // tabProgram = "<wd:write type=\"objectPicker\" name=\""+ fieldNamePrefix + name
  3351. // + "\" input=\""+ inputValue
  3352. // + "\" codebook=\""+ Optional.ofNullable(inputproperties.get("wdCodebook")).orElse(field.cbName)
  3353. // + "\" object=\""+ Optional.ofNullable(field.objName).orElse("")
  3354. // + "\" "+ (field.addable? ("add=\"true\"") : "")
  3355. // + " filter=\""+ (inputproperties.get("wdFilter") != null? inputproperties.get("wdFilter") : "")
  3356. ///// *
  3357. ///// * 再改,IDEA:String concatenation '+=' in loop。Lin
  3358. // tabProgram = "<objp@ss name=\""+ fieldNamePrefix + name
  3359. // + "\" inp=\""+ inputValue
  3360. // + "\" cb=\""+ Optional.ofNullable(inputproperties.get("wdCodebook")).orElse(field.cbName)
  3361. // + "\" obj=\""+ Optional.ofNullable(field.objName).orElse("")
  3362. // + "\" "+ (field.addable? ("add=\"true\"") : "")
  3363. // + " filter=\""+ (inputproperties.get("wdFilter") != null? inputproperties.get("wdFilter") : "")
  3364. /// * 去掉 Field.filter(String),用 filterList。Lin
  3365. // * 拼回 "zyid,rxnd"
  3366. // + "\"" +(field.getFilter()!=null?(" filterField=\""+ field.getFilter() +"\"") : "")
  3367. /// *
  3368. /// * 再去掉 .filterList,用回 .filterStr -- 页面用到,不改页面、JS 先。Lin
  3369. // + "\"" +((field.filterList.size() > 0)?
  3370. // (" filterField=\""+ StringUtils.join((field.filterList).toArray(), ',') +"\"")
  3371. // // 去掉 StrU.join(),直接用 StringUtils.join()。Lin
  3372. // : "")
  3373. /// *
  3374. // + "\"" +((field.filterStr != null)?(" filterField=\""+ field.filterStr +"\"") : "")
  3375. // + "/>";
  3376. ///// *
  3377. ///// * 再改,增加 field.inpCbName 和 field.cbParmStr。Lin
  3378. // * 需要判断 页面的 wdCodebook 和 配置文件的 field.inpCbName 和 field.cbName -- wdCodebook > .inpCbName > .cbName
  3379. // * 需要判断 页面的 ssFilter 和 配置文件的 field.cbParmStr -- ssFilter > .cbParm=
  3380. // * 太复杂,不好阅读
  3381. // tabProgram = new StringBuilder("<objp.ss name=\""+ fieldNamePrefix + name +
  3382. // "\" inp=\""+ inputValue +"\""+
  3383. // " cb=\""+ Optional.ofNullable(inputproperties.get("wdCodebook")).orElse(field.cbName) +"\""+
  3384. // " obj=\""+ Optional.ofNullable(field.objName).orElse("") +"\""+
  3385. // (field.addable ? (" add=\"true\"") : "") +
  3386. // " filter=\""+ ((inputproperties.get("wdFilter") != null)? inputproperties.get("wdFilter") : "") +"\""+
  3387. // ((field.filterStr != null)? (" filterField=\""+ field.filterStr +"\"") : "") +
  3388. // "/>");
  3389. ///// *
  3390. ///// * 再改,分开 <field obj= 为 impObj= 和 addObj=,同时去掉 <field add="true" -- 归入 addObj=。Lin
  3391. // tabProgram = new StringBuilder();
  3392. // tabProgram.append("<objp.ss name=\"").append(fieldNamePrefix).append(name).append("\"")
  3393. // .append(" inp=\"").append(inputValue).append("\"");
  3394. // if (inputproperties.get("wdCodebook") != null)
  3395. // tabProgram.append(" cb=\"").append(inputproperties.get("wdCodebook")).append("\"");
  3396. // else if (field.inpCbName != null)
  3397. // tabProgram.append(" cb=\"").append(field.inpCbName).append("\"");
  3398. // else if (field.cbName != null)
  3399. // tabProgram.append(" cb=\"").append(field.cbName).append("\"");
  3400. // if (field.objName != null)
  3401. // tabProgram.append(" obj=\"").append(field.objName).append("\"");
  3402. // if (field.addable)
  3403. // tabProgram.append(" add=\"true\"");
  3404. // if (inputproperties.get("ssFilter") != null) // ("wdFilter")。Lin
  3405. // tabProgram.append(" filter=\"").append(inputproperties.get("ssFilter")).append("\""); // ("wdFilter")).。Lin
  3406. // else if (field.cbParmStr != null) // <field cbParm=,里层的引号,要用 "。Lin
  3407. // tabProgram.append(" filter='").append(field.cbParmStr).append("'");
  3408. // if (field.filterFieldStr != null)
  3409. // tabProgram.append(" filterField=\"").append(field.filterFieldStr).append("\"");
  3410. // tabProgram.append("/>");
  3411. ///// *
  3412. tabProgram = new StringBuilder();
  3413. tabProgram.append("<objp.ss name=\"").append(fieldNamePrefix).append(name).append("\"")
  3414. .append(" inp=\"").append(inputValue).append("\"");
  3415. if (inputproperties.get("wdCodebook") != null)
  3416. tabProgram.append(" cb=\"").append(inputproperties.get("wdCodebook")).append("\"");
  3417. else if (field.inpCbName != null)
  3418. tabProgram.append(" cb=\"").append(field.inpCbName).append("\"");
  3419. else if (field.cbName != null)
  3420. tabProgram.append(" cb=\"").append(field.cbName).append("\"");
  3421. if (field.addObjName != null) { // (field.objName !=。分开 <field obj= 为 impObj= 和 addObj=,同时去掉 <field add="true"。Lin
  3422. tabProgram.append(" obj=\"").append(field.addObjName).append("\""); // (field.objName).。Lin
  3423. // if (field.addable) // 去掉,<field add="true" 归入 addObj=。Lin
  3424. tabProgram.append(" add=\"true\"");
  3425. }
  3426. if (inputproperties.get("ssFilter") != null) // ("wdFilter")。Lin
  3427. tabProgram.append(" filter=\"").append(inputproperties.get("ssFilter")).append("\""); // ("wdFilter")).。Lin
  3428. else if (field.cbParmStr != null) // <field cbParm=,里层的引号,要用 "。Lin
  3429. tabProgram.append(" filter='").append(field.cbParmStr).append("'");
  3430. if (field.filterFieldStr != null)
  3431. tabProgram.append(" filterField=\"").append(field.filterFieldStr).append("\"");
  3432. tabProgram.append("/>");
  3433. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  3434. // *??? 另,考虑把 <ss:objp 的处理程序 ObjpTag 上移到这 -- 搞明白 miniInfo、Tips 内容 再定???
  3435. // * 把下面 TagComper.compTag( 的 <ss:objp name='dwlbm' inp='false' cb='dwlb'/> 直接改为 wd.edit.objectPicker.createObjectPicker(
  3436. // tabProgram = "<%--自动生成:"
  3437. // + dxm +"."+ name +"@"
  3438. // + Optional.ofNullable(inputproperties.get("wdCodebook")).orElse(field.cbName)
  3439. // + "--%>"
  3440. // + hiddenElement +"\r\n"
  3441. // + inputElement + "\r\n"
  3442. // + TagComper.compTag(tabProgram);
  3443. // // obectPickerTransformer.transform(str) 移到 transform(tagAtrMap) 后,
  3444. // // 就可以用 TagComper.transform(str) 了。Lin
  3445. /// *
  3446. tabProgram = new StringBuilder("<%--自动生成:"
  3447. + dxm +"."+ name +"@"
  3448. + Optional.ofNullable(inputproperties.get("wdCodebook")).orElse(field.cbName)
  3449. + "--%>"
  3450. + hiddenElement +"\r\n"
  3451. + inputElement +"\r\n"
  3452. + TagComper.compTag(tabProgram.toString()));
  3453. */
  3454. String objPickerInputContent = PageCompU.getInputCode(PageCompC.FORM_PLUGIN_JS_TYPE_objp, //组件类弄
  3455. inputproperties,//组件属性
  3456. vo,
  3457. field.getName()
  3458. );
  3459. tabProgram = new StringBuilder(objPickerInputContent);
  3460. /* 再去掉,移到 if-else 后 -- 按 IDEA 规范 -- Common part can be extracted from 'if'。Lin
  3461. content = content.replace(temp[0], tabProgram);
  3462. */
  3463. } else { // 下面,不含 <input name="sfpm" ssRun= /> -- 被移到 allonoffbutton 里了。Lin
  3464. // 生成录入框
  3465. // 这里的 <input ssRun= 是 Date、Time 字段里的。Lin
  3466. String wdCallback = inputproperties.get("ssRun"); // ("wdCallback")。Lin
  3467. if (wdCallback != null)
  3468. inputproperties.remove("ssRun"); // ("wdCallback")。Lin
  3469. // 页面设置的value是否带有标签
  3470. boolean valueWithTag = false;
  3471. // ////value
  3472. if (wdWriteproperties.get("value") == null) { // "value"。Lin
  3473. // value="<wd:write />"
  3474. wdWriteproperties.put("value", value); // "value",。Lin
  3475. /* 增加把 "value" 转为 txt@ss 的 "val","format" 转为 "fmt"。Lin
  3476. * wdWriteproperties 仍为 "value" -- 有空再改。Lin
  3477. tabProgram = "<wd:write ";
  3478. for (Map.Entry<String, String> entry : wdWriteproperties.entrySet()) {
  3479. tabProgram += entry.getKey() + "='" + entry.getValue() + "' ";
  3480. }
  3481. */
  3482. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3483. tabProgram = "<txt@ss ";
  3484. */ tabProgram = new StringBuilder("<txt.ss ");
  3485. String key;
  3486. for (Entry<String, String> entry : wdWriteproperties.entrySet()) {
  3487. key = entry.getKey(); // 增加。Lin
  3488. if ("value".equals(key)) // 增加,转为新标准。Lin
  3489. key = "val";
  3490. else if ("format".equals(key)) // 增加,转为新标准。Lin
  3491. key = "fmt";
  3492. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3493. tabProgram += (key +"='"+ entry.getValue() +"' ");
  3494. */ tabProgram.append(key).append("='").append(entry.getValue()).append("' ");
  3495. }
  3496. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3497. tabProgram += "/>";
  3498. tabProgram = TagComper.compTag(tabProgram);
  3499. // textTransformer.transform(str) 移到 transform(tagAtrMap) 后,
  3500. // 就可以用 TagComper.transform(str) 了。Lin
  3501. */
  3502. tabProgram.append("/>");
  3503. tabProgram = new StringBuilder(TagComper.compTag(tabProgram.toString()));
  3504. } else {
  3505. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3506. tabProgram = wdWriteproperties.get("value"); // "value"。Lin
  3507. valueWithTag = tabProgram.contains("<");
  3508. */
  3509. tabProgram = new StringBuilder(wdWriteproperties.get("value")); // "value"。Lin
  3510. valueWithTag = tabProgram.toString().contains("<");
  3511. }
  3512. /* 没有 _view.jsp 了。Lin
  3513. if (isViewJsp) {
  3514. tabProgram = getDemoText();
  3515. }
  3516. */
  3517. // SsLog.print(name +"-"+ field.type); // 去掉,干扰。Lin
  3518. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3519. inputproperties.put("value", tabProgram);
  3520. */
  3521. /* 再改,没区分查看和录入,现在改为下面:Ben(20260512)
  3522. inputproperties.put("value", tabProgram.toString());
  3523. */
  3524. if(isInfo) {//是查看页才使用<ss:txt val='${zy.mc}'/>这个标签,因为这个标签会特殊字符转义 Ben(20260512)
  3525. inputproperties.put("value", tabProgram.toString());
  3526. }else{
  3527. /// **
  3528. // * Ben(20260512)
  3529. // * 是录入页直接使用EL表达式如:${zy.mc},不用<ss:txt转义
  3530. // * 实际页面是用JS的反引号(模板字符串),如`${zy.ms}`输出,屏蔽笑柄注入,类似下面这样
  3531. // *ss.dom.formElemConfig.ms={val:`${zy.ms}`,type:window.ss.dom.TYPE.INPUT};
  3532. /// *
  3533. inputproperties.put("value", wdWriteproperties.get("value"));
  3534. }
  3535. inputproperties.put("name",fieldNamePrefix+name);
  3536. /* maxLength 改为 Integer。Lin
  3537. if (StringUtil.notNull(field.getMaxLength()) && inputproperties.get("maxLength") == null)
  3538. inputproperties.put("maxLength", field.getMaxLength());
  3539. */
  3540. if (field.maxLen != null && inputproperties.get("maxLength") == null)
  3541. inputproperties.put("maxLength", field.maxLen.toString());
  3542. /* 再改,IDEA:Can be replaced with single 'Map.putIfAbsent' method call。Lin
  3543. if (inputproperties.get("type") == null)
  3544. inputproperties.put("type", "text");
  3545. */ inputproperties.putIfAbsent("type", "text");
  3546. /* 再去掉,按 IDEA 规范 -- The value '"\r\n<%--自动生成:"+ dxm +"."+ name +"--%>"' assigned to 'tabProgram' is never used。Lin
  3547. tabProgram = "\r\n<%--自动生成:"+ dxm +"."+ name +"--%>";
  3548. */
  3549. /* 再去掉,与上面两行是一样的。Lin
  3550. if (inputproperties.get("type") == null)
  3551. inputproperties.put("type", "text");
  3552. */
  3553. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3554. tabProgram = "\r\n<%--自动生成:"+ dxm +"."+ name +"--%>";
  3555. */ tabProgram = new StringBuilder("\r\n<%--自动生成:"+ dxm +"."+ name +"--%>");
  3556. // Boolean clearbutton=false;
  3557. /* String 改为 int。Lin
  3558. if (field.type.equals(ObjC.FIELD_timeType)) { // field.TYPE_TIME。Lin
  3559. */
  3560. /* 再改,保留 FIELD_dateType 了 -- 不转为 FIELD_timeType 了。Lin
  3561. if (field.type == ObjC.FIELD_timeType) {
  3562. */ if (field.type == ObjC.FIELD_dateType || field.type == ObjC.FIELD_timeType) {
  3563. /* 改为新UI。Lin
  3564. inputproperties.remove("width");
  3565. String onpickedStr = (StringUtils.isNotBlank(wdCallback))?
  3566. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  3567. (",onpicked:function(){"+wdCallback+"();}") : "";
  3568. /// * 去掉 Display,用 .format。Lin
  3569. // inputproperties.put("onClick", "wd.edit.datePicker({dateFmt:'" + field.getDisplay().getFormat() + "'"+onpickedStr+"});");
  3570. /// *
  3571. inputproperties.put("onClick", "wd.edit.datePicker({dateFmt:'"+ field.fmt +"'"+ onpickedStr +"});");
  3572. inputproperties.put("autocomplete", "off");
  3573. ///// * 再改,IDEA:Can be replaced with single 'Map.computeIfAbsent' method call。Lin
  3574. // if (inputproperties.get("placeholder") == null)
  3575. /// * 去掉 Display,用 .format。Lin
  3576. // inputproperties.put("placeholder", field.getDisplay().getFormat());
  3577. /// *
  3578. // inputproperties.put("placeholder", field.fmt);
  3579. ///// *
  3580. inputproperties.computeIfAbsent("placeholder", k -> field.fmt);
  3581. */
  3582. /**
  3583. * 新UI:
  3584. * 日期,时间选择
  3585. */
  3586. if(pageobj.isInp) {
  3587. String type = PageCompC.FORM_PLUGIN_JS_TYPE_time;
  3588. if (field.type == ObjC.FIELD_dateType) //只要有日期的,类似年朋日时分这样的,也必需在obj.xml配置为日期格式
  3589. type = PageCompC.FORM_PLUGIN_JS_TYPE_date;
  3590. String code = PageCompU.getInputCode(type, //组件类弄
  3591. inputproperties,//组件属性
  3592. vo, name);
  3593. tabProgram.append(code);
  3594. }
  3595. }
  3596. /* String 改为 int。Lin
  3597. if (field.type.equals(ObjC.FIELD_txtType) // field.TYPE_TEXT。Lin
  3598. || field.type.equals(ObjC.FIELD_numType)) { // field.TYPE_NUMBER。Lin
  3599. */
  3600. /* 再改,把 if 改为 else if,不然日期录入的 input 也会跑下面的 else 中多生成出一个文本框在页面。Ben(20251208)
  3601. if (field.type == ObjC.FIELD_txtType || field.type == ObjC.FIELD_numType) {
  3602. */ else if (field.type == ObjC.FIELD_txtType || field.type == ObjC.FIELD_numType) {
  3603. // 默认值
  3604. /* 改为新UI。Lin
  3605. String heightStr = getAttributeStr(inputproperties, "height");
  3606. String widthStr = getAttributeStr(inputproperties, "width");
  3607. String maxHeightStr = getAttributeStr(inputproperties, "maxHeight");
  3608. String buttonStr = getAttributeStr(inputproperties, "button");
  3609. if (StringUtils.isNotBlank(buttonStr)) // 增加,转为新标准。Lin
  3610. buttonStr = buttonStr.replace("button=", "btn=");
  3611. String nameStr = getAttributeStr(inputproperties, "name");
  3612. // <div id="ms" width="100%"
  3613. // height="100px"><wd:write value='${ry.ms}'/></div>
  3614. // <wd:write type="growHeight" name="ms" mode="edit"
  3615. // maxHeight="300px"/>
  3616. ///// * 再改,IDEA:String concatenation '+=' in loop。Lin
  3617. // tabProgram += "<div id=\""+ inputproperties.get("name") +"\" "
  3618. // + getAttributeStr(inputproperties, "placeholder") +" "
  3619. // + widthStr +" "+ heightStr +">"
  3620. // + inputproperties.get("value") + "</div>";
  3621. // tabProgram += TagComper.compTag(
  3622. // // 用 TagComper.transform(),growHeightTransformer 没盖写过。Lin
  3623. /// * 改。Lin
  3624. // "<wd:write type=\"growHeight\" multiLine=\""+ field.isMultiline +"\" "
  3625. // + nameStr +" "+ buttonStr +" "+ maxHeightStr +" mode=\"edit\" />");
  3626. /// *
  3627. // "<growh@ss multiline=\""+ field.isMultiline +"\" "
  3628. // + nameStr +" "+ buttonStr +" "+ maxHeightStr +" mode=\"edit\" />");
  3629. ///// *
  3630. tabProgram.append("<div id=\"").append(inputproperties.get("name")).append("\" ")
  3631. .append(getAttributeStr(inputproperties, "placeholder")).append(" ")
  3632. .append(widthStr).append(" ").append(heightStr).append(">")
  3633. .append(inputproperties.get("value")).append("</div>");
  3634. tabProgram.append(TagComper.compTag(
  3635. "<growh.ss multiline=\""+ field.isMultiline +"\" "
  3636. + nameStr +" "+ buttonStr +" "+ maxHeightStr +" mode=\"edit\" />"));
  3637. */
  3638. /**
  3639. * 新UI:
  3640. * 普通文本录入
  3641. */
  3642. if(pageobj.isInp) {
  3643. String code = PageCompU.getInputCode(PageCompC.FORM_PLUGIN_JS_TYPE_input, //组件类弄
  3644. inputproperties,//组件属性
  3645. vo, name);
  3646. tabProgram.append(code);
  3647. }
  3648. } else if (valueWithTag) {// value写带有标签:input标签不处理
  3649. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3650. tabProgram += temp[0];
  3651. */ tabProgram.append(temp[0]);
  3652. } else { // 在下面,增加生成 是否 字段的 <onoff.ss???Lin
  3653. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3654. tabProgram += "<input ";
  3655. */ tabProgram.append("<input ");
  3656. for (Entry<String, String> entry : inputproperties.entrySet()) {
  3657. // System.out.println(entry.getKey()+"="+entry.getValue());
  3658. /* 再改,IDEA:'\'' is unnecessarily escaped。Lin
  3659. String quota = entry.getValue().contains("\"")? "\'" : "\"";
  3660. */ String quota = entry.getValue().contains("\"")? "'" : "\"";
  3661. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3662. tabProgram += entry.getKey() +"="+ quota + entry.getValue() + quota +" ";
  3663. */ tabProgram.append(entry.getKey()).append("=").append(quota)
  3664. .append(entry.getValue()).append(quota).append(" ");
  3665. }
  3666. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3667. tabProgram += " />";
  3668. */ tabProgram.append(" />");
  3669. }
  3670. // clearbutton=true;
  3671. if ("true".equals(inputproperties.get("clear")))
  3672. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3673. tabProgram += "<script>wd.edit.addClearTextButton(\""+ field.name +"\");</script>";
  3674. */ tabProgram.append("<script>wd.edit.addClearTextButton(\"").append(field.name).append("\");</script>");
  3675. /* 再去掉,移到 if-else 后 -- 按 IDEA 规范 -- Common part can be extracted from 'if'。Lin
  3676. content = content.replace(temp[0], tabProgram);
  3677. */
  3678. }
  3679. }
  3680. /// 再,把 if 和 else 的公共部分移到这(if-else 后) -- 按 IDEA 规范 -- Common part can be extracted from 'if'。Lin
  3681. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3682. content = content.replace(temp[0], tabProgram);
  3683. */ content = content.replace(temp[0], tabProgram.toString());
  3684. ///
  3685. }
  3686. // 处理 :onoffbutton
  3687. // <input name="sfjy" type="button" value="否" wdValue="0" />
  3688. // <input name="sfjy" type="button" value="是" wdValue="1" />
  3689. // <%--默认选项第一个--%>
  3690. // <wd:write type="radio" name="sfjy" value="${pxjl.sfjy}"
  3691. // onClass="content-onButton" offClass="content-offButton"
  3692. // nullable="false" />
  3693. for (Entry<String, List<String[]>> entry : allonoffbutton.entrySet()) {
  3694. String name = entry.getKey();
  3695. ObjFieldB field = vo.fieldMap.get(name);
  3696. if (field == null)
  3697. continue;
  3698. /* String 改为 int。Lin
  3699. if (!(field.type.equals(ObjC.FIELD_boolType))) // Field.TYPE_BOOLEAN。Lin
  3700. */ if (field.type != ObjC.FIELD_boolType)
  3701. continue;
  3702. /* 改,增加支持 <input name="sfpm"/> -- 只写一行。Lin
  3703. if (entry.getValue().size() != 2)
  3704. */ if (entry.getValue().size() != 1 && entry.getValue().size() != 2)
  3705. continue;
  3706. String value = "${"+ dxm +"."+ field.name +"}";
  3707. String c = "";
  3708. for (int i = 0; i < entry.getValue().size(); i++) {
  3709. String[] temp = entry.getValue().get(i);
  3710. ///// 增加,支持 <input name="sfpm"/> -- 像普通字段一样写。Lin
  3711. /// 再增加,支持 <input name="sfpm" ssRun= />。Lin
  3712. String ssRun = StrWeb.findAtrVal(temp[0], "ssRun", 1);
  3713. ///
  3714. if (!(temp[1].contains("_"))) {
  3715. // <auth@ss field=。Lin
  3716. if (isBaseInfo)
  3717. c +="<ss:auth field=\""+name+"\">\r\n"; // 不用编译 <auth@ss -- 直接写编译后的。Lin
  3718. /* 改为新UI。Lin
  3719. // "是" 按钮。Lin
  3720. String vvvv = field.optMap.get(1);
  3721. c += "<input name=\""+ fieldNamePrefix + name +
  3722. "\" type=\"button\" value=\""+ vvvv +
  3723. /// * 再改,规范 wdValue= 命名。Lin
  3724. // "\" wdValue=\""+ 1 +"\" />\r\n";
  3725. /// *
  3726. "\" ssVal=\""+ AppC.IF_true +"\"/>\r\n";
  3727. // "否" 按钮。Lin
  3728. vvvv = field.optMap.get(0);
  3729. c += "<input name=\""+ fieldNamePrefix + name +
  3730. "\" type=\"button\" value=\""+ vvvv +
  3731. /// * 再改,规范 wdValue= 命名。Lin
  3732. // "\" wdValue=\""+ 0 +"\" />\r\n";
  3733. /// *
  3734. "\" ssVal=\""+ AppC.IF_false +"\"/>\r\n";
  3735. String tabStr = "<onoff.ss rad=\"true\" name=\"" + fieldNamePrefix + name + // 再改,<onoff.ss radio= 改为 rad=。Lin
  3736. "\" val=\"" + value + "\" null=\""+ field.nullable +"\""+
  3737. /// 再增加,支持 <input name="sfpm" ssRun= />。Lin
  3738. ((StringUtils.isNotBlank(ssRun))? (" run=\""+ ssRun +"\"") : "") +
  3739. ///
  3740. " mode=\"" + (isInfo ? "play" : "edit") + "\"/>";
  3741. tabStr = TagComper.compTag(tabStr);
  3742. // 用 TagComper.transform(),onoffbuttonTransform 没盖写过。Lin
  3743. c += tabStr;
  3744. */
  3745. Map<String, String> inputproperties = new HashMap<>();
  3746. inputproperties.put("value",value);
  3747. //20251024新加 getInputCode方法的param参数
  3748. Map<String,Object> param = new HashMap<>();
  3749. param.put("isInfo",isInfo);
  3750. /* 改,查看页和录入页分开处理 Ben(20260413)。Lin
  3751. String code = PageCompU.getInputCode(PageCompC.FORM_PLUGIN_JS_TYPE_onoffbtn, //组件类弄
  3752. inputproperties,//组件属性
  3753. vo,
  3754. fieldNamePrefix + name, //input的name属性
  3755. param
  3756. );
  3757. */
  3758. String code = null;
  3759. //查看页和录入页分开处理 Ben(20260413)
  3760. if(isInfo){
  3761. code = "<script>\n" +
  3762. "{\n" +
  3763. " let v = '" +
  3764. value +
  3765. "'; \n" +
  3766. " if (v === '1') {\n" +
  3767. " document.write('是');\n" +
  3768. " } else if (v === '0') {\n" +
  3769. " document.write('否');\n" +
  3770. " } else {\n" +
  3771. " document.write('-');\n" +
  3772. " }\n" +
  3773. "}\n" +
  3774. "</script>";
  3775. }else{
  3776. code = PageCompU.getInputCode(PageCompC.FORM_PLUGIN_JS_TYPE_onoffbtn, //组件类弄
  3777. inputproperties,//组件属性
  3778. vo,
  3779. fieldNamePrefix + name, //input的name属性
  3780. param
  3781. );
  3782. }
  3783. c += code;
  3784. // </auth@ss>。Lin
  3785. if (isBaseInfo)
  3786. c+="\r\n</ss:auth>"; // 不用编译 <auth@ss -- 直接写编译后的。Lin
  3787. // 替换 <input name="sfpm"/>。Lin
  3788. content = content.replace(temp[0], c);
  3789. continue; // 没有后续处理了。Lin
  3790. }
  3791. /////
  3792. // String wdValue = temp[1].split("\\_")[1];
  3793. /* 再改,IDEA:Redundant character escape '\\_' in RegExp。Lin
  3794. String[] vv = temp[1].split("\\_");
  3795. */ String[] vv = temp[1].split("_");
  3796. String wdValue = vv[vv.length -1];
  3797. if ("yes".equalsIgnoreCase(wdValue))
  3798. wdValue = "1";
  3799. if ("no".equalsIgnoreCase(wdValue))
  3800. wdValue = "0";
  3801. String vvvv = field.optMap.get(Integer.valueOf(wdValue));
  3802. c += "<input name=\""+ fieldNamePrefix + name +
  3803. "\" type=\"button\" value=\""+ vvvv +
  3804. "\" ssVal=\""+ wdValue +"\" />\r\n"; // "\" wdValue=\""+。Lin
  3805. if (entry.getValue().size() - 1 > i) {
  3806. String newContent="";
  3807. if (isBaseInfo && i == 0){
  3808. /* 改。Lin
  3809. newContent="<wd:permission name=\""+name+"\">\r\n";
  3810. */ newContent="<auth.ss field=\""+name+"\">\r\n";
  3811. }
  3812. content = content.replace(temp[0], newContent);
  3813. } else {
  3814. /* null="true" 改为 field.nullable。Lin
  3815. * 尾端不能是 "/>\r\n",只能是 "/>" -- TagComper.transform() 会判别尾端是 ">" 还是 "/>"
  3816. * 再改,<onoff.ss radio= 改为 rad=
  3817. String tabStr = "<wd:write type=\"radio\" name=\"" +fieldNamePrefix+ name
  3818. + "\" value=\"" + value + "\" nullable=\"true\""
  3819. +" mode=\"" + (isInfo ? "play" : "edit") + "\"/>\r\n";
  3820. */ String tabStr = "<onoff.ss rad=\"true\" name=\"" +fieldNamePrefix+ name
  3821. + "\" val=\"" + value + "\" null=\""+ field.nullable +"\""
  3822. +" mode=\"" + (isInfo ? "play" : "edit") + "\"/>";
  3823. tabStr = TagComper.compTag(tabStr);
  3824. // 用 TagComper.transform(),onoffbuttonTransform 没盖写过。Lin
  3825. c += tabStr;
  3826. if(isBaseInfo){
  3827. if(entry.getValue().size() - 1==i){
  3828. /* 改。Lin
  3829. c+="\r\n</wd:permission>";
  3830. */ c+="\r\n</auth.ss>";
  3831. }
  3832. }
  3833. content = content.replace(temp[0], c);
  3834. }
  3835. }
  3836. }
  3837. // Map<String, String[]> name_inputs = new HashMap();
  3838. //
  3839. // for (String[] temp : allcascadingSelect_input) {
  3840. // String name = temp[1];
  3841. // name_inputs.put(name, temp);
  3842. //
  3843. // }
  3844. //
  3845. // for (String[] temp : allcascadingTagExist) {
  3846. // // String name = temp[1];
  3847. // CascadingSelectObject m = WD.getApp(appName).getCascadingSelectObject().get(temp[1]);
  3848. // if (m == null)
  3849. // continue;
  3850. // String growHeigthScript = "";
  3851. //
  3852. // for (int i = 0; i < m.getInputs().getInputList().size(); i++) {
  3853. // String inputName = m.getInputs().getInputList().get(i).getName();
  3854. // String[] temp1 = name_inputs.get(inputName);
  3855. // if (temp1 == null)
  3856. // continue;
  3857. // Map<String, String> inputproperties = inputElementProperties_input(temp1[0]);
  3858. //
  3859. // String heightStr = getAttributeStr(inputproperties, "height");
  3860. // String widthStr = getAttributeStr(inputproperties, "width");
  3861. // String maxHeightStr = getAttributeStr(inputproperties, "maxHeight");
  3862. // String buttonStr = getAttributeStr(inputproperties, "button");
  3863. //
  3864. // String playDiv = "<div id=\"" + inputName + "Play\" name=\"" + inputName + "Play\" " + widthStr + " " + heightStr + "></div>";
  3865. // content = content.replace(temp1[0], temp1[0] + "\r\n" + playDiv);
  3866. //
  3867. //// growHeigthScript += growHeightTransformer.transform("<wd:write type=\"growHeight\" name=\"" + inputName + "Play\" mode=\"play\" " + buttonStr + " "
  3868. //// + maxHeightStr + "/>");
  3869. //
  3870. // }
  3871. //
  3872. // }
  3873. /// 改为新UI,增加。Lin
  3874. Map<String,List<CcpB>> inp2CcpMap = new HashMap<>();//新UI专用:key是input的name,value是input对应的级联配置
  3875. //初始化inp2CcpMap
  3876. //下面的inpName本身就是带前缀的
  3877. for (String inpName : allcascadingInputNamesObject.keySet()) {
  3878. CcpB ccpB = allcascadingInputNamesObject.get(inpName);
  3879. String prfx = cascadingPrfx.get(inpName);
  3880. if(ccpB.combField!=null&&StringUtils.isNotBlank(ccpB.combField.rule)){
  3881. //如果是有编码规则的隐藏字段
  3882. if((prfx + ccpB.combField.name).equals(inpName)){
  3883. List<CcpB> list = inp2CcpMap.get(inpName);
  3884. if(list==null){
  3885. list = new ArrayList<>();
  3886. inp2CcpMap.put(inpName,list);
  3887. }
  3888. list.add(ccpB);
  3889. continue;
  3890. }
  3891. }
  3892. /* 再去掉,共用 CcpB.combField.fieldList(List<CcpFieldB>) 里的 CcpFieldB.name。Lin
  3893. for (Integer index : ccpB.fieldNameMap.keySet()) {
  3894. String fieldNameWithoutPrfx = ccpB.fieldNameMap.get(index);
  3895. */
  3896. for (CcpFieldB field : ccpB.combField.fieldList) {
  3897. String fieldNameWithoutPrfx = field.name;
  3898. String fullFieldName = prfx+fieldNameWithoutPrfx;
  3899. if(fullFieldName.equals(inpName)){
  3900. /* 再去掉,共用 CcpB.combField.fieldList(List<CcpFieldB>) 里的 CcpFieldB.name。Lin
  3901. for (Integer j : ccpB.fieldNameMap.keySet()) {
  3902. String fieldNameWithoutPrfx2 = ccpB.fieldNameMap.get(j);
  3903. */
  3904. for (CcpFieldB f : ccpB.combField.fieldList) {
  3905. String fieldNameWithoutPrfx2 = f.name;
  3906. String fullFieldName2 = prfx+fieldNameWithoutPrfx2;
  3907. List<CcpB> list = inp2CcpMap.get(fullFieldName2);
  3908. if(list==null||list.size()==0){
  3909. list = new ArrayList<>();
  3910. inp2CcpMap.put(fullFieldName2,list);
  3911. }
  3912. boolean allReadyHave = false;
  3913. for (CcpB b : list) {
  3914. if(b.name.equals(ccpB.name)){
  3915. allReadyHave = true;
  3916. break;
  3917. }
  3918. }
  3919. if(!allReadyHave)
  3920. list.add(ccpB);
  3921. }
  3922. continue;
  3923. }
  3924. }
  3925. }
  3926. ///
  3927. // System.out.println(cascadingTagNewAttribute.keySet());
  3928. //
  3929. // System.out.println(notHandleCascadingInputNames);
  3930. /// 改为新UI,增加。Lin
  3931. //所有级联菜单的代码,在下面这循环生成
  3932. ///
  3933. for (String[] temp : allcascadingSelect_input) {
  3934. Map<String, String> inputproperties = inputElementProperties_input(temp[0]);
  3935. boolean wdReadonly = "true".equals(inputproperties.get("wdReadonly"));
  3936. String inputName = temp[1]; // name(String) 改为 inputName -- 与 lastInputName 对应。Lin
  3937. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  3938. String thisContent=temp[0];
  3939. */ StringBuilder thisContent= new StringBuilder(temp[0]); // <input name="bzrid" width="170px"/>。Lin
  3940. CcpB ccp = allcascadingInputNamesObject.get(inputName); // m(CcpB) 改为 ccp。Lin
  3941. /// 增加,获取 prfx -- 支持共用 ccp 定义。Lin
  3942. String prfx = cascadingPrfx.get(inputName);
  3943. ///
  3944. boolean haveRules = StringUtils.isNotBlank(ccp.combField.rule); //带掩码
  3945. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  3946. /* 增加支持共用 ccp 定义。Lin
  3947. boolean isinputs = (m.combField.name != null && m.combField.name.equals(name));
  3948. */ boolean isinputs = (ccp.combField.name != null && (prfx + ccp.combField.name).equals(inputName));
  3949. // if(isinputs)continue;
  3950. // SsLog.print("name:"+ name +"---"+ m.name); // 去掉,干扰。Lin
  3951. if(notHandleCascadingInputNames.contains(inputName))
  3952. continue;
  3953. /* 增加支持共用 ccp 定义。Lin
  3954. if(cascadingTagNewAttribute.get(m.name)==null)
  3955. */ if(cascadingTagNewAttribute.get(prfx + ccp.name) == null)
  3956. continue;
  3957. /* 改用 .lastFieldName。Lin
  3958. * List<Input> 改为 Map<String, CascaderFieldB>
  3959. int si = m.getInputs().getInputList().size() - 1;
  3960. String lastInputName = m.getInputs().getInputList().get(si).getName();
  3961. */
  3962. /* 再增加,支持共用 ccp 定义。Lin
  3963. String lastInputName = m.combField.lastFieldName;
  3964. */ String lastInputName = prfx + ccp.combField.lastFieldName;
  3965. /// 改为新UI,增加。Lin
  3966. //新UI:生成初始化级联菜单的script
  3967. //旧UI:生成级联自定义标签
  3968. if(ccpIsNewUI){
  3969. StringBuilder scriptSb = new StringBuilder();
  3970. if(pageobj.isInp){//是发布录入页
  3971. String script = null;
  3972. if (lastInputName.equals(inputName)) { // 在最后的 <input 后面加 <ss:ccp mode="edit" name="dw_bzr" val="${bj.dwid},${bj.bzrid}"/>。Lin
  3973. String componentType = null;
  3974. if (haveRules) {//有编码规则的级联菜单
  3975. componentType = PageCompC.FORM_PLUGIN_JS_TYPE_ccpsingle;
  3976. }else {
  3977. componentType = PageCompC.FORM_PLUGIN_JS_TYPE_ccpmutiple;
  3978. }
  3979. //返回初始化级联菜单录入组件的JS
  3980. script = PageCompU.getInitInputCcpComponentJs(componentType, //组件类弄
  3981. ccp,//级联菜单配置
  3982. prfx, //级联配置中的前缀
  3983. dxm, //对象名
  3984. null
  3985. );
  3986. thisContent.append(script);
  3987. }
  3988. } else if (pageobj.isInfo) {//是发布baseInfo页
  3989. ///
  3990. /* 改为新UI。Lin
  3991. * 去掉,抽取到 doCcpByInfo(,在下面共用。Lin
  3992. * m(CcpB) 改为 ccp,name(String) 改为 inputName
  3993. if (lastInputName.equals(inputName)) { // 在最后的 <input 后面加 <ss:ccp mode="edit" name="dw_bzr" val="${bj.dwid},${bj.bzrid}"/>。Lin
  3994. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  3995. // String v="";
  3996. /// *
  3997. StringBuilder v = new StringBuilder();
  3998. if (haveRules) {
  3999. /// * 改。Lin
  4000. // * 支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'
  4001. // * IDEA 规范 -- String concatenation '+=' in loop
  4002. // if(namesValue.get(m.combField.name) != null){
  4003. // v=namesValue.get(m.combField.name);
  4004. // }else if(vo.fieldMap.get(m.combField.name) != null){
  4005. // v = "${"+ dxm +"."+ m.combField.name +"},";
  4006. // }
  4007. /// *
  4008. if (namesValue.get(prfx + ccp.combField.name) != null) {
  4009. v = new StringBuilder(namesValue.get(prfx + ccp.combField.name));
  4010. } else if (vo.fieldMap.get(prfx + ccp.combField.name) != null) {
  4011. v = new StringBuilder("${"+ dxm +"."+ prfx + ccp.combField.name +"},");
  4012. }
  4013. } else {
  4014. /// * List<Input> 改为 Map<String, CascaderFieldB>。Lin
  4015. // for(int i=0;i<m.getInputs().getInputList().size();i++){
  4016. // String n=m.getInputs().getInputList().get(i).getName();
  4017. /// *
  4018. /// * 改,支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'。Lin
  4019. // for (CcpFieldB input : ccp.combField.fieldList) {
  4020. // String n = input.name;
  4021. /// *
  4022. for (CcpFieldB input : ccp.combField.fieldList) {
  4023. String n = prfx + input.name;
  4024. if (namesValue.get(n) != null) {
  4025. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  4026. // v+=namesValue.get(n)+",";
  4027. /// *
  4028. v.append(namesValue.get(n)).append(",");
  4029. } else if (vo.fieldMap.get(n) != null) {
  4030. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  4031. // v+="${"+dxm+"."+n+"},";
  4032. /// *
  4033. v.append("${").append(dxm).append(".").append(n).append("},");
  4034. } else {
  4035. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  4036. // v+=",";
  4037. /// *
  4038. v.append(",");
  4039. }
  4040. }
  4041. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  4042. // v=v.substring(0, v.length() -1);
  4043. /// *
  4044. v = new StringBuilder(v.substring(0, v.length() -1));
  4045. }
  4046. /// * 改,支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'。Lin
  4047. // cascadingTagNewAttribute.get(m.name).put("value",v);
  4048. /// *
  4049. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  4050. // cascadingTagNewAttribute.get(prfx + m.name).put("value",v);
  4051. /// *
  4052. cascadingTagNewAttribute.get(prfx + ccp.name).put("value", v.toString());
  4053. /// * 改。Lin
  4054. // thisContent+="\r\n<wd:cascadingSelect ";
  4055. /// *
  4056. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  4057. // *??? 另,考虑把 <ss:ccp 的处理程序 CcpTag 上移到这 -- 搞明白 miniInfo、Tips 内容 再定???
  4058. // * 把下面 .append( 的 <ss:ccp mode="edit" prfx="sz" name="dq" val="${dw.szdqm}"/> 直接改为 wd.edit.objectPicker.createObjectPicker(
  4059. // thisContent+="\r\n<ss:ccp"; // 不能用 <ccp@ss,没有编译。Lin
  4060. /// *
  4061. thisContent.append("\r\n<ss:ccp"); // 不能用 <ccp@ss,没有编译。Lin
  4062. /// * 改,支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'。Lin
  4063. // for(String key : cascadingTagNewAttribute.get(m.name).keySet()){
  4064. /// *
  4065. for (String key : cascadingTagNewAttribute.get(prfx + ccp.name).keySet()) {
  4066. /// * 改,支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'。Lin
  4067. // if(cascadingTagNewAttribute.get(m.name).get(key)==null)
  4068. /// *
  4069. if (cascadingTagNewAttribute.get(prfx + ccp.name).get(key) == null)
  4070. continue;
  4071. /// * 改,使用新标准的 val=。Lin
  4072. // thisContent += " "+ getAttributeStr(cascadingTagNewAttribute.get(m.name), key);
  4073. /// *
  4074. /// * 再改。Lin
  4075. // * 支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'
  4076. // * IDEA 规范 -- String concatenation '+=' in loop
  4077. // String str = getAttributeStr(cascadingTagNewAttribute.get(m.name), key);
  4078. // if ("value".equals(key))
  4079. // str = str.replace("value=", "val=");
  4080. // thisContent += " "+ str;
  4081. /// *
  4082. String str = getAttributeStr(cascadingTagNewAttribute.get(prfx + ccp.name), key);
  4083. if ("value".equals(key))
  4084. str = str.replace("value=", "val=");
  4085. thisContent.append(" ").append(str);
  4086. }
  4087. /// * 再改,IDEA:String concatenation '+=' in loop。Lin
  4088. // thisContent+="/>";
  4089. /// *
  4090. thisContent.append("/>");
  4091. }
  4092. */ doCcpByInfo(inputName, lastInputName, ccp, haveRules, prfx,
  4093. namesValue, cascadingTagNewAttribute, vo, dxm, thisContent);
  4094. /// 改为新UI,增加。Lin
  4095. }
  4096. } else {
  4097. /* 改为新UI。Lin
  4098. * 去掉,共用上面抽取出来的 doCcpByInfo(。Lin
  4099. * m(CcpB) 改为 ccp,name(String) 改为 inputName
  4100. if (lastInputName.equals(inputName)) { // 在最后的 <input 后面加 <ss:ccp mode="edit" name="dw_bzr" val="${bj.dwid},${bj.bzrid}"/>。Lin
  4101. StringBuilder v = new StringBuilder();
  4102. if (haveRules) {//有编码规则的级联菜单
  4103. if (namesValue.get(prfx + ccp.combField.name) != null) {
  4104. v = new StringBuilder(namesValue.get(prfx + ccp.combField.name));
  4105. } else if (vo.fieldMap.get(prfx + ccp.combField.name) != null) {
  4106. v = new StringBuilder("${"+ dxm +"."+ prfx + ccp.combField.name +"},");
  4107. }
  4108. } else {//没编码规则的级联菜单
  4109. for (CcpFieldB input : ccp.combField.fieldList) {
  4110. String n = prfx + input.name;
  4111. if (namesValue.get(n) != null) {
  4112. v.append(namesValue.get(n)).append(",");
  4113. } else if (vo.fieldMap.get(n) != null) {
  4114. v.append("${").append(dxm).append(".").append(n).append("},");
  4115. } else {
  4116. v.append(",");
  4117. }
  4118. }
  4119. v = new StringBuilder(v.substring(0, v.length() -1));
  4120. }
  4121. cascadingTagNewAttribute.get(prfx + ccp.name).put("value", v.toString());
  4122. thisContent.append("\r\n<ss:ccp"); // 不能用 <ccp@ss,没有编译。Lin
  4123. for (String key : cascadingTagNewAttribute.get(prfx + ccp.name).keySet()) {
  4124. if (cascadingTagNewAttribute.get(prfx + ccp.name).get(key) == null)
  4125. continue;
  4126. String str = getAttributeStr(cascadingTagNewAttribute.get(prfx + ccp.name), key);
  4127. if ("value".equals(key))
  4128. str = str.replace("value=", "val=");
  4129. thisContent.append(" ").append(str);
  4130. }
  4131. thisContent.append("/>");
  4132. }
  4133. */ doCcpByInfo(inputName, lastInputName, ccp, haveRules, prfx,
  4134. namesValue, cascadingTagNewAttribute, vo, dxm, thisContent);
  4135. }
  4136. ///
  4137. ObjFieldB field = vo.fieldMap.get(inputName);
  4138. /// 改为新UI,增加。Lin
  4139. // m(CcpB) 改为 ccp,name(String) 改为 inputName
  4140. if (ccpIsNewUI) {
  4141. if (isInfo || wdReadonly) {//替换baseInfo页的级联菜单代码
  4142. if (!haveRules) {
  4143. String v=Optional.ofNullable(inputproperties.get("value")).orElse("${"+ dxm +"."+ inputName +"}");
  4144. String writeStr="";
  4145. String codebook111=Optional.ofNullable(
  4146. inputproperties.get("wdCodebook")).orElse((field != null)? field.cbName : null);
  4147. if (StringUtils.isNotBlank(codebook111)) {
  4148. writeStr += "<ss:cbTrans cb=\"" +codebook111
  4149. + "\" val=\""+ v +"\" "
  4150. + " filter=\""+ (inputproperties.get("ssFilter") != null? inputproperties.get("ssFilter") : "") + "\"/>";
  4151. } else {
  4152. writeStr="-object未定义codebook-";
  4153. SsLog.log("XXXXXXXX -object未定义codebook-");
  4154. }
  4155. writeStr = "<div id=\""+ inputproperties.get("name") + "\" "
  4156. +" "+ getAttributeStr(inputproperties, "style")
  4157. + getAttributeStr(inputproperties, "width")
  4158. + " " + getAttributeStr(inputproperties, "height") +">"
  4159. + writeStr +"</div>";
  4160. writeStr += TagComper.compTag(
  4161. "<growh.ss name=\""+ inputName
  4162. + "\" mode=\"play\" "+" "+ getAttributeStr(inputproperties, "maxHeight") +" />");
  4163. if (isBaseInfo && (field != null)) {
  4164. writeStr="<ss:auth field=\""+ field.name +"\">\r\n"
  4165. + writeStr +"\r\n</ss:auth>";
  4166. }
  4167. thisContent = new StringBuilder(thisContent.toString().replace(temp[0], writeStr));
  4168. }
  4169. } else if(pageobj.isInp) {//新UI 替换录入页的级联菜单代码
  4170. List<CcpB> ccpList = inp2CcpMap.get(inputName);
  4171. if (ccpList != null) {
  4172. String html = null;
  4173. //如果是带编码规则的级联菜单
  4174. if (haveRules) {
  4175. boolean isCombField = (prfx + ccp.combField.name).equals(inputName);
  4176. //返回初始化录入级联组件的JS
  4177. html = PageCompU.getCcpInputCode(PageCompC.FORM_PLUGIN_JS_TYPE_ccpsingle, //组件类弄
  4178. inputproperties,//组件属性
  4179. vo,
  4180. inputName, //input的name属性
  4181. isCombField, //是隐藏字段
  4182. ccpList, //级联菜单配置
  4183. prfx, //级联菜单前缀
  4184. cascadingTagNewAttribute //级联菜单filter放在这
  4185. );
  4186. } else {
  4187. //返回初始化录入级联组件的JS
  4188. html = PageCompU.getCcpInputCode(PageCompC.FORM_PLUGIN_JS_TYPE_ccpmutiple, //组件类弄
  4189. inputproperties,//组件属性
  4190. vo,
  4191. inputName, //input的name属性
  4192. false, //是隐藏字段
  4193. ccpList, //级联菜单配置
  4194. prfx, //级联菜单前缀
  4195. cascadingTagNewAttribute //级联菜单filter放在这
  4196. );
  4197. }
  4198. thisContent = new StringBuilder(thisContent.toString().replace(temp[0], html));
  4199. }
  4200. }
  4201. if (isBaseInfo && haveRules) {
  4202. if (lastInputName.equals(inputName)) {
  4203. thisContent.append("\r\n</ss:auth>\r\n"); // 不用编译 <auth@ss -- 直接写编译后的。Lin
  4204. }
  4205. }
  4206. if (isinputs) {
  4207. if (isBaseInfo && haveRules) {
  4208. content = content.replace(temp[0],
  4209. "<ss:auth field=\""+inputName+"\">\r\n"+ temp[0]); // 不用编译 <auth@ss -- 直接写编译后的。Lin
  4210. } else {
  4211. content = content.replace(temp[0], thisContent.toString());
  4212. }
  4213. } else {
  4214. content = content.replace(temp[0], thisContent.toString());
  4215. }
  4216. } else {//老UI
  4217. ///
  4218. if (isInfo || wdReadonly) {
  4219. /* 再改,IDEA:'if' statement has empty body。Lin
  4220. if(haveRules){
  4221. // thisContent =thisContent.replace(temp[0],"\r\n<div id=\"" + name + "Play\" name=\"" + name + "Play\" " +getAttributeStr(inputproperties, "width") + " " + getAttributeStr(inputproperties, "height") + "></div>");
  4222. }else{
  4223. */ if (!haveRules) {
  4224. String v=Optional.ofNullable(inputproperties.get("value")).orElse("${"+ dxm +"."+ inputName +"}");
  4225. String writeStr="";
  4226. String codebook111=Optional.ofNullable(
  4227. inputproperties.get("wdCodebook")).orElse((field != null)? field.cbName : null);
  4228. if (StringUtils.isNotBlank(codebook111)) {
  4229. // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  4230. /* 改。Lin
  4231. * 不用编译 <cbTrans@ss -- 直接写编译后的。Lin
  4232. writeStr += "<wd:translate name=\"" +codebook111
  4233. + "\" value=\""+ v +"\" "
  4234. + " filter=\""+ (inputproperties.get("wdFilter") != null? inputproperties.get("wdFilter") : "") + "\"/>";
  4235. */ writeStr += "<ss:cbTrans cb=\"" +codebook111
  4236. + "\" val=\""+ v +"\" "
  4237. + " filter=\""+ (inputproperties.get("ssFilter") != null? inputproperties.get("ssFilter") : "") + "\"/>";
  4238. } else {
  4239. writeStr="-object未定义codebook-";
  4240. SsLog.log("XXXXXXXX -object未定义codebook-");
  4241. }
  4242. writeStr = "<div id=\""+ inputproperties.get("name") + "\" "
  4243. +" "+ getAttributeStr(inputproperties, "style")
  4244. + getAttributeStr(inputproperties, "width")
  4245. + " " + getAttributeStr(inputproperties, "height") +">"
  4246. + writeStr +"</div>";
  4247. writeStr += TagComper.compTag(
  4248. // 用 TagComper.transform(),growHeightTransformer 没盖写过。Lin
  4249. /* 改。Lin
  4250. "<wd:write type=\"growHeight\" name=\""+ name
  4251. + "\" mode=\"play\" "+" "+ getAttributeStr(inputproperties, "maxHeight") +" />");
  4252. */ "<growh.ss name=\""+ inputName
  4253. + "\" mode=\"play\" "+" "+ getAttributeStr(inputproperties, "maxHeight") +" />");
  4254. if (isBaseInfo && (field != null)) {
  4255. /* 改。Lin
  4256. * 不用编译 <auth@ss -- 直接写编译后的。Lin
  4257. writeStr="<wd:permission name=\""+ field.name +"\">\r\n"
  4258. + writeStr +"\r\n</wd:permission>";
  4259. */ writeStr="<ss:auth field=\""+ field.name +"\">\r\n"
  4260. + writeStr +"\r\n</ss:auth>";
  4261. }
  4262. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4263. thisContent =thisContent.replace(temp[0],writeStr);
  4264. */ thisContent = new StringBuilder(thisContent.toString().replace(temp[0], writeStr));
  4265. }
  4266. } else {
  4267. String v = "";
  4268. if (namesValue.get(inputName) != null) {
  4269. v += namesValue.get(inputName);
  4270. } else if (vo.fieldMap.get(inputName) != null) {
  4271. v += "${"+ dxm +"."+ inputName +"}";
  4272. }
  4273. inputproperties.put("value", v);
  4274. /* 0,增加 />。Lin
  4275. String hiddenElement = "<input name=\"" + name + "\" type=\"hidden\" "
  4276. + getAttributeStr(inputproperties, "value") + " ";
  4277. */
  4278. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4279. String hiddenElement = "<input name=\""+ name +"\" type=\"hidden\" "
  4280. + getAttributeStr(inputproperties, "value") +" />";
  4281. */ StringBuilder hiddenElement = new StringBuilder("<input name=\""+ inputName +"\" type=\"hidden\" "
  4282. + getAttributeStr(inputproperties, "value") +" />");
  4283. inputproperties.remove("value");
  4284. inputproperties.remove("ssCcp"); // ("wdCascadingSelect")。Lin
  4285. inputproperties.remove("type");
  4286. inputproperties.put("name", inputName +"Name"); // 1。Lin
  4287. inputproperties.put("type", "text"); // 2。Lin
  4288. if (inputproperties.get("width") != null) {
  4289. String style_ = inputproperties.get("style");
  4290. style_ = style_ == null ? "" : style_;
  4291. style_ += "width:" + inputproperties.get("width") + ";";
  4292. inputproperties.put("style", style_);
  4293. }
  4294. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4295. hiddenElement += "\r\n<input "; // 3。Lin
  4296. */ hiddenElement.append("\r\n<input "); // 3。Lin
  4297. inputproperties.remove("width"); // 4。Lin
  4298. for (Entry<String, String> entry : inputproperties.entrySet()) {
  4299. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4300. hiddenElement += entry.getKey() + "=\"" + entry.getValue() + "\" ";
  4301. */ hiddenElement.append(entry.getKey()).append("=\"").append(entry.getValue()).append("\" ");
  4302. }
  4303. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4304. hiddenElement += " />"; // 5,去掉 \r\n。Lin
  4305. */ hiddenElement.append(" />"); // 5,去掉 \r\n。Lin
  4306. //
  4307. // 奇怪,前面 1、2、3、4 行被注释掉。Lin
  4308. // 翻译出来的是:<input name="hksheng" type="hidden" name="hksheng" width="85px" style="width:85px;" />
  4309. // 这明显是错的
  4310. //
  4311. // 去掉 1、2、3、4 行的注释后,翻译出来的是:
  4312. // <input name="hksheng" type="hidden" />
  4313. // <input name="hkshengName" style="width:85px;" type="text" />
  4314. // 这应该才是对的。(原翻译后的,也是这样的
  4315. //
  4316. // 另,0 行也加了闭标签 />,5 行去掉了 \r\n
  4317. //
  4318. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4319. thisContent =thisContent.replace(temp[0],hiddenElement);
  4320. */
  4321. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4322. thisContent = new StringBuilder(thisContent.toString().replace(temp[0], hiddenElement));
  4323. */ thisContent = new StringBuilder(thisContent.toString().replace(temp[0], hiddenElement.toString()));
  4324. }
  4325. if (isBaseInfo && haveRules) {
  4326. // if(firstInputName.equals(name)){
  4327. // thisContent="<wd:permission name=\""+name+"\">\r\n"+thisContent;
  4328. // }else
  4329. if (lastInputName.equals(inputName)) {
  4330. /* 改。Lin
  4331. thisContent+="\r\n</wd:permission>\r\n";
  4332. */
  4333. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4334. thisContent+="\r\n</ss:auth>\r\n"; // 不用编译 <auth@ss -- 直接写编译后的。Lin
  4335. */ thisContent.append("\r\n</ss:auth>\r\n"); // 不用编译 <auth@ss -- 直接写编译后的。Lin
  4336. }
  4337. }
  4338. if (isinputs) {
  4339. /* 再改,IDEA:Condition 'isinputs' is always 'true'。Lin
  4340. if(isBaseInfo&&isinputs&&haveRules){
  4341. */ if (isBaseInfo && haveRules) {
  4342. content = content.replace(temp[0],
  4343. "<ss:auth field=\""+inputName+"\">\r\n"+ temp[0]); // 不用编译 <auth@ss -- 直接写编译后的。Lin
  4344. }
  4345. } else {
  4346. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4347. content = content.replace(temp[0], thisContent);
  4348. */ content = content.replace(temp[0], thisContent.toString());
  4349. }
  4350. /// 改为新UI,增加。Lin
  4351. }
  4352. ///
  4353. // } // for (String[] temp : allcascadingSelect_input) {。再去掉(,把下面的 if (isInfo) { 也包到 for 里 -- 改为新UI时,大叶改为这样。Lin
  4354. // 级联查看
  4355. if (isInfo) {
  4356. //combine=true
  4357. // { // 再去掉,没意义。Lin
  4358. Pattern p2 = Pattern.compile(
  4359. /* 再改为 IDEA 规范。Lin
  4360. * Redundant character escape '\\<' in RegExp
  4361. * Empty branch in alternation -- ||
  4362. * '\'' is unnecessarily escaped
  4363. * Redundant character escape '\\>' in RegExp
  4364. * Redundant character escape '\\/' in RegExp
  4365. "\\<(td||TD)[^>]*?(wdCombine|wdcombine)=[\"\']true[\"\'][^>]*?\\>(.*?)\\<\\/(td||TD)>",
  4366. */ "<(td|TD)[^>]*?(ssComb)=[\"']true[\"'][^>]*?>(.*?)</(td|TD)>",
  4367. Pattern.DOTALL);
  4368. Matcher m2 = p2.matcher(content);
  4369. /* 去掉,没用到。Lin
  4370. boolean dd = false;
  4371. */
  4372. int combineIndex=1;
  4373. while (m2.find()) {
  4374. String thismatch = m2.group();//(<td>...</td>)
  4375. String innerMatch = m2.group(3);//(<td>(...)</td>)
  4376. String combineId = "div"+ combineIndex+"combine";
  4377. innerMatch = "<div id=\""+combineId+ "\">"
  4378. + innerMatch
  4379. + "</div>";
  4380. /// 再增加,去掉 thismatch > content 里的 ssComb="true",避免被重复匹配到 -- 修正多个字段的 <td ssComb="true"。Lin
  4381. Pattern ssCombPattern = Pattern.compile("ssComb=[\"']true[\"']");
  4382. Matcher ssCombMatcher = ssCombPattern.matcher(thismatch);
  4383. thismatch = ssCombMatcher.replaceAll("");
  4384. ///
  4385. thismatch = thismatch.replaceFirst(Pattern.quote(m2.group(3)), Matcher.quoteReplacement(innerMatch)) +
  4386. //td之后追加
  4387. "<script>wd.display.combineDiv(\""+ combineId+ "\");</script>\r\n"+
  4388. TagComper.compTag(
  4389. // 用 TagComper.transform(),growHeightTransformer 没盖写过。Lin
  4390. /* 改。Lin
  4391. "<wd:write type=\"growHeight\" name=\"" +combineId
  4392. + "\" mode=\"play\" />");
  4393. */ "<growh.ss name=\"" +combineId
  4394. + "\" mode=\"play\" />");
  4395. content=content.replaceFirst(Pattern.quote(m2.group()), Matcher.quoteReplacement(thismatch));
  4396. combineIndex++;
  4397. }
  4398. // } // 再去掉,没意义。Lin
  4399. }
  4400. } // for (String[] temp : allcascadingSelect_input) {。增加,从上面上移到这,把 if (isInfo) { 也包到 for 里 -- 改为新UI时,大叶改为这样。Lin
  4401. /// 再增加,查看时,在 <td 里增加样式 padding:0 15px。Lin
  4402. // 在实现 growh 弹出框的左右边线与 <td 的边线重叠时,去掉 base.css 里的 .form-container td { 里的 padding: 0 15px,导致查看页的 <td 没有缩进 15px
  4403. // 抄自上面的 处理 <td ssComb="true" 的程序
  4404. if (isInfo) {
  4405. Pattern tdPattern = Pattern.compile("<(td|TD)(.*?)>", Pattern.DOTALL); // <td ...>。Lin
  4406. Matcher tdMatcher = tdPattern.matcher(content);
  4407. while (tdMatcher.find()) {
  4408. String tdMatch = tdMatcher.group(); // <td style="width:400px;">。Lin
  4409. String tdCont = tdMatcher.group(2); // style="width:400px;"。Lin
  4410. Pattern stylePattern = Pattern.compile("(style=[\"'].*?[\"'])", Pattern.DOTALL); // <td 里 style=。Lin
  4411. Matcher styleMatcher = stylePattern.matcher(tdCont);
  4412. if (styleMatcher.find()) { // 有 style=。Lin
  4413. String styleMatch = styleMatcher.group(); // style="width:400px;"。Lin
  4414. String styleStr = styleMatcher.group(1); // style="width:400px;"。Lin
  4415. styleStr = styleStr.substring(0, styleStr.length() -1).trim(); // 去掉最后的 "。Lin
  4416. if (!StringUtils.endsWith(styleStr, ";"))
  4417. styleStr += ";";
  4418. styleStr += "padding:0 15px;\"";
  4419. tdCont = tdMatch.replaceFirst(styleMatch, styleStr); // 替换 style=。Lin
  4420. } else { // 没有 style=。Lin
  4421. tdCont = tdMatch.substring(0, tdMatch.length() -1).trim() + // <td > 改为 <td。Lin
  4422. " style=\"padding:0 15px;\">"; // 增加 style=。Lin
  4423. }
  4424. // 更新到 content。Lin
  4425. content = content.replaceFirst(Pattern.quote(tdMatch), Matcher.quoteReplacement(tdCont));
  4426. }
  4427. }
  4428. ///
  4429. /// 再增加,<th 里不需要写 style="width:160px;" -- 没有写 style="width: 时,自动补上。Lin
  4430. // 抄自上面的 在 <td 里增加样式 padding:0 15px 的程序
  4431. Pattern tdPattern = Pattern.compile("<(th|TH)(.*?)>", Pattern.DOTALL); // <th ...>。Lin
  4432. Matcher tdMatcher = tdPattern.matcher(content);
  4433. while (tdMatcher.find()) {
  4434. String thMatch = tdMatcher.group(); // <th style="width:100px;">。Lin
  4435. String thCont = tdMatcher.group(2); // style="width:100px;"。Lin
  4436. Pattern stylePattern = Pattern.compile("(style=[\"'].*?[\"'])", Pattern.DOTALL); // <th 里 style=。Lin
  4437. Matcher styleMatcher = stylePattern.matcher(thCont);
  4438. if (styleMatcher.find()) { // 有 style=。Lin
  4439. if (!thCont.contains("width:")) { // 没有 width:。Lin
  4440. String styleMatch = styleMatcher.group(); // style="height:120px"。Lin
  4441. String styleStr = styleMatcher.group(1); // style="height:120px"。Lin
  4442. styleStr = styleStr.substring(0, styleStr.length() -1).trim(); // 去掉最后的 "。Lin
  4443. if (!StringUtils.endsWith(styleStr, ";"))
  4444. styleStr += ";";
  4445. styleStr += SkinC.STYLE_thWidthStr +"\"";
  4446. thCont = thMatch.replaceFirst(styleMatch, styleStr); // 替换 style=。Lin
  4447. content = content.replaceFirst(Pattern.quote(thMatch), Matcher.quoteReplacement(thCont)); // 更新到 content。Lin
  4448. }
  4449. } else { // 没有 style=。Lin
  4450. thCont = thMatch.substring(0, thMatch.length() -1).trim() + // <th > 改为 <th。Lin
  4451. " style=\""+ SkinC.STYLE_thWidthStr +"\">"; // 增加 style="width:160px;"。Lin
  4452. content = content.replaceFirst(Pattern.quote(thMatch), Matcher.quoteReplacement(thCont)); // 更新到 content。Lin
  4453. }
  4454. }
  4455. ///
  4456. return new StringReader(content);
  4457. } catch (Exception e) {
  4458. /* 改,去掉 e.printStackTrace(),改用 log4j -- 按 IDEA 规范。Lin
  4459. e.printStackTrace();
  4460. */ log4j.error("PageComper.addViewObjectTools() 异常", e);
  4461. }
  4462. return reader;
  4463. }
  4464. // 从 addViewObjectTools( 抽取出来,在 addViewObjectTools( 里共用。Lin
  4465. // m(CcpB) 改为 ccp,name(String) 改为 inputName
  4466. private static void doCcpByInfo(String inputName, String lastInputName, CcpB ccp, boolean haveRules, String prfx,
  4467. Map<String, String> namesValue, Map<String, Map<String, String>> cascadingTagNewAttribute,
  4468. ObjB vo, String dxm, StringBuilder thisContent) {
  4469. if (lastInputName.equals(inputName)) { // 在最后的 <input 后面加 <ss:ccp mode="edit" name="dw_bzr" val="${bj.dwid},${bj.bzrid}"/>。Lin
  4470. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4471. String v="";
  4472. */ StringBuilder v = new StringBuilder();
  4473. if (haveRules) {
  4474. /* 改。Lin
  4475. * 支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'
  4476. * IDEA -- String concatenation '+=' in loop
  4477. if(namesValue.get(m.combField.name) != null){
  4478. v=namesValue.get(m.combField.name);
  4479. }else if(vo.fieldMap.get(m.combField.name) != null){
  4480. v = "${"+ dxm +"."+ m.combField.name +"},";
  4481. }
  4482. */
  4483. if (namesValue.get(prfx + ccp.combField.name) != null) {
  4484. v = new StringBuilder(namesValue.get(prfx + ccp.combField.name));
  4485. } else if (vo.fieldMap.get(prfx + ccp.combField.name) != null) {
  4486. v = new StringBuilder("${"+ dxm +"."+ prfx + ccp.combField.name +"},");
  4487. }
  4488. } else {
  4489. /* List<Input> 改为 Map<String, CascaderFieldB>。Lin
  4490. for(int i=0;i<m.getInputs().getInputList().size();i++){
  4491. String n=m.getInputs().getInputList().get(i).getName();
  4492. */
  4493. for (CcpFieldB input : ccp.combField.fieldList) {
  4494. /* 改,支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'。Lin
  4495. String n = input.name;
  4496. */ String n = prfx + input.name;
  4497. if (namesValue.get(n) != null) {
  4498. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4499. v+=namesValue.get(n)+",";
  4500. */ v.append(namesValue.get(n)).append(",");
  4501. } else if (vo.fieldMap.get(n) != null) {
  4502. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4503. v+="${"+dxm+"."+n+"},";
  4504. */ v.append("${").append(dxm).append(".").append(n).append("},");
  4505. } else {
  4506. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4507. v+=",";
  4508. */ v.append(",");
  4509. }
  4510. }
  4511. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4512. v=v.substring(0, v.length() -1);
  4513. */ v = new StringBuilder(v.substring(0, v.length() -1));
  4514. }
  4515. /* 改,支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'。Lin
  4516. cascadingTagNewAttribute.get(m.name).put("value",v);
  4517. */
  4518. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4519. cascadingTagNewAttribute.get(prfx + m.name).put("value",v);
  4520. */ cascadingTagNewAttribute.get(prfx + ccp.name).put("value", v.toString());
  4521. /* 改。Lin
  4522. thisContent+="\r\n<wd:cascadingSelect ";
  4523. */
  4524. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4525. *??? 另,考虑把 <ss:ccp 的处理程序 CcpTag 上移到这 -- 搞明白 miniInfo、Tips 内容 再定???
  4526. * 把下面 .append( 的 <ss:ccp mode="edit" prfx="sz" name="dq" val="${dw.szdqm}"/> 直接改为 wd.edit.objectPicker.createObjectPicker(
  4527. thisContent+="\r\n<ss:ccp"; // 不能用 <ccp@ss,没有编译。Lin
  4528. */ thisContent.append("\r\n<ss:ccp"); // 不能用 <ccp@ss,没有编译。Lin
  4529. /* 改,支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'。Lin
  4530. for(String key : cascadingTagNewAttribute.get(m.name).keySet()){
  4531. */ for (String key : cascadingTagNewAttribute.get(prfx + ccp.name).keySet()) {
  4532. /* 改,支持共用 ccp 定义。Lin
  4533. if(cascadingTagNewAttribute.get(m.name).get(key)==null)
  4534. */ if (cascadingTagNewAttribute.get(prfx + ccp.name).get(key) == null)
  4535. continue;
  4536. /* 改,使用新标准的 val=。Lin
  4537. thisContent += " "+ getAttributeStr(cascadingTagNewAttribute.get(m.name), key);
  4538. */
  4539. /* 再改。Lin
  4540. * 支持共用 ccp 定义 -- 增加前缀 <input ssCcp='{name:"bm_ry",prfx:"fz"}'
  4541. * IDEA 规范 -- String concatenation '+=' in loop
  4542. String str = getAttributeStr(cascadingTagNewAttribute.get(m.name), key);
  4543. if ("value".equals(key))
  4544. str = str.replace("value=", "val=");
  4545. thisContent += " "+ str;
  4546. */
  4547. String str = getAttributeStr(cascadingTagNewAttribute.get(prfx + ccp.name), key);
  4548. if ("value".equals(key))
  4549. str = str.replace("value=", "val=");
  4550. thisContent.append(" ").append(str);
  4551. }
  4552. /* 再改,IDEA:String concatenation '+=' in loop。Lin
  4553. thisContent+="/>";
  4554. */ thisContent.append("/>");
  4555. }
  4556. }
  4557. private static String getAttributeStr(Map<String, String> map, String name) {
  4558. if (StringUtils.isBlank(map.get(name))) // 去掉 StrU.isNull(),直接用 StringUtils.isBlank()。Lin
  4559. return "";
  4560. if ("button".equals(name)){
  4561. if(map.get(name).contains("'"))
  4562. return name + "=\"" + map.get(name) + "\"";
  4563. return name + "='" + map.get(name) + "'";
  4564. }
  4565. if (map.get(name).contains("\"")) {
  4566. return name + "='" + map.get(name) + "'";
  4567. }else{
  4568. return name + "=\"" + map.get(name) + "\"";
  4569. }
  4570. }
  4571. /**
  4572. * 查找生成<wd:write/>标签的附加属性
  4573. *
  4574. * @param source;
  4575. * @return Map<String, String>
  4576. */
  4577. private static Map<String, String> inputElementProperties_WdWrite(String source) {
  4578. Map<String, String> r = new HashMap<>();
  4579. /// <input name="kssj" width="168px" format="yyyy-MM-dd HH:mm:ss" miniDate="false"/>。Lin
  4580. // format= 改为 ssFmt=、miniDate= 改为 ssMiniDate=
  4581. // 先不改,等 新UI 发布程序搞好了再改 -- 不打扰 大叶
  4582. ///
  4583. for (String a : new String[] { "value", "format", "miniDate", "length" }) {
  4584. String value = StrWeb.findAtrVal(source, a, 1);
  4585. if (StringUtils.isNotBlank(value)) { // 去掉 StrU.notNull(),直接用 StringUtils.isNotBlank()。Lin
  4586. r.put(a, value);
  4587. }
  4588. }
  4589. return r;
  4590. }
  4591. /* 再改。Lin
  4592. private static final String[] inputElementPropertiess = {
  4593. "class", "style", "id", "size", "type", "name", "onclick", "onchange",
  4594. "placeholder", "autocomplete", "width", "height", "button", "input",
  4595. "cascadingSelect", "wdCascadingSelect", "wdButton", "wdInput", "wdRadio",
  4596. "wdCheckbox", "wdCallback", "value", "wdFilter", "clear","wdReadonly" ,"wdTabNo","wdCodebook"};
  4597. */ private static final String[] inputElementPropertiess = {
  4598. "class", "style", "id", "size", "type", "name", "onclick", "onchange",
  4599. "placeholder", "autocomplete", "width", "height", "button", "ssInp",
  4600. "cascadingSelect", "ssCcp", "ssChg", "ssBtn", "wdInput", "ssRad",
  4601. "wdCheckbox", "ssRun", "value", "ssFilter","ssFilterField", "clear", "wdReadonly" ,
  4602. ObjC.FIELD_no, // "wdTabNo",。Lin
  4603. "wdCodebook"};
  4604. /**
  4605. * 查找生成<input />的附加属性
  4606. *
  4607. * @param source;
  4608. * @return Map<String, String>
  4609. */
  4610. private static Map<String, String> inputElementProperties_input(String source) {
  4611. // http://www.w3school.com.cn/tags/tag_input.asp
  4612. Map<String, String> r = new HashMap<>();
  4613. for (String a : inputElementPropertiess) {
  4614. /* 去掉 findAttributeValue(),用 findAtrVal(,,1) -- 原 _findString()。Lin
  4615. String value = findAttributeValue(source, a);
  4616. */
  4617. String value = StrWeb.findAtrVal(source, a, 1);
  4618. if (value != null) {
  4619. r.put(a, value);
  4620. }
  4621. }
  4622. return r;
  4623. // accept
  4624. // align
  4625. // alt
  4626. // autocomplete
  4627. // autofocus
  4628. // checked
  4629. // disabled
  4630. // form
  4631. // formaction
  4632. // formenctype
  4633. // formmethod
  4634. // formnovalidate
  4635. // formtarget
  4636. // height
  4637. // list
  4638. // max
  4639. // maxlength
  4640. // min
  4641. // multiple
  4642. // name
  4643. // pattern
  4644. // placeholder
  4645. // readonly
  4646. // required
  4647. // size
  4648. // src
  4649. // step
  4650. // type
  4651. // style
  4652. // class
  4653. }
  4654. // =============
  4655. // 把 PageConfig.systemComponent() 拆开,为 isWebsite() 和 isHomep()
  4656. // 增加。Lin
  4657. /* 再去掉,增加 PageB.isHomep 和 PageB.isSitep 了 -- 来自插件的 <pages homep="true"/sitep="true"。Lin
  4658. private static boolean isWebsite(Integer pageType, Long devType){
  4659. if (devType == null // 不指定访问设备,默认为 PC。Lin
  4660. || devType == UserC.DEV_pcType) {
  4661. /// * 再改,IDEA:'if' statement can be simplified。Lin
  4662. // if (pageType > 10700 && pageType < 11000)
  4663. // return true;
  4664. // else
  4665. // return false;
  4666. /// *
  4667. return pageType > 10700 && pageType < 11000;
  4668. }
  4669. return false;
  4670. }
  4671. */
  4672. // 增加。Lin
  4673. /* 再去掉,增加 PageB.isHomep 和 PageB.isSitep 了 -- 来自插件的 <pages homep="true"/sitep="true"。Lin
  4674. private static boolean isHomep(Integer pageType, Long devType){
  4675. if (devType == null // 不指定访问设备,默认为 PC。Lin
  4676. || devType == UserC.DEV_pcType) {
  4677. /// * 再改,IDEA:'if' statement can be simplified。Lin
  4678. // if (pageType > 10500 && pageType < 10700)
  4679. // return true;
  4680. // else
  4681. // return false;
  4682. /// *
  4683. return pageType > 10500 && pageType < 10700;
  4684. }
  4685. return false;
  4686. }
  4687. */
  4688. }