I have implemented a series of classes to manage search / detail page with JSF and PrimeFaces. More in detail, I've created an abstract class SearchDetailView<C extends BaseView, M>
in order to centralize common functionality for Search/Detail page.
In short, I've a class MyView
that extends the base SearchDetailView
. Now I'd like to add another behavior to MyView
, that is Confirm Dialog.
I'm wondering what design pattern I have to use? I was going to use the design pattern Decorator, but I don't need to add new behaviors at runtime, but I've already know what behaviors MyView
needs.
I can't extends two classes (obviously), but I didn't like to have many combinations of "base" classes. I'd like to create a second abstract class like ConfirmDialogDecorator
in order to add "dynamically" the extra functionality.
So, I ask you which design pattern add behavior to a class?
Actually my code is like the following:
public abstract class SearchDetailView<C extends BaseController, M> extends BaseView {
[...]
}
public abstract class ConfirmDialogDecorator<C extends BaseController, M> extends SearchDetailView<C, M> {
public void showDialog(final String message) { [...] }
}
public class MyView extends ConfirmDialogDecorator<MyController, MyModel> {
[...]
}
But I'd like to separate ConfirmDialogDecorator
from SearchDetailView
. Any idea? Thanks.
Aucun commentaire:
Enregistrer un commentaire