【问题标题】:jsf cdi application architecturejsf cdi 应用架构
【发布时间】:2014-08-28 12:19:46
【问题描述】:

以下用例存在架构问题。

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

Order 实体有两个字段:invoiceRecipient 和receiver。都是客户类型。

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

当客户被选中时,customerSelectionController bean 会执行以下操作:

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

orderFormController 通过

接收事件
public void customerSelected(@Observes @Selected Customer customer) {

}

这就是问题^^ orderFormController 知道客户已被选中,但它打算设置为 invoiceRecipient 还是订单的接收者?

我知道您可以指定更准确的限定词,例如 @SelectedAsInvoiceRecipient,但这真的是这样做的方法吗?

我是否应该将 customerSelectionController bean 复制为 invoiceRecipientSelectionController 和 receiverSelectionController 并让它们触发不同的合格客户实体?

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

感谢您的帮助

【问题讨论】:

    标签: jsf jsf-2 cdi deltaspike


    【解决方案1】:

    您可以使用限定符或将 Customer 实体包装在更具体的事件类型中,例如

    public class InvoiceRecipientSelected {
        private Customer customer;
        // ... add accessors ...
    }
    
    Event<InvoiceRecipientSelected> invoiceRecipientSelected;
    

    【讨论】:

      猜你喜欢
      • 2015-01-11
      • 2015-08-04
      • 2012-06-23
      • 2013-05-24
      • 2017-06-13
      • 1970-01-01
      • 1970-01-01
      • 2011-10-23
      • 2018-10-10
      相关资源
      最近更新 更多