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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 4 09:00:40 EST 2010


Author: lvlcek at redhat.com
Date: 2010-03-04 09:00:40 -0500 (Thu, 04 Mar 2010)
New Revision: 101824

Modified:
   projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/java/org/jboss/snowdrop/samples/sportsclub/jsf/beans/ReservationSearch.java
   projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/WEB-INF/spring-beans.xml
   projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/searchReservation.xhtml
Log:
JBQA-3032 done

Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/java/org/jboss/snowdrop/samples/sportsclub/jsf/beans/ReservationSearch.java
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/java/org/jboss/snowdrop/samples/sportsclub/jsf/beans/ReservationSearch.java	2010-03-04 13:43:33 UTC (rev 101823)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/java/org/jboss/snowdrop/samples/sportsclub/jsf/beans/ReservationSearch.java	2010-03-04 14:00:40 UTC (rev 101824)
@@ -7,15 +7,11 @@
 import org.jboss.snowdrop.samples.sportsclub.domain.entity.Account;
 import org.jboss.snowdrop.samples.sportsclub.domain.entity.Equipment;
 import org.jboss.snowdrop.samples.sportsclub.service.ReservationService;
-import org.richfaces.model.selection.Selection;
 import org.richfaces.model.selection.SimpleSelection;
 
 import javax.faces.context.FacesContext;
 import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Locale;
