2011-07-21 5 views
2
<f:view> 
<h:form> 
    <h:panelGrid> 
    <f:facet name="header"> 
    <h:outputText value="Create Order"/> 
    </f:facet> 
    <h:column> 
    <h:outputText value="Customer Number : "></h:outputText> 
    <h:inputText value="#{SalesCreate.orderBean.customerNumber}"/> 
    </h:column> 
    <h:column> 
    <h:outputText value="Create With : "></h:outputText> 
    <h:selectOneMenu id="createWith" value="#{SalesCreate.orderBean.createWith}"> 
     <f:selectItem itemLabel="Without Reference" itemValue="noRef"/> 
     <f:selectItem itemLabel="Reference" itemValue="ref"/>        
    </h:selectOneMenu> 
    </h:column>   
    <h:column> 
    <h:outputText value="Reference By : "></h:outputText> 
     <h:selectOneMenu id="refBy" value="#{SalesCreate.orderBean.referenceBy}"> 
     <f:selectItem itemLabel="Quotation" itemValue="quotation"/> 
     <f:selectItem itemLabel="Contract" itemValue="contract"/> 
     </h:selectOneMenu> 
    </h:column> 
    <h:column> 
    <h:outputText value="Inquiry Reference Number : "></h:outputText> 
     <h:inputText id="docNum" value="#{SalesCreate.orderBean.referenceNum}"/> 
     <h:commandButton value="..." onclick="javascript:popUp('OpenRef.jsp',this)">       
     </h:commandButton> 
     <h:commandButton value="Load" action="#{SalesCreate.getQuotationListFromDb}">     </h:commandButton>       
    </h:column>   
    </h:panelGrid> 
    </h:form> 
</f:view> 

以上がselectOneMenuが含まれている私のJSPであるから値を取得し、私は、ユーザーが前のフィールドでwithReferenceを選択した場合にのみ、フィールドreferenceByを有効にしようとしています。また、referenceByの値に応じて、ポップアップの値が異なっている、つまり、idユーザーがをquotationと選択した場合、ポップアップの値はquotationに関連する必要があります。 ポップアップJSPには、データベースの値を持つデータテーブルが含まれています。selectOneMenu JSF

答えて

2

使用<f:ajax>新しいJSF 2.0のAjaxの力の助けを借りて、最初のドロップダウンの変更に再レンダリング2番目のドロップダウンにと最初のドロップダウンの値がrefないときに2番目のドロップダウンを無効にするdisabled属性を使用します。

<h:selectOneMenu id="createWith" value="#{SalesCreate.orderBean.createWith}"> 
    <f:selectItem itemLabel="Without Reference" itemValue="noRef"/> 
    <f:selectItem itemLabel="Reference" itemValue="ref"/> 
    <f:ajax render="refBy" /> 
</h:selectOneMenu> 
... 
<h:selectOneMenu id="refBy" value="#{SalesCreate.orderBean.referenceBy}" disabled="#{SalesCreate.orderBean.createWith != 'ref'}"> 
    <f:selectItem itemLabel="Quotation" itemValue="quotation"/> 
    <f:selectItem itemLabel="Contract" itemValue="contract"/> 
</h:selectOneMenu> 
+0

返信いただきありがとうございます...しかし、また、私はポップアップに2番目のドロップダウンの値を渡す際に私を助けることができます – Mango

関連する問題