Coverage Report - jp.co.y_net.amm.page.InfoListPage
 
Classes in this File Line Coverage Branch Coverage Complexity
InfoListPage
0%
0/27
0%
0/8
0
InfoListPage$1
0%
0/7
N/A
0
InfoListPage$2
0%
0/5
0%
0/2
0
InfoListPage$3
0%
0/6
N/A
0
InfoListPage$4
0%
0/11
N/A
0
InfoListPage$4$1
0%
0/8
N/A
0
InfoListPage$4$2
0%
0/6
N/A
0
 
 1  0
 package jp.co.y_net.amm.page;
 2  
 
 3  
 import java.util.List;
 4  
 
 5  
 import jp.co.y_net.amm.AppSession;
 6  
 import jp.co.y_net.amm.AppSession.LoginUser;
 7  
 import jp.co.y_net.amm.common.ResourceReader;
 8  
 import jp.co.y_net.amm.dao.Inf;
 9  
 import jp.co.y_net.amm.dao.Usr;
 10  
 
 11  
 import org.apache.wicket.markup.html.WebMarkupContainer;
 12  
 import org.apache.wicket.markup.html.basic.Label;
 13  
 import org.apache.wicket.markup.html.form.Button;
 14  
 import org.apache.wicket.markup.html.form.Form;
 15  
 import org.apache.wicket.markup.html.link.ExternalLink;
 16  
 import org.apache.wicket.markup.html.link.Link;
 17  
 import org.apache.wicket.markup.html.list.ListItem;
 18  
 import org.apache.wicket.markup.html.list.ListView;
 19  
 import org.apache.wicket.markup.html.list.PageableListView;
 20  
 import org.apache.wicket.markup.html.panel.FeedbackPanel;
 21  
 import org.apache.wicket.model.IModel;
 22  
 import org.apache.wicket.model.LoadableDetachableModel;
 23  
 import org.apache.wicket.model.Model;
 24  
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 25  
 
 26  
 public class InfoListPage extends CommonFrameA {
 27  
     private static final long serialVersionUID = 1L;
 28  
     
 29  
     /*
 30  
      * 画面入力値
 31  
      */
 32  
     // 無し
 33  
     
 34  
     /*
 35  
      * 画面の状態
 36  
      */
 37  0
     private boolean complete = false;
 38  
     
 39  
     /**
 40  
      * ログインチェック定義
 41  
      * @see jp.co.y_net.amm.page.AppPage#validateLogin()
 42  
      */
 43  
     @Override
 44  
     public boolean validateLogin() {
 45  0
         if(AppSession.get().isLogin()) {
 46  0
             if(AppSession.get().getLoginUser().getKind().equals(Usr.KIND_運営管理者)) {
 47  0
                 return true;
 48  
             }
 49  
         }
 50  0
         return false;
 51  
     }
 52  
     
 53  0
     public InfoListPage() {
 54  
         
 55  
         /* 戻るリンク */
 56  0
         add(new ExternalLink("lnkSysAdmin", ResourceReader.getStringQuick("url.back.sysadmin")));
 57  
 
 58  
         /* 新規お知らせ作成リンク */
 59  
 //        add(new BookmarkablePageLink<Void>("goInfoEntry", InfoEntryPage.class));
 60  
         /* 編集画面への遷移 */
 61  0
         Link<Void> goInfoEntry = new Link<Void>("goInfoEntry"){
 62  
             @Override
 63  
             public void onClick() {
 64  0
                 PageParameters params = new PageParameters();
 65  
 //                params.set("infid", inf.getInfid());
 66  0
                 InfoEntryPage infoEntryPage = new InfoEntryPage(params);
 67  0
                 infoEntryPage.setReturnPage(getPage());
 68  0
                 setResponsePage(infoEntryPage);
 69  0
             }
 70  
         };
 71  0
         add(goInfoEntry);
 72  
         
 73  
         /* フィードバックメッセージ */
 74  0
         add(new FeedbackPanel("feedback"));
 75  
         
 76  
         /* 入力フォーム */
 77  0
         Form<Void> form  = new Form<Void>("form");
 78  0
         add(form);
 79  
         
 80  
         /* 初期表示エラーチェック・共通変数設定 --------------------------------------------------------------------- */
 81  0
         form.setVisible(false); // Formはエラーチェックが完了するまで非表示とする。
 82  
         
 83  0
         final LoginUser loginUser  = AppSession.get().getLoginUser();
 84  0
         if(loginUser == null) {
 85  0
             error("ログイン情報が取得できません。");
 86  0
             return;
 87  
         }
 88  0
         final Integer loginUserId = loginUser.getUsrid();
 89  
         
 90  0
         if(hasInputError()) return; // ----------エラーがあれば中止
 91  0
         form.setVisible(true);
 92  
         
 93  
         /* Form内の設定 ----------------------------------------------------------------------------------------------*/
 94  
         /* 完了メッセージ */
 95  0
         Model<String> resultMessageModel = new Model<String>() {
 96  
             @Override
 97  
             public String getObject() {
 98  0
                 if(complete) {
 99  0
                     return "削除しました。";
 100  
                 }
 101  0
                 return "";
 102  
             }
 103  
         };
 104  0
         final Label resutlMessage = new Label("resutlMessage", resultMessageModel);
 105  0
         form.add(resutlMessage);
 106  
         
 107  
         
 108  
         /* 一覧の設定 ------------------------------------------------------------------------------------------------*/
 109  
         
 110  
         /* お知らせ領域 */
 111  
         // LoadableDetachableModel は リクエストの最初に load にてデータを取得するモデル
 112  0
         final IModel<List<Inf>> infModel = new LoadableDetachableModel<List<Inf>>() {
 113  
             @Override
 114  
             protected List<Inf> load() {
 115  0
                 Inf cnd = new Inf();
 116  0
                 cnd.setStatus(Inf.STATUS_掲載中);
 117  0
                 List<Inf> list = infDao.get(cnd);
 118  0
                 return list;
 119  
             }
 120  
         };
 121  0
         final ListView<Inf> listInfo = new PageableListView<Inf>("listInfo", infModel, 20) {
 122  
             private static final long serialVersionUID = 1L;
 123  
 
 124  
             @Override
 125  
             protected void populateItem(ListItem<Inf> item) {
 126  0
                 final Inf inf = item.getModelObject();
 127  
 
 128  0
                 WebMarkupContainer infoCont = new WebMarkupContainer("infoCont");
 129  0
                 item.add(infoCont);
 130  
 
 131  
                 /* 編集画面への遷移 */
 132  0
                 Link<Void> link = new Link<Void>("link"){
 133  
                     @Override
 134  
                     public void onClick() {
 135  0
                         PageParameters params = new PageParameters();
 136  0
                         params.set("infid", inf.getInfid());
 137  0
                         InfoEntryPage infoEntryPage = new InfoEntryPage(params);
 138  0
                         infoEntryPage.setReturnPage(getPage());
 139  0
                         setResponsePage(infoEntryPage);
 140  0
                     }
 141  
                 };
 142  0
                 link.add(new Label("label", inf.getTitleFormat()));
 143  0
                 infoCont.add(link);
 144  
 
 145  0
                 item.add(new Label("date", inf.getPubdate_Disp()));
 146  
                 
 147  0
                 item.add(new Button("delete") {
 148  
                     @Override
 149  
                     public void onSubmit() {
 150  0
                         inf.setStatus(Inf.STATUS_掲載終了);
 151  0
                         infDao.update(inf, loginUserId); // 更新処理
 152  
                         
 153  
                         /* 完了状態へ遷移 */
 154  
 //                        completeDel = true; 連続削除を考慮し、完了状態へ移行しない
 155  
                         
 156  0
                         info("削除しました。");
 157  0
                     }
 158  
                 });
 159  0
             }
 160  
         };
 161  0
         form.add(listInfo);
 162  
 
 163  0
     }
 164  
 
 165  
 //    private List<Infomation> readInfo() {
 166  
 //        List<Infomation> list = new ArrayList<Infomation>();
 167  
 //
 168  
 //        for (int i = 0; i < 3; i++) {
 169  
 //            Infomation info = new Infomation();
 170  
 //            info.title = "ああああ" + i + "いいいいいうううううえええええおおおおおかかかかかかききききき";
 171  
 //            info.date = new Date();
 172  
 //            list.add(info);
 173  
 //        }
 174  
 //        return list;
 175  
 //    }
 176  
 
 177  
     //    @Override
 178  
     //    protected boolean needLogin() {
 179  
     //        return false;
 180  
     //    }
 181  
 }