Search in sources :

Example 1 with Customer

use of com.liferay.faces.demos.dto.Customer in project liferay-faces-bridge-impl by liferay.

the class CustomerServiceMockImpl method getCustomer.

public Customer getCustomer(long customerId) {
    Customer customer = null;
    List<Customer> customers = getAllCustomers();
    for (Customer curCustomer : customers) {
        if (curCustomer.getCustomerId() == customerId) {
            customer = curCustomer;
            break;
        }
    }
    return customer;
}
Also used : Customer(com.liferay.faces.demos.dto.Customer)

Example 2 with Customer

use of com.liferay.faces.demos.dto.Customer in project liferay-faces-bridge-impl by liferay.

the class CustomerServiceMockImpl method postConstruct.

@PostConstruct
public void postConstruct() {
    allCustomers = new ConcurrentHashMap<Long, Customer>();
    BookingService bookingService = getBookingService();
    Customer customer = new Customer(ID_BRIAN_GREEN, "Brian", "Green");
    customer.setBookings(bookingService.getBookingsByCustomerId(ID_BRIAN_GREEN));
    allCustomers.put(ID_BRIAN_GREEN, customer);
    customer = new Customer(ID_LIZ_KESSLER, "Liz", "Kessler");
    customer.setBookings(bookingService.getBookingsByCustomerId(ID_LIZ_KESSLER));
    allCustomers.put(ID_LIZ_KESSLER, customer);
    customer = new Customer(ID_RICH_SHEARER, "Rich", "Shearer");
    customer.setBookings(bookingService.getBookingsByCustomerId(ID_RICH_SHEARER));
    allCustomers.put(ID_RICH_SHEARER, customer);
}
Also used : Customer(com.liferay.faces.demos.dto.Customer) PostConstruct(javax.annotation.PostConstruct)

Example 3 with Customer

use of com.liferay.faces.demos.dto.Customer in project liferay-faces-bridge-impl by liferay.

the class CustomerSelectedEventHandler method handleEvent.

public EventNavigationResult handleEvent(FacesContext facesContext, Event event) {
    EventNavigationResult eventNavigationResult = null;
    String eventQName = event.getQName().toString();
    if (eventQName.equals("{http://liferay.com/events}ipc.customerSelected")) {
        Serializable value = event.getValue();
        // payload from the wrapper.
        if (value instanceof EventPayloadWrapper) {
            value = ((EventPayloadWrapper) value).getWrapped();
        }
        Customer customer = (Customer) value;
        BookingsModelBean bookingsModelBean = getBookingsModelBean(facesContext);
        bookingsModelBean.setCustomer(customer);
        String fromAction = null;
        String outcome = "ipc.customerSelected";
        eventNavigationResult = new EventNavigationResult(fromAction, outcome);
        logger.debug("Received event ipc.customerSelected for customerId=[{0}] firstName=[{1}] lastName=[{2}]", new Object[] { customer.getCustomerId(), customer.getFirstName(), customer.getLastName() });
    }
    return eventNavigationResult;
}
Also used : Serializable(java.io.Serializable) EventPayloadWrapper(com.liferay.faces.bridge.event.EventPayloadWrapper) Customer(com.liferay.faces.demos.dto.Customer) EventNavigationResult(javax.portlet.faces.event.EventNavigationResult) BookingsModelBean(com.liferay.faces.demos.bean.BookingsModelBean)

Example 4 with Customer

use of com.liferay.faces.demos.dto.Customer in project liferay-faces-bridge-impl by liferay.

the class CustomerEditedEventHandler method handleEvent.

public EventNavigationResult handleEvent(FacesContext facesContext, Event event) {
    EventNavigationResult eventNavigationResult = null;
    String eventQName = event.getQName().toString();
    if (eventQName.equals("{http://liferay.com/events}ipc.customerEdited")) {
        Customer customer = (Customer) event.getValue();
        getCustomerService(facesContext).save(customer);
        logger.debug("Received event ipc.customerEdited for customerId=[{0}] firstName=[{1}] lastName=[{2}]", new Object[] { customer.getCustomerId(), customer.getFirstName(), customer.getLastName() });
    }
    return eventNavigationResult;
}
Also used : Customer(com.liferay.faces.demos.dto.Customer) EventNavigationResult(javax.portlet.faces.event.EventNavigationResult)

Example 5 with Customer

use of com.liferay.faces.demos.dto.Customer in project liferay-faces-bridge-impl by liferay.

the class BookingsModelBean method postConstruct.

@PostConstruct
public void postConstruct() {
    logger.trace("@PostConstruct annotation worked");
    customer = new Customer();
    customer.setBookings(new ArrayList<Booking>(5));
}
Also used : Customer(com.liferay.faces.demos.dto.Customer) Booking(com.liferay.faces.demos.dto.Booking) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Customer (com.liferay.faces.demos.dto.Customer)7 PostConstruct (javax.annotation.PostConstruct)2 EventNavigationResult (javax.portlet.faces.event.EventNavigationResult)2 EventPayloadWrapper (com.liferay.faces.bridge.event.EventPayloadWrapper)1 BookingsModelBean (com.liferay.faces.demos.bean.BookingsModelBean)1 Booking (com.liferay.faces.demos.dto.Booking)1 Serializable (java.io.Serializable)1 UICommand (javax.faces.component.UICommand)1