Search in sources :

Example 6 with Customer

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

the class BookingsModelBean method setSelectedCustomerId.

/**
 * This method will be called automatically by the bridge if the user selects a different customer from the list,
 * because the public render parameter model-el expression #{bookingsPortlet:bookingsModelBean.selectedCustomerId}
 * exists in the WEB-INF/faces-config.xml descriptor.
 *
 * @param  selectedCustomerId
 */
public void setSelectedCustomerId(String selectedCustomerId) {
    logger.debug("Retrieving bookings for new selectedCustomerId=[{0}]", selectedCustomerId);
    this.selectedCustomerId = selectedCustomerId;
    if (selectedCustomerId != null) {
        long customerId = Long.parseLong(selectedCustomerId);
        Customer selectedCustomer = customerService.getCustomer(customerId);
        setCustomer(selectedCustomer);
    }
}
Also used : Customer(com.liferay.faces.demos.dto.Customer)

Example 7 with Customer

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

the class CustomersBackingBean method selectionListener.

/**
 * This method is a JSF action listener that is called when the user clicks on a customer. By calling {@link
 * CustomersModelBean#setSelectedCustomerId(String)} it may seem that we are simply recording the selected
 * customerId in the model. However, there is more than meets the eye. I the WEB-INF/faces-config.xml descriptor
 * there is an EL expression of #{customersPortlet:customersModelBean.selectedCustomerId} which means that the
 * bridge will be monitoring the status of that model bean property. If the value changes in the model bean, then
 * the bridge will automatically call {@link BookingsModelBean#setSelectedCustomerId(String)} because of the other
 * model-el Expression #{bookingsPortlet:bookingsModelBean.selectedCustomerId} found in the WEB-INF/faces-config.xml
 * descriptor.
 */
public void selectionListener(ActionEvent actionEvent) {
    UICommand uiCommand = (UICommand) actionEvent.getComponent();
    Customer customer = (Customer) uiCommand.getValue();
    logger.debug("User click! selectedCustomerId=[{0}]", customer.getCustomerId());
    customersModelBean.setSelectedCustomerId(Long.toString(customer.getCustomerId()));
}
Also used : Customer(com.liferay.faces.demos.dto.Customer) UICommand(javax.faces.component.UICommand)

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