+import java.util.*;
 
 /**
  * @author <a href="mailto:lvlcek at redhat.com">Lukas Vlcek</a>
@@ -32,6 +28,7 @@
    private AccountFilter accountFilter;
    private EquipmentFilter equipmentFilter;
    private Locale locale = Locale.getDefault();
+   private Reservation reservation;
 
    private boolean editing;
 
@@ -51,7 +48,7 @@
    }
 
    @Override
-   public Map<Long,? extends Object> getDomainObjectMap()
+   public Map<Long, ? extends Object> getDomainObjectMap()
    {
       return reservationsMap;
    }
@@ -60,9 +57,9 @@
    public Long getCurrentRowCount()
    {
       return reservationService.countReservationsForRange(
-               reservationSearchOptions.getFromDate(),
-               reservationSearchOptions.getToDate(),
-               reservationSearchOptions.getSelectedEquipmentTypes());
+            reservationSearchOptions.getFromDate(),
+            reservationSearchOptions.getToDate(),
+            reservationSearchOptions.getSelectedEquipmentTypes());
    }
 
    @Override
@@ -83,11 +80,25 @@
       }
    }
 
-   public String equipmentTypeCheckboxChanged()
+   public void reservationSelected()
    {
-      return null; // TODO ?
+      if (getSelection() != null && getSelection().size() > 0)
+      {
+         reservation = reservationsMap.get(getSelectedKey());
+      } else
+      {
+         reservation = null;
+         editing = false;
+      }
+      cleanFilters();
    }
 
+   private void cleanFilters()
+   {
+      accountFilter.setSelection(new SimpleSelection());
+      equipmentFilter.setSelection(new SimpleSelection());
+   }
+
    public ReservationTableState getTableState()
    {
       return tableState;
@@ -116,39 +127,53 @@
          return ((Long) getSelection().getKeys().next());
    }
 
-   public Reservation getCurrentReservation()
+   public void deleteReservation()
    {
-      if (getSelection() != null && getSelection().size() > 0)
-         return reservationsMap.get(getSelectedKey());
-      else
-         return null;
-   }
-
-   public String deleteReservation()
-   {
-      reservationService.delete(getCurrentReservation());
+      if (reservation != null)
+      {
+         reservationService.delete(reservation);
+         reservation = null;
+      }
       setSelection(new SimpleSelection());
+      cleanFilters();
       resetCurrentRowCount();
-      return "closed";
+      editing = false;
    }
 
    public void saveCurrent()
    {
-      reservationService.updateReservation(getCurrentReservation());
+      if (reservation != null)
+      {
+         reservationService.updateReservation(reservation);
+         reservation = null;
+      }
       setSelection(new SimpleSelection());
+      cleanFilters();
       editing = false;
    }
 
    public void updateSelectedAccount()
    {
-      Account account = accountFilter.getSelectedAccount();
-      //reservation.setAccount(account);
+      if (accountFilter.getSelection() != null && accountFilter.getSelection().size() > 0)
+      {
+         Account account = accountFilter.getSelectedAccount();
+         reservation.setAccount(account);
+      } else
+      {
+         reservation.setAccount(reservationsMap.get(getSelectedKey()).getAccount());
+      }
    }
 
    public void updateSelectedEquipment()
    {
-      Equipment equipment = equipmentFilter.getSelectedEquipment();
-      //reservation.setEquipment(equipment);
+      if (equipmentFilter.getSelection() != null && equipmentFilter.getSelection().size() > 0)
+      {
+         Equipment equipment = equipmentFilter.getSelectedEquipment();
+         reservation.setEquipment(equipment);
+      } else
+      {
+         reservation.setEquipment(reservationsMap.get(getSelectedKey()).getEquipment());
+      }
    }
 
    public void setEditing(boolean editing)
@@ -190,4 +215,9 @@
    {
       this.locale = locale;
    }
+
+   public Reservation getReservation()
+   {
+      return reservation;
+   }
 }

Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/WEB-INF/spring-beans.xml
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/WEB-INF/spring-beans.xml	2010-03-04 13:43:33 UTC (rev 101823)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/WEB-INF/spring-beans.xml	2010-03-04 14:00:40 UTC (rev 101824)
@@ -19,19 +19,12 @@
         <property name="equipmentFilter" ref="equipmentFilter"/>
     </bean>
 
-    <bean id="accountFilter" class="org.jboss.snowdrop.samples.sportsclub.jsf.beans.AccountFilter" scope="session">
-        <property name="accountService" ref="accountService"/>
-    </bean>
-
-    <bean id="equipmentFilter" class="org.jboss.snowdrop.samples.sportsclub.jsf.beans.EquipmentFilter" scope="session">
-        <property name="equipmentService" ref="equipmentService"/>
-    </bean>
-
-
     <bean id="reservationSearch" class="org.jboss.snowdrop.samples.sportsclub.jsf.beans.ReservationSearch" scope="session">
         <property name="reservationService" ref="reservationService"/>
         <property name="tableState" ref="reservationSearchTableState"/>
         <property name="reservationSearchOptions" ref="reservationSearchOptions"/>
+        <property name="accountFilter" ref="accountFilter"/>
+        <property name="equipmentFilter" ref="equipmentFilter"/>
     </bean>
     
     <bean id="reservationSearchTableState" class="org.jboss.snowdrop.samples.sportsclub.jsf.beans.ReservationTableState" scope="session"/>
@@ -40,7 +33,14 @@
         <property name="equipmentService" ref="equipmentService"/>
     </bean>
 
+    <bean id="accountFilter" class="org.jboss.snowdrop.samples.sportsclub.jsf.beans.AccountFilter" scope="session">
+        <property name="accountService" ref="accountService"/>
+    </bean>
 
+    <bean id="equipmentFilter" class="org.jboss.snowdrop.samples.sportsclub.jsf.beans.EquipmentFilter" scope="session">
+        <property name="equipmentService" ref="equipmentService"/>
+    </bean>
+    
     <bean id="equipmentTypeConverter" class="org.jboss.snowdrop.samples.sportsclub.jsf.beans.converter.EquipmentTypeConverter"/>
     
     <!-- Application scoped service -->

Modified: projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/searchReservation.xhtml
===================================================================
--- projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/searchReservation.xhtml	2010-03-04 13:43:33 UTC (rev 101823)
+++ projects/snowdrop/examples/trunk/sportsclub/sportsclub-reservations-web/src/main/webapp/searchReservation.xhtml	2010-03-04 14:00:40 UTC (rev 101824)
@@ -50,7 +50,6 @@
         <a4j:outputPanel id="searchResults">
             <h:form>
                 <rich:panel header="Search results">
-
                     <rich:extendedDataTable id="searchResultsTable" value="#{reservationSearch}" var="reservation"
                                             selectionMode="single"
                                             selection="#{reservationSearch.selection}"
@@ -58,7 +57,7 @@
                                             height="250px"
                                             rows="5"
                                             tableState="#{reservationSearch.tableState.tableState}">
-                        <a4j:support event="onselectionchange" reRender="reservationData,reservationFilters"/>
+                        <a4j:support event="onselectionchange" action="#{reservationSearch.reservationSelected}" reRender="reservationData,reservationFilters"/>
                         <rich:column label="Reservation #">
                             <f:facet name="header">
                                 <h:outputText value="Reservation #"/>
@@ -110,9 +109,9 @@
         </a4j:outputPanel>
 
         <!--*********************************** -->
-
+        
         <a4j:outputPanel id="reservationFilters">
-            <rich:panel rendered="#{reservationSearch.editing and reservationSearch.currentReservation != null}">
+            <rich:panel rendered="#{reservationSearch.editing and reservationSearch.reservation != null}">
                 <f:facet name="header">Edit Reservation</f:facet>
                 <table>
                     <tr>
@@ -140,8 +139,8 @@
                                                             height="250px"
                                                             rows="5">
                                         <a4j:support event="onselectionchange"
-                                                     action="#{reservationCreate.updateSelectedAccount}"
-                                                     reRender="reservationDetails"/>
+                                                     action="#{reservationSearch.updateSelectedAccount}"
+                                                     reRender="reservationData"/>
 
                                         <rich:column label="Id" width="7%">
                                             <f:facet name="header">
@@ -198,8 +197,8 @@
                                                                 height="250px"
                                                                 rows="5">
                                             <a4j:support event="onselectionchange"
-                                                         action="#{reservationCreate.updateSelectedEquipment}"
-                                                         reRender="reservationDetails"/>
+                                                         action="#{reservationSearch.updateSelectedEquipment}"
+                                                         reRender="reservationData"/>
 
                                             <rich:column label="Id" width="10%">
                                                 <f:facet name="header">
@@ -240,59 +239,57 @@
         <!-- ******************************************** -->
 
         <a4j:outputPanel id="reservationData">
-            <rich:panel rendered="#{reservationSearch.currentReservation != null}" >
+            <rich:panel rendered="#{reservationSearch.reservation != null}" >
                 <h:form>
-                    <a4j:region id="controlRegion">
-                        <h:panelGrid columns="2">
-                            <h:outputLabel value="Equipment"/>
-                            <h:panelGroup>
-                                <h:outputText rendered="#{reservationSearch.currentReservation.equipment != null}"
-                                              value="#{reservationSearch.currentReservation.equipment.name} (#{reservationSearch.currentReservation.equipment.description})"/>
-                                <h:outputText rendered="#{reservationSearch.currentReservation.equipment == null}"
-                                              value="Not selected"/>
-                            </h:panelGroup>
+                    <h:panelGrid columns="2">
+                        <h:outputLabel value="Equipment:"/>
+                        <h:panelGroup>
+                            <h:outputText rendered="#{reservationSearch.reservation.equipment != null}"
+                                          value="#{reservationSearch.reservation.equipment.name} (#{reservationSearch.reservation.equipment.description})"/>
+                            <h:outputText rendered="#{reservationSearch.reservation.equipment == null}"
+                                          value="Not selected"/>
+                        </h:panelGroup>
 
-                            <h:outputLabel value="Account"/>
-                            <h:panelGroup>
-                                <h:outputText rendered="#{reservationSearch.currentReservation.account != null}"
-                                              value="#{reservationSearch.currentReservation.account.subscriber.name.firstName} #{reservationSearch.currentReservation.account.subscriber.name.lastName} (#{reservationSearch.currentReservation.account.subscriber.address.city}, #{reservationSearch.currentReservation.account.subscriber.address.country})"/>
-                                <h:outputText rendered="#{reservationSearch.currentReservation.account == null}" value="Not selected"/>
-                            </h:panelGroup>
-    
-                            <h:outputLabel value="From"/>
-                            <h:panelGroup>
-                                <h:outputText value="#{reservationSearch.currentReservation.from}" rendered="#{!reservationSearch.editing}"/>
-                                <rich:calendar id="from"
-                                           value="#{reservationSearch.currentReservation.from}"
-                                           datePattern="d/M/yy HH:mm"
-                                           showApplyButton="true"
-                                           locale="#{reservationSearch.locale}"
-                                           rendered="#{reservationSearch.editing}"/>
-                            </h:panelGroup>
+                        <h:outputLabel value="Account:"/>
+                        <h:panelGroup>
+                            <h:outputText rendered="#{reservationSearch.reservation.account != null}"
+                                          value="#{reservationSearch.reservation.account.subscriber.name.firstName} #{reservationSearch.reservation.account.subscriber.name.lastName} (#{reservationSearch.reservation.account.subscriber.address.city}, #{reservationSearch.reservation.account.subscriber.address.country})"/>
+                            <h:outputText rendered="#{reservationSearch.reservation.account == null}" value="Not selected"/>
+                        </h:panelGroup>
 
-                            <h:outputLabel value="To"/>
-                            <h:panelGroup>
-                                <h:outputText value="#{reservationSearch.currentReservation.to}" rendered="#{!reservationSearch.editing}"/>
-                                <rich:calendar id="to"
-                                           value="#{reservationSearch.currentReservation.to}"
-                                           datePattern="d/M/yy HH:mm"
-                                           showApplyButton="true"
-                                           locale="#{reservationSearch.locale}"
-                                           rendered="#{reservationSearch.editing}"/>
-                            </h:panelGroup>
+                        <h:outputLabel value="From:"/>
+                        <h:panelGroup>
+                            <h:outputText value="#{reservationSearch.reservation.from}" rendered="#{!reservationSearch.editing}"/>
+                            <rich:calendar id="from"
+                                       value="#{reservationSearch.reservation.from}"
+                                       datePattern="d/M/yy HH:mm"
+                                       showApplyButton="true"
+                                       locale="#{reservationSearch.locale}"
+                                       rendered="#{reservationSearch.editing}"/>
+                        </h:panelGroup>
 
-                            <a4j:commandButton id="deleteRsrvBtn" value="Delete" action="#{reservationSearch.deleteReservation}" reRender="searchResults,reservationData" rendered="#{!reservationSearch.editing}"/>
-                            <a4j:commandButton id="editRsrvBtn" value="Edit" reRender="reservationData,reservationFilters" rendered="#{!reservationSearch.editing}">
-                                <f:setPropertyActionListener value="#{true}" target="#{reservationSearch.editing}"/>
-                            </a4j:commandButton>
+                        <h:outputLabel value="To:"/>
+                        <h:panelGroup>
+                            <h:outputText value="#{reservationSearch.reservation.to}" rendered="#{!reservationSearch.editing}"/>
+                            <rich:calendar id="to"
+                                       value="#{reservationSearch.reservation.to}"
+                                       datePattern="d/M/yy HH:mm"
+                                       showApplyButton="true"
+                                       locale="#{reservationSearch.locale}"
+                                       rendered="#{reservationSearch.editing}"/>
+                        </h:panelGroup>
+                    </h:panelGrid>
+                    
+                    <a4j:commandButton id="deleteRsrvBtn" value="Delete Reservation" action="#{reservationSearch.deleteReservation}" reRender="searchResults,reservationFilters,reservationData" rendered="#{!reservationSearch.editing}" status="actionStatus" />
+                    <a4j:commandButton id="editRsrvBtn" value="Edit Reservation" reRender="reservationData,reservationFilters" rendered="#{!reservationSearch.editing}" status="actionStatus">
+                        <f:setPropertyActionListener value="#{true}" target="#{reservationSearch.editing}"/>
+                    </a4j:commandButton>
+                    <br/>
+                    <a4j:commandButton id="cancelRsrvBtn" value="Cancel Editing" rendered="#{reservationSearch.editing}" reRender="reservationData,reservationFilters">
+                        <f:setPropertyActionListener value="#{false}" target="#{reservationSearch.editing}"/>
+                    </a4j:commandButton>
+                    <a4j:commandButton id="saveRsrvBtn" value="Save Reservation" action="#{reservationSearch.saveCurrent}" reRender="reservationData,reservationFilters,searchResults" rendered="#{reservationSearch.editing}" status="actionStatus" />
 
-                            <a4j:commandButton id="cancelRsrvBtn" value="Cancel" rendered="#{reservationSearch.editing}" reRender="reservationData,reservationFilters">
-                                <f:setPropertyActionListener value="#{false}" target="#{reservationSearch.editing}"/>
-                            </a4j:commandButton>
-                            <a4j:commandButton id="saveRsrvBtn" value="Save" action="#{reservationSearch.saveCurrent}" reRender="reservationData" rendered="#{reservationSearch.editing}"/>
-
-                        </h:panelGrid>
-                    </a4j:region>
                 </h:form>
             </rich:panel>
         </a4j:outputPanel>
@@ -305,9 +302,11 @@
              <h:outputText value="Your request is being processed, please wait."></h:outputText>
         </rich:modalPanel>
 
-        <a4j:status for="controlRegion"
-                    onstart="Richfaces.showModalPanel('ajaxLoadingModalBox',{width:450, top:200})"
-                    onstop="Richfaces.hideModalPanel('ajaxLoadingModalBox')"></a4j:status>
+        <a4j:region>
+            <a4j:status id="actionStatus"
+                        onstart="Richfaces.showModalPanel('ajaxLoadingModalBox',{width:450, top:200})"
+                        onstop="Richfaces.hideModalPanel('ajaxLoadingModalBox')"></a4j:status>
+        </a4j:region>
     
     </ui:define>
 




More information about the jboss-cvs-commits mailing list