0
我在所有的jsf页面中都有相同的标准工具栏,其中包含保存,新建,搜索等操作,并且我正在寻找一种重构它的方法在一个xhtml页面中并将其包含在每个页面中,问题是每个页面都有它自己的viewscoped managedbean,并且命令按钮操作与每个页面有关。用每个页面的自定义逻辑重构一个常见的JSF工具条
每个managedbean实现下面的界面,表示动作
public interface ActionAbstract {
public void search(ActionEvent actionEvent);
public void newRecord(ActionEvent actionEvent);
public void clear(ActionEvent actionEvent);
public void remove(ActionEvent actionEvent);
public void searchAdvanced(ActionEvent actionEvent);
public void back(ActionEvent actionEvent);
public void closePage(ActionEvent actionEvent);
public void validate(ActionEvent actionEvent);
public void duplicate(ActionEvent actionEvent);
public void refresh(ActionEvent actionEvent);
}
托管Bean:
@ViewScoped
@ManagedBean
public class ExampleBean implements ActionAbstract
工具栏XHTML:
<p:toolbar>
<f:facet name="left">
<p:commandButton title="New" update="@all" icon="fa fa-plus" actionListener="#{ExampleBean.newRecord}" process="@this" />
<p:commandButton title="Search" update="@all" icon="fa fa-search" actionListener="#{ExampleBean.search}" rendered="#{ExampleBean.showTable}"
process="@this" />
<p:commandButton title="Advanced Search" icon="fa fa-search-plus" actionListener="#{ExampleBean.searchAdvanced}"
rendered="#{ExampleBean.showTable}" process="@this" />
<p:commandButton title="Clear" icon="fa fa-eraser" actionListener="#{ExampleBean.clear}" rendered="#{ExampleBean.showTable}" process="@this" />
<p:commandButton title="Duplicate" icon="fa fa-copy" actionListener="#{ExampleBean.duplicate}" rendered="#{ExampleBean.showDetail}"
process="@this" />
<p:commandButton title="Validate" icon="fa fa-check" actionListener="#{ExampleBean.validate}" rendered="#{ExampleBean.showDetail}"
process="@this" />
<p:commandButton title="Remove" icon="fa fa-remove" actionListener="#{ExampleBean.remove}" rendered="#{ExampleBean.showDetail}" process="@this" />
<p:commandButton title="Refresh" icon="fa fa-refresh" actionListener="#{ExampleBean.refresh}" process="@this" />
<p:commandButton title="Back" update=":form" icon="fa fa-arrow-left" actionListener="#{ExampleBean.back}" rendered="#{ExampleBean.showDetail}"
process="@this" />
<p:commandButton title="Close" icon="fa fa-sign-out" actionListener="#{ExampleBean.closePage}" process="@this" />
</f:facet>
它possibl e重构它??? !!!非常感谢您的帮助。