この記事では、リファレンスのフォームライティングテクノロジーを共有しています。特定のコンテンツは次のとおりです
Java Spelling JSメソッドをサポートするために書き戻します:
/ ** * formを書き留めます * * @param mrequest * @return */ public static string writebackmaptoform(map mrequest){return return backmaptoform(mrequest、new String [] {}、 "withowbackmaptoform"); } / ** *書き込みフォーム * * @param mrequest * @param Ingorename入力が書き戻さないキー値を定義する * @return * / public static string writebackmaptoform(map mrequest、string [] ingorename、string jsfunctionname){mrequest.remove( "Checkbox_template"); //リストのチェックボックスの値を書き留めないでくださいstringbuffer rtvalue = new StringBuffer(); rtvalue.append( "var mform = new object();/n"); rtvalue.append( "var indexarray = new Array();/n"); rtvalue.append( "function writebackmaptoform(){/n"); iterator itmrequest = mrequest.keyset()。iterator(); while(itmrequest.hasnext()){string tempkey =(string)itmrequest.next(); Object TempValue = mrequest.get(tempkey); if(tempkey.startswith( "venus")|| tempkey.startswith( "ranmin")){contion; } if(rmstringHelper.ArrayContainString(Ignorename、tempkey)){contion; } string tempvaluenew = ""; if(tempvalue instanceof string){//単一の値の場合、tempvaluenew = rmstringhelper.replacestringtoscript((string)tempvalue); //データベースからそれを取り出した後、rtvalue.append( "indexarray.length] =/" " + tempkey +"/";/n")を変換する必要があります。 rtvalue.append( "mform [/" " + tempkey +"/"] =/" " + tempvaluenew +"/";/n"); } else if(tempvalue instanceof string []){//多値の場合、配列rtvalue.append( "indexarray.length] =/" " + tempkey +"/";/n"); string [] myarray =(string [])tempvalue; if(tempkey.equals( "cmd")){tempvaluenew = rmstringhelper.replacestringtoscript(myarray [0]); rtvalue.append( "mform [/" " + tempkey +"/"] =/" " + tempvaluenew +"/";/n"); } else {rtvalue.append( "mform [/" " + tempkey +"/"] = ["); for(int i = 0; i <myarray.length; i ++){if(i> 0)rtvalue.append( "、"); tempvaluenew = rmstringhelper.replacestringtoscript(myarray [i]); rtvalue.append( "/" " + tempvaluenew +"/""); } rtvalue.append( "];/n"); }} else if(tempvalue instance of timestamp){//それがタイムスタンプの場合、if(tempvalue == null){継続; } tempvaluenew = rmstringhelper.replacestringtoscript(tempValue.toString()。サブストリング(0,19)); rtvalue.append( "indexarray [indexarray.length] =/" " + tempkey +"/";/n"); rtvalue.append( "mform [/" " + tempkey +"/"] =/" " + tempvaluenew +"/";/n"); } else if(tempvalue instance of bigdecimal){tempvaluenew = rmstringhelper.replacestringtoscript(tempvalue.tostring()); rtvalue.append( "indexarray [indexarray.length] =/" " + tempkey +"/";/n"); rtvalue.append( "mform [/" " + tempkey +"/"] =/" " + tempvaluenew +"/";/n"); } else {if(tempvalue!= null){rmstringhelper.log( "ページを書き戻すと、不明なjavaタイプに遭遇しました:" + tempvalue); } 続く; }} rtValue.Append( "for(var i = 0; i <indexarray.length; i ++){/n"); rtvalue.append( "writebackvalue(indexarray [i]);/n"); rtvalue.append( "}/n"); rtvalue.append( "}/n"); rtvalue.append(jsfunctionname + "();/n"); return rtvalue.toString(); } //このメソッドを使用して、要求に値をmformオブジェクトに配置しますvar mform = new object(); var indexArray = new Array(); function writebackmaptoform(){indexarray [indexarray.length] = "att_id"; mform ["att_id"] = ""; indexArray [indexarray.length] = "BusinessTypeoiod"; mform ["BusinessTypeoiod"] = [""]; indexArray [indexarray.length] = "Business_Type1"; mform ["business_type1"] = ""; indexArray [indexarray.length] = "Business_Type2"; mform ["business_type2"] = "1"; indexArray [indexarray.length] = "cmd"; mform ["cmd"] = "SaveExaminerule"; indexArray [indexarray.length] = "document_content"; mform ["document_content"] = "s2"; indexArray [indexarray.length] = "file_path"; mform ["file_path"] = ""; indexArray [indexarray.length] = "file_template"; mform ["file_template"] = ""; indexArray [indexarray.length] = "gxl"; mform ["gxl"] = "null"; indexArray [indexarray.length] = "owner_id"; mform ["owner_id"] = "s1"; for(var i = 0; i <indexarray.length; i ++){writebackvalue(indexarray [i]); }} writebackmaptoform();キーステートメントJSPページを追加した後、出力はJSメソッドを呼び出しますjspページ:<スクリプト言語= "javascript"> <%// form writeback if(request.getAttribute(recolexamineconstants.request_write_back_form_values) out.print(rmvohelper.writebackmaptoform((java.util.map)request.getAttribute(ruleexamineconstants.request_write_back_form_values))); //フォームを出力するためのスクリプトwritebackメソッド} map mapt =(java.util.map)request.getattribute(ruleexamineconstants.request_write_back_form_values); System.out.print( "Infitis:"+mapt.entryset()); out.print( "alert(1);");%> </script> //上記のステートメントで実際に挿入されたJS形式のコンテンツは次のとおりです。 var indexArray = new Array(); function writebackmaptoform(){indexarray [indexarray.length] = "_function_id_"; mform ["_ function_id_"] = "36702125000000000000050"; indexArray [indexarray.length] = "cmd"; mform ["cmd"] = "listbusinesstypepage"; for(var i = 0; i <indexarray.length; i ++){writebackvalue(indexarray [i]); }} writebackmaptoform(); // JS Writeback form method function writebackvalue(inputname){if(form.elements [inputname] == undefined){return false;} if(form.elements [inputname] .value!= undefined){form.elements [inputname] .value = mform [inputname]; } if(form.elements [inputname] .length!= undefined){var thisvalue = mform [inputname]; if(mform [inputname] [0] == undefined){thisValue = new Array(); thisvalue [thisvalue.length] = mform [inputname]; } if(form.elements [inputname] .length!= null){var templength = form.elements [inputname] .length; for(var j = 0; j <templength; j ++){var thisobj = form.elements [inputname] [j]; for(var k = 0; k <thisvalue.length; k ++){if(thisobj.value == thisValue [k]){if(thisobj.checked!= undefined){thatobj.checked = true;壊す; } else if(thatobj.selected!= undefined){thisobj.selected = true;壊す; }} else {if(thisobj.checked!= undefined){thatobj.checked = false; } else if(thisobj.selected!= undefined){thisobj.selected = false; }}}}}}}}}}上記はこの記事に関するものです。すべての人の学習に役立つことを願っています。