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重構它??? !!!非常感謝您的幫助。