[jboss-user] [JBoss Seam] - Re: A couple of observations
iradix
do-not-reply at jboss.com
Mon Aug 28 14:44:12 EDT 2006
Not an inner class, the class definition would not have to be within the parent.
An example of how it works now:
| @Stateful
| @Name("productSearcher")
| public Class ProductSearcherImpl....{
|
| @DataModel
| private List<Product> searchResults;
|
| private List<ProductFilter> filters = new ArrayList<ProductFilter>();
|
| @Create
| public void init(){
| for(ProductCategory category: categoryDAO.list()){
| ProductCategoryFilter filter = Component.newInstance("productCategoryFilter");
| filter.setCategory(category);
| filters.add(filter);
| }
| }
|
| @Factory("searchResults")
| public void search(){
| searchResults = ...
| for(ProductFilter filter: filters){
| filter.apply(searchResults);
| }
| }
|
| }
|
To me at least this is bad. Every time I call Component.newInstance() I outject the created filter. Since the Filter is never used outside of the containing SFSB, I don't want it oujected. What I do want is for each filter to recieve injection from the associated contexts AND be allowed to outject values into those contexts. What I was thinking would look like this:
| @Stateful
| @Name("productSearcher")
| public Class ProductSearcherImpl....{
|
| @DataModel
| private List<Product> searchResults;
|
| @ChildComponent
| private List<ProductFilter> filters = new ArrayList<ProductFilter>();
|
| @Create
| public void init(){
| for(ProductCategory category: categoryDAO.list())
| ProductFilter filter = new ProductFilter(category);
| }
|
| @Factory("searchResults")
| public void search(){
| searchResults = ...
| for(ProductFilter filter: filters){
| filter.apply(searchResults);
| }
| }
|
| }
|
Does that make more sense?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3967896#3967896
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3967896
More information about the jboss-user
mailing list