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 javax.enterprise.context.RequestScoped;
   20   import javax.enterprise.inject.Default;
   21   import javax.inject.Inject;
   22   import javax.inject.Named;
   23   
   24   import org.apache.webbeans.reservation.controller.user.UserController;
   25   import org.apache.webbeans.reservation.entity.User;
   26   import org.apache.webbeans.reservation.session.SessionTracker;
   27   import org.apache.webbeans.reservation.util.JSFUtility;
   28   
   29   @Named
   30   @RequestScoped
   31   public class UserUpdateBean
   32   {
   33       private String name;
   34       
   35       private String surname;
   36       
   37       private int age;
   38       
   39       private String userName;
   40       
   41       private String password;
   42       
   43       private @Inject @Default UserController controller;
   44       
   45       private @Inject @Default SessionTracker tracker;
   46       
   47       public UserUpdateBean()
   48       {
   49           
   50       }
   51   
   52       public String showInfo()
   53       {
   54           //Just show how can access session webbeans
   55           User user = this.controller.getUser(tracker.getUser().getId());
   56           
   57           setName(user.getName());
   58           setSurname(user.getSurname());
   59           setAge(user.getAge());
   60           setUserName(user.getUserName());
   61           setPassword(user.getPassword());
   62                   
   63           return "toUpdatePage";
   64       }
   65   
   66       public String clear()
   67       {
   68           setName("");
   69           setSurname("");
   70           setAge(0);
   71           setUserName("");
   72           setPassword("");
   73           
   74           return null;
   75       }
   76       
   77       public String update()
   78       {
   79           this.controller.updateUserInfo(tracker.getUser().getId(), name, surname, age, userName, password);
   80           
   81           JSFUtility.addInfoMessage("Personal information is succesfully updated.", "");
   82           
   83           return null;
   84       }
   85       
   86       /**
   87        * @return the name
   88        */
   89       public String getName()
   90       {
   91           return name;
   92       }
   93   
   94       /**
   95        * @param name the name to set
   96        */
   97       public void setName(String name)
   98       {
   99           this.name = name;
  100       }
  101   
  102       /**
  103        * @return the surname
  104        */
  105       public String getSurname()
  106       {
  107           return surname;
  108       }
  109   
  110       /**
  111        * @param surname the surname to set
  112        */
  113       public void setSurname(String surname)
  114       {
  115           this.surname = surname;
  116       }
  117   
  118       /**
  119        * @return the age
  120        */
  121       public int getAge()
  122       {
  123           return age;
  124       }
  125   
  126       /**
  127        * @param age the age to set
  128        */
  129       public void setAge(int age)
  130       {
  131           this.age = age;
  132       }
  133   
  134       /**
  135        * @return the userName
  136        */
  137       public String getUserName()
  138       {
  139           return userName;
  140       }
  141   
  142       /**
  143        * @param userName the userName to set
  144        */
  145       public void setUserName(String userName)
  146       {
  147           this.userName = userName;
  148       }
  149   
  150       /**
  151        * @return the password
  152        */
  153       public String getPassword()
  154       {
  155           return password;
  156       }
  157   
  158       /**
  159        * @param password the password to set
  160        */
  161       public void setPassword(String password)
  162       {
  163           this.password = password;
  164       }
  165       
  166       
  167   }

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