[jboss-user] [JBoss Seam] - Re: Duplicate Factory method error from CVS head
supernovasoftware.com
do-not-reply at jboss.com
Wed Sep 26 15:52:23 EDT 2007
I didn't clean up the code much, but I will explain. If you need me to clean it up, I can as I appreciate greatly all the help that I have been giving on this forum.
First I list the generated class that I created with a custom code generation script.
Next I listed the extended version with higher precedence. In this case I need to add a simple filter to the entity list. So I overrode
| @Factory("contactList")
| public List<Contact> getEntityList()
|
Now Seam sees 2 factories for "contactList", but the original should not be deployed as a Seam component as it has lower precedence.
Generated Manager Class
| @Stateful
| @Name("contactManager")
| @Scope(ScopeType.CONVERSATION)
| public class ContactManagerBean extends CrudEjb3DAOBean<Contact, Long> implements Serializable, ContactManager
| {
| public ContactManagerBean() { super(Contact.class); }
|
| @In(create=true)
| private ContactDAO contactDAO;
|
| @DataModel(value="contactList")
| protected List<Contact> contactList;
|
| @Out(required = false)
| @DataModelSelection(value="contactList")
| private Contact contactEdit;
|
| @SuppressWarnings("unchecked")
| @Factory("contactList")
| public List<Contact> getEntityList()
| {
| log.info("@Factory(contactList)");
| return contactList = processList(contactDAO.getAll());
| }
|
| /* All Contact */
| @Out(required=false, scope=ScopeType.APPLICATION)
| private List<Contact> listContact;
|
| @Factory("listContact")
| public List<Contact> loadAll()
| {
| log.info("loadContact()");
| return listContact = contactDAO.getAll();
| }
|
| /* Active Contact */
| @Out(required=false, scope=ScopeType.APPLICATION)
| private List<Contact> listContactActive;
|
| @Factory("listContactActive")
| public List<Contact> loadActive()
| {
| log.info("loadContactActive()");
| return listContactActive = contactDAO.getActive();
| }
|
| public void clearList() { contactList = null; }
| public Contact getEntityEdit() { return this.contactEdit; }
| public void setEntityEdit(Contact entity) { contactEdit = entity; }
|
| @Destroy @Remove
| public void destroy() { }
|
| @Override
| public GenericDAO<Contact, Long> getGenericDAO() { return contactDAO; }
| }
|
Extended and set with higher presedence
| @Stateful
| @Name("contactManager")
| @Install(precedence=100)
| public class ContactManagerExtendsBean extends ContactManagerBean implements ContactSearch
| {
| @SuppressWarnings("unchecked")
| @Factory("contactList")
| public List<Contact> getEntityList()
| {
| log.info("@Factory(contactList)");
| if(strCompanyFilter==null)
| {
| return contactList = processList(((ContactDAO) getGenericDAO()).getAll());
| }
| else
| {
| return contactList = processList(((ContactDAO) getGenericDAO()).getFilterdContacts(strCompanyFilter));
| }
| }
|
| @In(required = false, create = true)
| @Out(scope = ScopeType.UNSPECIFIED, required = false)
| private String strCompanyFilter = "%";
| public String getStrCompanyFilter() { return strCompanyFilter; }
| public void setStrCompanyFilter(String strCompanyFilter) { this.strCompanyFilter = strCompanyFilter; }
|
| public void filter()
| {
| contactList = ((ContactDAO) getGenericDAO()).getFilterdContacts(strCompanyFilter);
| contactList.add(new Contact());
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4089029#4089029
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4089029
More information about the jboss-user
mailing list