Home » apache-openwebbeans-1.0.0-incubating-M3-binary » org.apache.webbeans.reservation » beans » user » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    * 
    9    *       http://www.apache.org/licenses/LICENSE-2.0
   10    * 
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   package org.apache.webbeans.reservation.beans.user;
   18   
   19   import java.util.ArrayList;
   20   import java.util.List;
   21   
   22   import javax.enterprise.context.RequestScoped;
   23   import javax.enterprise.inject.Default;
   24   import javax.inject.Inject;
   25   import javax.inject.Named;
   26   import javax.faces.component.html.HtmlDataTable;
   27   
   28   import org.apache.webbeans.reservation.controller.user.UserController;
   29   import org.apache.webbeans.reservation.entity.Reservation;
   30   import org.apache.webbeans.reservation.session.SessionTracker;
   31   import org.apache.webbeans.reservation.util.JSFUtility;
   32   
   33   @Named("listReservationBean")
   34   @RequestScoped
   35   public class UserListBean
   36   {
   37   
   38       private List<Reservation> reservations = new ArrayList<Reservation>();
   39       
   40       private HtmlDataTable model = null;
   41       
   42       private @Inject @Default UserController controller;
   43       
   44       private @Inject @Default SessionTracker tracker;
   45       
   46       public UserListBean()
   47       {
   48           
   49       }
   50   
   51       public String delete()
   52       {
   53           Reservation res = (Reservation)model.getRowData();
   54           
   55           controller.deleteReservation(res.getId());
   56           
   57           JSFUtility.addInfoMessage("Reservation is succesfully delete", "");
   58           
   59           
   60           return null;
   61       }
   62       
   63       public String showReservations()
   64       {
   65           return "toReservePage";
   66       }
   67       
   68       /**
   69        * @return the reservations
   70        */
   71       public List<Reservation> getReservations()
   72       {
   73           this.reservations = this.controller.getReservations(tracker.getUser().getId());
   74           
   75           return reservations;
   76       }
   77   
   78       /**
   79        * @param reservations the reservations to set
   80        */
   81       public void setReservations(List<Reservation> reservations)
   82       {
   83           this.reservations = reservations;
   84       }
   85   
   86       /**
   87        * @return the model
   88        */
   89       public HtmlDataTable getModel()
   90       {
   91           return model;
   92       }
   93   
   94       /**
   95        * @param model the model to set
   96        */
   97       public void setModel(HtmlDataTable model)
   98       {
   99           this.model = model;
  100       }
  101       
  102       
  103   }

Home » apache-openwebbeans-1.0.0-incubating-M3-binary » org.apache.webbeans.reservation » beans » user » [javadoc | source]