[jboss-cvs] jboss-seam/examples/ui/src/org/jboss/seam/example/ui ...

Peter Muir peter at bleepbleep.org.uk
Sat Mar 10 14:09:36 EST 2007


  User: pmuir   
  Date: 07/03/10 14:09:36

  Modified:    examples/ui/src/org/jboss/seam/example/ui       Person.java
  Added:       examples/ui/src/org/jboss/seam/example/ui       BookPk.java
                        AgeConverter.java Colour.java Book.java
  Removed:     examples/ui/src/org/jboss/seam/example/ui      
                        Converters.java
  Log:
  EntityConverter
  
  Revision  Changes    Path
  1.4       +29 -0     jboss-seam/examples/ui/src/org/jboss/seam/example/ui/Person.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Person.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/ui/src/org/jboss/seam/example/ui/Person.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- Person.java	25 Feb 2007 00:42:33 -0000	1.3
  +++ Person.java	10 Mar 2007 19:09:36 -0000	1.4
  @@ -1,13 +1,16 @@
   package org.jboss.seam.example.ui;
   
   import java.io.Serializable;
  +import java.util.List;
   
   import javax.persistence.Entity;
   import javax.persistence.EnumType;
   import javax.persistence.Enumerated;
   import javax.persistence.GeneratedValue;
   import javax.persistence.Id;
  +import javax.persistence.ManyToMany;
   import javax.persistence.ManyToOne;
  +import javax.persistence.OneToMany;
   
   @Entity
   public class Person implements Serializable
  @@ -51,6 +54,12 @@
      
      private int age;
   
  +   @ManyToMany
  +   private List<Colour> favouriteColours;
  +   
  +   @ManyToOne
  +   private Book favouriteBook;
  +
      public Country getCountry()
      {
         return country;
  @@ -110,4 +119,24 @@
      {
         this.honorific = honorific;
      }
  +   
  +   public List<Colour> getFavouriteColours()
  +   {
  +      return favouriteColours;
  +   }
  +   
  +   public void setFavouriteColours(List<Colour> favouriteColours)
  +   {
  +      this.favouriteColours = favouriteColours;
  +   }
  +   
  +   public Book getFavouriteBook()
  +   {
  +      return favouriteBook;
  +   }
  +   
  +   public void setFavouriteBook(Book favouriteBook)
  +   {
  +      this.favouriteBook = favouriteBook;
  +   }
   }
  
  
  
  1.1      date: 2007/03/10 19:09:36;  author: pmuir;  state: Exp;jboss-seam/examples/ui/src/org/jboss/seam/example/ui/BookPk.java
  
  Index: BookPk.java
  ===================================================================
  package org.jboss.seam.example.ui;
  
  import java.io.Serializable;
  
  import javax.persistence.Embeddable;
  
  @Embeddable
  public class BookPk implements Serializable
  {
     
     private String name;
     
     private String author;
     
     protected BookPk()
     {
     }
     
     public BookPk(String name, String author)
     {
        this.name = name;
        this.author = author;
     }
  
     public String getName()
     {
        return name;
     }
     
     public String getAuthor()
     {
        return author;
     }
     
     @Override
     public boolean equals(Object other)
     {
        if (other instanceof BookPk)
        {
           BookPk that = (BookPk) other;
           return this.getAuthor().equals(that.getAuthor()) && this.getName().equals(that.getName());
        }
        else
        {
           return false;
        }
     }
  }
  
  
  
  1.1      date: 2007/03/10 19:09:36;  author: pmuir;  state: Exp;jboss-seam/examples/ui/src/org/jboss/seam/example/ui/AgeConverter.java
  
  Index: AgeConverter.java
  ===================================================================
  package org.jboss.seam.example.ui;
  
  import static org.jboss.seam.InterceptionType.NEVER;
  
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  import javax.faces.convert.ConverterException;
  import javax.persistence.EntityManager;
  
  import org.jboss.seam.Component;
  import org.jboss.seam.annotations.Intercept;
  import org.jboss.seam.annotations.Name;
  import org.jboss.seam.annotations.Transactional;
  import org.jboss.seam.annotations.jsf.Converter;
  
  @Name("ageConverter")
  @Intercept(NEVER)
  @Converter
  public class AgeConverter implements javax.faces.convert.Converter
  {
     public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException
     {
        Integer i = new Integer(value);
        return i.intValue();
     }
  
     public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException
     {
        return value + "";
     }
  }
  
  
  
  1.1      date: 2007/03/10 19:09:36;  author: pmuir;  state: Exp;jboss-seam/examples/ui/src/org/jboss/seam/example/ui/Colour.java
  
  Index: Colour.java
  ===================================================================
  package org.jboss.seam.example.ui;
  
  import java.io.Serializable;
  import java.util.List;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.ManyToMany;
  
  @Entity
  public class Colour implements Serializable
  {
     
     @ManyToMany(mappedBy="favouriteColours")
     private List<Person> people;
  
     @Id @GeneratedValue
     private Integer id;
     
     private String name;
  
     public Integer getId()
     {
        return id;
     }
  
     public void setId(Integer id)
     {
        this.id = id;
     }
  
     public String getName()
     {
        return name;
     }
  
     public void setName(String name)
     {
        this.name = name;
     }
     
     
     
  }
  
  
  
  1.1      date: 2007/03/10 19:09:36;  author: pmuir;  state: Exp;jboss-seam/examples/ui/src/org/jboss/seam/example/ui/Book.java
  
  Index: Book.java
  ===================================================================
  package org.jboss.seam.example.ui;
  
  import javax.persistence.Entity;
  import javax.persistence.Id;
  
  @Entity
  public class Book
  {
     
     @Id
     private BookPk bookPk = new BookPk();
     
     private String nationality;
     
     public String getName() 
     {
        return bookPk.getName();
     }
     
     public String getAuthor() 
     {
        return bookPk.getAuthor();
     }
  
     public String getNationality()
     {
        return nationality;
     }
     
  }
  
  
  



More information about the jboss-cvs-commits mailing list