Search in sources :

Example 1 with BookingsModelBean

use of com.liferay.faces.demos.bean.BookingsModelBean 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 2 with BookingsModelBean

use of com.liferay.faces.demos.bean.BookingsModelBean in project liferay-faces-bridge-impl by liferay.

the class CustomerSelectedEventHandler method getBookingsModelBean.

protected BookingsModelBean getBookingsModelBean(FacesContext facesContext) {
    String elExpression = "#{bookingsModelBean}";
    ELContext elContext = facesContext.getELContext();
    ValueExpression valueExpression = facesContext.getApplication().getExpressionFactory().createValueExpression(elContext, elExpression, BookingsModelBean.class);
    return (BookingsModelBean) valueExpression.getValue(elContext);
}
Also used : ELContext(javax.el.ELContext) ValueExpression(javax.el.ValueExpression) BookingsModelBean(com.liferay.faces.demos.bean.BookingsModelBean)

Aggregations

BookingsModelBean (com.liferay.faces.demos.bean.BookingsModelBean)2 EventPayloadWrapper (com.liferay.faces.bridge.event.EventPayloadWrapper)1 Customer (com.liferay.faces.demos.dto.Customer)1 Serializable (java.io.Serializable)1 ELContext (javax.el.ELContext)1 ValueExpression (javax.el.ValueExpression)1 EventNavigationResult (javax.portlet.faces.event.EventNavigationResult)1