-
1. Re: @DataModel design issues -- JSF/HTTP dependency in EJBs?
uhyonc Apr 8, 2006 7:56 AM (in response to uhyonc)One way I thought of is to have the backing bean that contains the @DataModel have a select method that calls the injected bean's select method.
For example :class Main { @In(create=true) ItemEditor itemEditor; @DataModel List items; @DataModelSelection private Item selectedItem; String selectItem() { itemEditor.selectItem(selectedItem); } } class ItemFinder { @In(create=true) ItemEditor itemEditor; @DataModel List foundItems; @DataModelSelection private Item selectedItem; String selectItem() { itemEditor.selectItem(selectedItem); } } class ItemEditor { Item instance; public String selectItem(Item item) { instance = item; return "editItem"; } }
-
2. Re: @DataModel design issues -- JSF/HTTP dependency in EJBs?
mirko27 Apr 8, 2006 8:12 AM (in response to uhyonc)You should try this way:
In one bean:
@DataModel items;
In other bean;
@DataModelSelection(value="items")
This seems to be logic way of doing it.
The current select()-way-of-doing-things is needed because to Inject @datamodelselection object we need to use that bean.
By the way you do not need
this ugly solution:
String selectItem() { itemEditor.selectItem(selectedItem); }
You can replace it by
@Out @DataModelSelection item; in one bean
and @In item; in other bean.
Hope it helps. My english is not the best virtue. -
3. Re: @DataModel design issues -- JSF/HTTP dependency in EJBs?
uhyonc Apr 9, 2006 1:55 AM (in response to uhyonc)The first solution would work except that you'd have to make sure that the the @DataModel's names are all matched up. And it wouldn't work in cases where you have multiple items in a single bean, since that'd require two different selectedItem in the receiving bean.
However, I hadn't realized that you could actually do it that way. I think it'll come in useful later.
The second way would work, and is definitely prettier than the way I did it. I hadn't realized you could transfer data that way.
Thanks
- Luther -
4. Re: @DataModel design issues -- JSF/HTTP dependency in EJBs?
uhyonc Apr 9, 2006 4:04 AM (in response to uhyonc)As to the selectedItem...
It works, as long as you make sure that the bean is either a stateful session bean or it's in the page (or longer) scope and the same goes for the scope on the @Out annotation for the selectedItem. -
5. Re: @DataModel design issues -- JSF/HTTP dependency in EJBs?
uhyonc Apr 9, 2006 4:32 AM (in response to uhyonc)The outjection is tougher than you'd think...
The problem is that I have 3 beans that will outject the selectedItem object...
I tried it with both the Page scope and the Session scope. Apparently, all 3 of the beans will outject the selectedItem, which means that a random item will get outjected... (in which case I get a NPE).
I tried the stateless/event scope, which doesn't propagate the selectedItem...
I also tried the conversation scope which doesn't propagate the selectedItem...
FYI :@Stateful class Bean1 { @DataModel private List<Item> itemList; @DataModelSelection("itemList") @Out(required=false,scope=ScopeType.SESSION) private Item selectedItem; } @Stateful class Bean2 { @DataModel private List<Item> itemList; @DataModelSelection("itemList") @Out(required=false,scope=ScopeType.SESSION) private Item selectedItem; } @Scope(ScopeType.SESSION) class Bean3 { @DataModel private List<Item> itemList; @DataModelSelection("itemList") @Out(required=false,scope=ScopeType.SESSION) private Item selectedItem; } class ReceivingBean { @In(required=false) private Item selectedItem; @Begin(nested=true) public String selectItem() { } }
I'd like to know what combination of scope types/annotation type settings will work in the above case...
Note :
outject in random order is because the BijectionInterceptor is called many times and there is probably not an order in how JBoss AOP calls it... -
6. Re: @DataModel design issues -- JSF/HTTP dependency in EJBs?
mirko27 Apr 9, 2006 5:58 AM (in response to uhyonc)Use long-running conversation. You have to start thinking this way :D