質問があります同じページにある他のコンポジットコンポーネントをどのように更新できますか?顧客IDを入力して「検索」ボタンをクリックすると、データベース内で顧客を検索し、存在する場合は顧客IDのケースベースの検索を続行します。およびその逆。他のJSFコンポジットコンポーネントの更新
この例では、関係Customer:Caseが1:1であるとします。
main_page.xhtml
<h:body>
<ui:composition template="/WEB-INF/template/layout.xhtml">
<ui:define name="content">
<custom:component_customer
customerId="#{mainPageController.customer.id}"
searchCustomer="#{mainPageController.searchCustomer}"
/>
<custom:component_case
caseaseId="#{mainPageController.case.caseId}"
searchCase="#{mainPageController.searchCase}"
/>
</ui:define>
</ui:composition>
</h:body>
component_customer.xhtml
<composite:interface>
<composite:attribute name="customerId" type="java.lang.Long"/>
<composite:attribute name="searchCustomer" method-signature="void searchCustomer()"/>
</composite:interface>
<composite:implementation>
<h:form>
<h:inputText id="id" value="#{cc.attrs.customerId}"/>
<h:commandButton value="Search" action="#{cc.attrs.searchCustomer}"/>
</h:form>
</composite:implementation>
component_case.xhtml
<composite:interface>
<composite:attribute name="caseId" type="java.lang.Long"/>
<composite:attribute name="searchCase" method-signature="void searchCase()"/>
</composite:interface>
<composite:implementation>
<h:form>
<h:inputText id="id" value="#{cc.attrs.caseId}"/>
<h:commandButton value="Search" action="#{cc.attrs.searchCase}"/>
</h:form>
</composite:implementation>
MainPageController.java
@ManagedBean
@ViewScoped
public class MainPageController {
@EJB
private CaseLogic caseLogic;
@EJB
private CustomerLogic customerLogic;
private Customer customer = new Customer();
private Case case = new Case();
// getter & setters
public void searchCustomer() {
}
public void searchCase() {
}
1)一般的な「JSF」ソリューションはありますか?
2)または、どういうわけか、Javaコードでオブザーバーデザインパターンを実装する必要がありますか?しかし、多くのオブザーバー(Customer、Case、...)には多くのサブジェクト(MainPageController、SecondPageController、...)が存在するという問題があります。
OK、コンポーネントケースをラップしました: ... h:panelGroup>。しかし、「IDを検索に使用して属性を更新する」と「その属性をコマンドボタンで使用する」という意味ですか? –
Ziletka
遅く返事を申し訳ありません。私は休暇中です。最初にパネルに必要なものをフォームの中に入れる必要があります。次に、更新するアイテムを表す文字列を取り込むコンポーネントの新しいパラメータを作成します。その文字列をコマンドボタンの更新属性に入力します。 – mosgjig
私はまだ戦っています。しかし別の質問:standartに属性 "update"がありますか?または、私はPrimeFaces commandButtonなどを使用する必要がありますか? –
Ziletka