I've been going through the generated code for a Skeleton app based on Seam
that Hibernate Tools gives you and have been trying to refactor it into a
cleaner design to get rid of a lot of the repetitious code.
One thing that I would like to do that would make the refactoring easier is to
declare abstract base classes that defined the
@DataModel and @DataModelSelection
for the subclasses as well as the findFirstPage(), reorder(), findPrevPage(),
etc...
Is there a way to inherit the Seam annotations so that you don't have to
declare them in the child classes?
Ex:
| Local interface for all finder classes:
|
| @Local
| public interface Base {
| public String findFirstPage();
| }
|
| Base class for all finder classes:
|
| public abstract class BaseClass<T extends Serializable> implements Base,
Serializable {
|
| @In(create = true)
| protected EntityManager em;
|
| @DataModel
| protected List<T> results;
|
| @DataModelSelection("results")
| protected T selectedResult;
|
| protected abstract String findFirstPage();
| }
|
| Find subclass for User objects:
|
| @Name("userFinder")
| @Stateful
| @Interceptors(...)
| public class UserFinder extends BaseFinder<User> implements Base,
Serializable {
| public String findFirstPage() {
| this.results = (List<User>) em.createQuery("from
User").getResultsList();
|
| return null;
| }
| }
|
| And somewhere in the jsf code:
|
| <h:dataTable value="#{results}" var="user">
| ...
| #{user.userName}
| ...
| </h:dataTable>
|
The point being, that the methods and fields referred to by the #{...}
expressions would be able to access the base class and not just the stateful
UserFinder bean.
Is this doable?
Thanks,
- Cory
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3926883#3926883
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3926883
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user