2014-08-28 157 views
0

我对以下用例有一个体系结构问题。jsf cdi应用程序体系结构

我有一个用于创建JPA实体的JSF页面,例如订单。

Order实体有两个字段:invoiceRecipient和receiver。这两种类型的客户。

订单表单上有两个字段,每个字段都有一个按钮,用于打开一个选择列表,用于从customerSelectionController中选择一个客户。

当客户已经选择了customerSelectionController豆的确是这样的:

@Inject 
@Selected 
Event<Customer> customerSelectedEvent; 
public void select(Customer customer) { 
    customerSelectedEvent.fire(customer); 
} 

和orderFormController reveives与

public void customerSelected(@Observes @Selected Customer customer) { 

} 

事件和这里的问题是^^ 的orderFormController知道客户已被选中,但是是否打算将其设置为发票接受方或订单的接收方?

我知道你可以指定更准确的限定符像@SelectedAsInvoiceRecipient,但这真的是如何做到这一点?

我是否应该将customerSelectionController bean作为invoiceRecipientSelectionController和receiverSelectionController复制并让它们触发不同限定的Customer实体?

我也使用Apache Deltaspike,它支持GroupedConversations和其他复杂的事情,但我找不到指定的规则如何实现这一点。

感谢您的帮助

回答

0

您可以使用预选赛或包裹你的Customer实体在一个更具体的事件类型,例如

public class InvoiceRecipientSelected { 
    private Customer customer; 
    // ... add accessors ... 
} 

Event<InvoiceRecipientSelected> invoiceRecipientSelected;