View Javadoc
1   /*
2    * Copyright (c) 2002-2015, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.release.web;
35  
36  
37  import javax.servlet.http.HttpServletRequest;
38  
39  import fr.paris.lutece.portal.service.message.SiteMessageException;
40  import fr.paris.lutece.portal.service.spring.SpringContextService;
41  import fr.paris.lutece.portal.util.mvc.commons.annotations.Action;
42  import fr.paris.lutece.portal.util.mvc.commons.annotations.View;
43  import fr.paris.lutece.portal.util.mvc.xpage.MVCApplication;
44  import fr.paris.lutece.portal.util.mvc.xpage.annotations.Controller;
45  import fr.paris.lutece.portal.web.xpages.XPage;
46  
47  
48  /**
49   * This class provides a simple implementation of an XPage
50   */
51  @Controller( xpageName = ReleaseApp.XPAGE_NAME, pageTitleI18nKey = ReleaseApp.MESSAGE_DEFAULT_PAGE_TITLE, pagePathI18nKey = ReleaseApp.MESSAGE_DEFAULT_PATH )
52  public class ReleaseApp extends MVCApplication
53  {
54      /**
55       * Name of the view of the first step of the form
56       */
57      public static final String VIEW_APPOINTMENT_FORM_FIRST_STEP = "getAppointmentFormFirstStep";
58  
59      /**
60       * Name of the view of the second step of the form
61       */
62      public static final String VIEW_APPOINTMENT_FORM_SECOND_STEP = "getAppointmentFormSecondStep";
63  
64      /**
65       * Default page of XPages of this app
66       */
67      public static final String MESSAGE_DEFAULT_PATH = "appointment.appointmentApp.defaultPath";
68  
69      /**
70       * Default page title of XPages of this app
71       */
72      public static final String MESSAGE_DEFAULT_PAGE_TITLE = "appointment.appointmentApp.defaultTitle";
73  
74      /** Infos error WorkFlow */
75      private static final String INFO_APPOINTMENT_STATE_ERROR = "appointment.info.appointment.etatinitial";
76  
77      /**
78       * The name of the XPage
79       */
80      protected static final String XPAGE_NAME = "appointment";
81  
82      /**
83       * Generated serial version UID
84       */
85      private static final long serialVersionUID = 5741361182728887387L;
86  
87      // Templates
88    // Views
89      private static final String VIEW_APPOINTMENT_FORM_LIST = "getViewFormList";
90     
91      // Actions
92      private static final String ACTION_DO_VALIDATE_FORM = "doValidateForm";
93    
94      // Parameters
95      private static final String PARAMETER_ID_FORM = "id_form";
96       private static final String PARAMETER_ID_SLOT = "idSlot";
97       // Local variables
98      private final fr.paris.lutece.plugins.workflowcore.service.workflow.WorkflowService _stateServiceWorkFlow = SpringContextService.getBean( fr.paris.lutece.plugins.workflowcore.service.workflow.WorkflowService.BEAN_SERVICE );
99     
100     
101     /**
102      * Get the list of appointment form list
103      * @param request The request
104      * @return The XPage to display
105      */
106     @View( value = VIEW_APPOINTMENT_FORM_LIST, defaultView = true )
107     public XPage getFormList( HttpServletRequest request )
108     {
109         XPage xpage = new XPage(  );
110        
111 
112         return xpage;
113     }
114 
115     /**
116      * Get the page to complete a form
117      * @param request The request
118      * @return The XPage to display
119      */
120 
121     //    @View( VIEW_GET_FORM )
122     public XPage getViewForm( HttpServletRequest request )
123     {
124         String strIdForm = request.getParameter( PARAMETER_ID_FORM );
125         
126 //        if(_appointmentFormService.getAppointmentFromSession( request.getSession(  )).getIdSlot(  )!=0)
127 //        {
128 //
129 //        idSlot = _appointmentFormService.getAppointmentFromSession( request.getSession(  )).getIdSlot(  );
130 //        }
131 //
132 //        //AppointmentSlot appointmentSlot = AppointmentSlotHome.findByPrimaryKey( idSlot );
133 
134       
135 
136         return redirectView( request, VIEW_APPOINTMENT_FORM_LIST );
137     }
138 
139     /*WORKFLOW FUTURE
140         private State getStatus( int nIdForm)
141         {
142                 State retour = null;
143                 AppointmentForm tmpForm = AppointmentFormHome.findByPrimaryKey( nIdForm );
144                 if ( tmpForm != null )
145                 {
146                         Workflow wFlow = _stateServiceWorkFlow.findByPrimaryKey( tmpForm.getIdWorkflow() );
147                         if (wFlow != null)
148                         {
149                                 retour = _stateService.getInitialState( wFlow.getId());
150                         }
151                 }
152                 return retour;
153         }
154     */
155     
156     
157 
158     /**
159      * Do validate data entered by a user to fill a form
160      * @param request The request
161      * @param ddd The request
162      * @return The next URL to redirect to
163      * @throws SiteMessageException
164      */
165     @Action( ACTION_DO_VALIDATE_FORM )
166     public XPage doValidateForm( HttpServletRequest request )
167         throws SiteMessageException
168     {
169         String strIdForm = request.getParameter( PARAMETER_ID_FORM );
170         String strIdSlot = request.getParameter(PARAMETER_ID_SLOT);
171       
172 
173         return redirectView( request, VIEW_APPOINTMENT_FORM_LIST );
174     }
175 
176  
177     
178 }