WelcomeController.java
// license-header java merge-point
// Generated by andromda-jsf cartridge (controllers\Controller.java.vsl) DO NOT EDIT!
package org.andromda.samples.carrental.welcome;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import org.andromda.samples.carrental.ControllerBase;
import org.andromda.samples.carrental.JsfUtils;
import org.andromda.samples.carrental.admins.web.login.AdministratorLoginController;
import org.andromda.samples.carrental.customers.web.login.CustomerLogInController;
/**
* <p>
* TODO: Model Documentation for org.andromda.samples.carrental.welcome.WelcomeController
* </p>
*/
public abstract class WelcomeController
extends ControllerBase
implements Serializable
{
/**
* The serial version UID of this class. Needed for serialization.
*/
private static final long serialVersionUID = 1L;
/**
* Returns an instance from the JSF context
*
*/
public static WelcomeController instance()
{
return (WelcomeController)JsfUtils.resolveVariable("welcomeController");
}
/**
* Populate action form and page variables
*
* @param currentView the current view
* @param forward the forward view
* @param sourceForm the source form
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
*/
private void populateActionFormsAndPageVariables(final String currentView, String forward, final Object sourceForm) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
{
if(forward == null)
{
forward=currentView;
}
final Map<String,Object> pageVariables=this.getPageVariables(forward);
if("/org/andromda/samples/carrental/welcome/show-welcome.jsf".equals(forward))
{
WelcomeViewPopulator.populateShowWelcomePageVariables(sourceForm,pageVariables);
}
ControllerBase.getUseCaseScope().put(CURRENT_PAGE_VARIABLES_KEY, pageVariables);
}
/**
* <p>
* Return the welcome message
* </p>
*
* @param form the associated form
* @throws Throwable
*/
public abstract String getWelcomeMessage()
throws Throwable;
/**
* <p>
* TODO: Model Documentation for Customer login
* </p>
* This method is called when 'Customer login' is triggered in the view 'Show Welcome'.
* It can be safely overridden in descendant classes.
*/
protected void _showWelcome_customerLogin()
{
//this method can be overridden
}
/**
* Retrieves showWelcomeCustomerLogin()
*
* @return showWelcomeCustomerLogin
* @throws Throwable
*/
public String showWelcomeCustomerLogin()
throws Throwable
{
this.setLastPostedFormClientId("welcomeShowWelcomeCustomerLoginForm");
String forward=null;
forward=((CustomerLogInController)JsfUtils.resolveVariable("customerLogInController")).startUseCase();
return forward;
}
/**
* <p>
* TODO: Model Documentation for Admin Login
* </p>
* This method is called when 'Admin Login' is triggered in the view 'Show Welcome'.
* It can be safely overridden in descendant classes.
*/
protected void _showWelcome_adminLogin()
{
//this method can be overridden
}
/**
* Retrieves showWelcomeAdminLogin()
*
* @return showWelcomeAdminLogin
* @throws Throwable
*/
public String showWelcomeAdminLogin()
throws Throwable
{
this.setLastPostedFormClientId("welcomeShowWelcomeAdminLoginForm");
String forward=null;
forward=((AdministratorLoginController)JsfUtils.resolveVariable("administratorLoginController")).startUseCase();
return forward;
}
/**
* Retrieves the {@link WelcomeFormImpl} form instance
*
* @return WelcomeFormImpl
*/
protected WelcomeFormImpl getWelcomeForm()
{
return (WelcomeFormImpl)JsfUtils.resolveVariable("welcomeWelcomeForm");
}
/**
* This method is called when the use case 'welcome' starts.
* It can be safely overridden in descendant classes.
*
* @param form the associated form
*/
protected void _welcome_started(WelcomeFormImpl form)
{
//this method can be overridden
}
/**
* Retrieves the internal start use case
*
* @return welcome
* @throws Throwable
*/
protected String internalStartUseCase(Map<String,Object> useCaseParameters)
throws Throwable
{
this.setLastPostedFormClientId("welcomeWelcomeForm");
String forward=null;
final WelcomeFormImpl form =
this.getWelcomeForm();
//copy parameters form caller use case
form.copyFrom(useCaseParameters);
//trigger method execution
_welcome_started(form);
forward = _welcomeStart(form);
populateActionFormsAndPageVariables(null,forward,form);
return forward;
}
/**
* <p>
* TODO: Model Documentation for Welcome Start
* </p>
*
* @param form the associated form
* @return the forward view
* @throws Throwable
*/
protected String _welcomeStart(final WelcomeFormImpl form)
throws Throwable
{
String forward = null;
getWelcomeMessage();
forward = "/org/andromda/samples/carrental/welcome/show-welcome.jsf";
return forward;
}
}