Forums: Open Discussion (Thread #25505)

【WEB】result.setErrors(errors);について (2010-02-22 21:15 by Anonymous #48834)

いつもご丁寧なご回答ありがとうございます。

ある決まったエラーコードのときのみ「errorFlg」に1をたててjspで利用します。
画面遷移は、機関検索をして機関一覧を表示し、その中のひとつの機関を選んで機関名リンクをクリックすると、その機関の情報が閲覧できるようになっています。
まず、通常手順で機関一覧から機関情報画面へ遷移すると、決まったエラーコードのときは「errorFlg」に1がちゃんとセットでき、jspでも「1」を利用できるのですが、
その機関情報画面からブラウザの戻るボタンを押下して機関一覧画面へもどり、違う機関の機関名リンクを押下して機関情報を表示させようとすると、BLogicを出るときまでは(return result;)決まったエラーコードのときは「errorFlg」に1がちゃんとセットされているのに,
jspで表示すると、デフォルトの「0」が表示されてしまいます。

result.setErrors(errors);をすると、BLogicからJSPまでの間に何か通常のサクセス遷移とは違った動きをするのでしょうか。
説明がわかりにくく申し訳ございませんが、 何かお心当たりがございましたら、ご教示願います。

以下、BLogicクラスのコードです。

*********************************************************************************
//エラーフラグ(「救急対応科目が登録されていません。」エラーの場合のみ「1」)
int errorFlg = 0;

<中略>

}catch (OjuInputException e) {
BLogicMessages errors = result.getErrors();
if(errors == null){
errors = new BLogicMessages();
}
errors.add(Globals.ERROR_KEY,new BLogicMessage(e.getMessage(),false));
result.setErrors(errors);

if(CommonConst.MSGID_CM03036004.equals(e.getReturnCd())){
//排他エラー
result.setResultString(CommonConst.APP_COMMON_ERROR);
}else{

//「救急対応科目が選択されていません。」エラーの場合
if(MSG_ID_OJ02030002.equals(e.getReturnCd())){
errorFlg = 1;
}

//その他のチェックエラー
result.setResultString(CommonConst.FORWARD_FAILURE);
}
e.printStackTrace();
}

/*(8)出力情報設定*/
//①パラメータ情報
output.setParamMap(paramMap);
//②マーク情報
output.setMarkInfo(markInfo);
//汎用項目情報
output.setHanyoKomokuInfo(hanyoKomokuInfo);
//③コメント情報
output.setCommentMap(commentMap);
//④エラー情報
output.setErrorFlg(errorFlg);

result.setResultObject(output);

return result;

Reply to #48834×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: 【WEB】result.setErrors(errors);について (2010-02-24 10:43 by taromaru #48863)

result.setErrorsでエラーメッセージが設定されている場合、
出力DTO(result.setResultObjectで設定されるオブジェクト)の、
form等への反映は行わない仕様です。

特定エラー発生時のみ、
errors.addの第一引数を固有の名前にしておき(仮に「err1」とします)、
JSPでは
<logic:messagesPresent property="err1" message="false">
のタグボディに、特定エラーが発生した時の表示(または処理)を埋め、
<logic:messagesNotPresent property="err1" message="false">
のタグボディに、特定エラーが発生しなかった時の表示(または処理)を埋めることで、
対処できる思います。
Reply to #48834

Reply to #48863×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: 【WEB】result.setErrors(errors);について (2010-02-24 14:02 by Anonymous #48873)

そうでしたか!
ありがとうございます。
ご教示いただいたタグを使用して、問題を解決できました。
本当にありがとうございました。
Reply to #48834

Reply to #48873×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login