Hi all,
I really love bijection; it makes things so much easier. However, I have a requirement
that makes it somehow hard to use contextual components.
Let's suppose we have a Checkout page, were you can enter shipping and a payment
addresses. These addresses obviously belong to a model of the same type. Let us further
assume, that entering an address triggers some logic (beyond validation) so we need a
controller, say:
@Name("checkoutAddressController")
| public class CheckoutAddressController {
|
| // maybe a persistence manager
| @In SomeService service
|
| // our model
| private Address address;
|
| // [...]
| // some logic, getter / setter etc
|
| }
Now on my checkout page, I want my address forms to have the above controller as a backing
bean. So I need two instances of the same component on the same page. From the manual I
read that maybe @Role could help here. But if the designer chooses to add another address
form, I would have to add another Role. What if the designer wants to add 100 addresses?
(yes, he's a maniac)
Can composition help? I thought something like this?
@Name("checkoutPage")
| public class CheckoutPage
| {
| @In(scope=ScopeType.STATELESS, create=true)
| CheckoutAddressController c1;
|
| @In(scope=ScopeType.STATELESS, create=true)
| CheckoutAddressController c2;
|
| // or even
| List<CheckoutController> ctls;
|
| @Create public void create() {
| ctls = new ArrayList...
| ctls.add(Component.getInstance("checkoutAddressController",
ScopeType.STATELESS, true))
| }
| }
Will this work?
Are there other solutions?
Am I making things to complicated?
Regards
Patrick
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068226#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...