[jboss-cvs] JBossAS SVN: r98074 - in projects/snowdrop/examples/trunk/sportsclub: sportsclub-reservations-web/src/main/webapp and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Dec 21 05:43:18 EST 2009


Author: lvlcek at redhat.com
Date: 2009-12-21 05:43:18 -0500 (Mon, 21 Dec 2009)
New Revision: 98074

Modified:
   projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Account.java
   projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Equipment.java
   projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Person.java
   projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/createReservation.xhtml
Log:
Fixing broken Validation (added equals and hashCode implementation)

Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Account.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Account.java	2009-12-21 08:28:06 UTC (rev 98073)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Account.java	2009-12-21 10:43:18 UTC (rev 98074)
@@ -17,7 +17,8 @@
 @Entity
 public class Account
 {
-   @Id @GeneratedValue
+   @Id
+   @GeneratedValue
    private Long id;
 
    @OneToOne(cascade = {CascadeType.ALL})
@@ -120,5 +121,33 @@
       this.balance.setAccount(this);
       this.balance.setCurrentBalance(BigDecimal.ZERO);
    }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o)
+      {
+         return true;
+      }
+      if (o == null || getClass() != o.getClass())
+      {
+         return false;
+      }
+
+      Account that = (Account) o;
+
+      if (id != null ? !id.equals(that.id) : that.id != null)
+      {
+         return false;
+      }
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return id != null ? id.hashCode() : 0;
+   }
 }
 

Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Equipment.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Equipment.java	2009-12-21 08:28:06 UTC (rev 98073)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Equipment.java	2009-12-21 10:43:18 UTC (rev 98074)
@@ -12,7 +12,8 @@
 @Entity
 public class Equipment
 {
-   @Id @GeneratedValue
+   @Id
+   @GeneratedValue
    private Long id;
 
    private String name;
@@ -57,4 +58,32 @@
    {
       this.equipmentType = equipmentType;
    }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o)
+      {
+         return true;
+      }
+      if (o == null || getClass() != o.getClass())
+      {
+         return false;
+      }
+
+      Equipment that = (Equipment) o;
+
+      if (id != null ? !id.equals(that.id) : that.id != null)
+      {
+         return false;
+      }
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return id != null ? id.hashCode() : 0;
+   }
 }

Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Person.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Person.java	2009-12-21 08:28:06 UTC (rev 98073)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-domain/src/main/java/org/jboss/snowdrop/samples/sportsclub/domain/entity/Person.java	2009-12-21 10:43:18 UTC (rev 98074)
@@ -12,7 +12,8 @@
 @Entity
 public class Person
 {
-   @Id @GeneratedValue
+   @Id
+   @GeneratedValue
    private Long id;
 
    @Embedded
@@ -53,4 +54,32 @@
    {
       this.account = account;
    }
+
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o)
+      {
+         return true;
+      }
+      if (o == null || getClass() != o.getClass())
+      {
+         return false;
+      }
+
+      Person that = (Person) o;
+
+      if (id != null ? !id.equals(that.id) : that.id != null)
+      {
+         return false;
+      }
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return id != null ? id.hashCode() : 0;
+   }
 }

Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/createReservation.xhtml
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/createReservation.xhtml	2009-12-21 08:28:06 UTC (rev 98073)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/createReservation.xhtml	2009-12-21 10:43:18 UTC (rev 98074)
@@ -11,14 +11,20 @@
                 <h:panelGrid columns="2" >
 
                     <h:outputLabel value="Equipment"/>
-                    <rich:inplaceSelect defaultLabel="Click to enter" value="#{reservationCreate.reservation.equipment}" converter="#{equipmentConverter}">
-                        <f:selectItems value="#{reservationCreate.allEquipments}"/>
-                    </rich:inplaceSelect>
+                    <h:panelGroup>
+                        <rich:inplaceSelect id="equipment" defaultLabel="Click to enter" value="#{reservationCreate.reservation.equipment}" converter="#{equipmentConverter}">
+                            <f:selectItems value="#{reservationCreate.allEquipments}"/>
+                        </rich:inplaceSelect>
+                        <h:message for="equipment" style="color:RED"/>
+                    </h:panelGroup>
 
                     <h:outputLabel value="Account"/>
-                    <rich:inplaceSelect defaultLabel="Click to enter" value="#{reservationCreate.reservation.account}" converter="#{accountConverter}">
-                        <f:selectItems value="#{reservationCreate.allAccounts}"/>
-                    </rich:inplaceSelect>
+                    <h:panelGroup>
+                        <rich:inplaceSelect id="account" defaultLabel="Click to enter" value="#{reservationCreate.reservation.account}" converter="#{accountConverter}">
+                            <f:selectItems value="#{reservationCreate.allAccounts}"/>
+                        </rich:inplaceSelect>
+                        <h:message for="account" style="color:RED"/>
+                    </h:panelGroup>
 
                     <h:outputLabel value="From"/>
                     <rich:calendar id="from" value="#{reservationCreate.reservation.from}"/>




More information about the jboss-cvs-commits mailing list