JSF组合框更改为默认值



我有一个JSF应用程序,其中有一个组合框。基于这个组合框值,我想更改另外两个组合框值。

<h:outputText value="#{msgs.transformation_rule}"/>
      <h:panelGroup>
          <h:selectOneMenu id="dsTransformationRule" value="#{activityDataSource.selectedTransformationRule}"
                           disabled="#{!sp:hasRight(facesContext, 'ManageApplication')}"
                           readonly="#{!sp:hasRight(facesContext, 'ManageApplication')}">
            <f:selectItems value="#{activityDataSource.transformationRules}"/>
          </h:selectOneMenu>
          <ui:fragment rendered="#{sp:hasRight(facesContext, 'ManageRules')}" >
              <input type="button" value="#{msgs.button_ellipsis}" class="ruleEditorBtn"
                     onclick="SailPoint.Rule.Editor.edit($('editForm:dsTransformationRule').value,
                             'ActivityTransformer',
                             $('editForm:refreshActivityDataSourceRulesButton'))" />
          </ui:fragment>
      </h:panelGroup>
      <h:outputText value="#{msgs.correlation_rule}"/>
      <h:panelGroup>
          <h:selectOneMenu id="dsCorrelationRule" value="#{activityDataSource.selectedCorrelationRule}"
                           disabled="#{!sp:hasRight(facesContext, 'ManageApplication')}"
                           readonly="#{!sp:hasRight(facesContext, 'ManageApplication')}">
            <f:selectItems value="#{activityDataSource.correlationRules}"/>
          </h:selectOneMenu>
          <ui:fragment rendered="#{sp:hasRight(facesContext, 'ManageRules')}" >
              <input type="button" value="#{msgs.button_ellipsis}" class="ruleEditorBtn"
                     onclick="SailPoint.Rule.Editor.edit($('editForm:dsCorrelationRule').value,
                             'ActivityCorrelation',
                             $('editForm:refreshActivityDataSourceRulesButton'))" />
          </ui:fragment>
      </h:panelGroup>
      <h:outputText value="#{msgs.activity_data_src_type}"/>
      <h:panelGroup>
        <a4j:outputPanel id="collectorSettings">
          <h:selectOneMenu id="collectorType"
                           value="#{activityDataSource.object.type}"
                           rendered="#{empty activityDataSource.object.id}"
                           disabled="#{!sp:hasRight(facesContext, 'ManageApplication')}"
                           readonly="#{!sp:hasRight(facesContext, 'ManageApplication')}"
                           onchange="$('editForm:selectTypeButton').click();">
             <f:ajax event="change" 
                    execute="@this" 
                    render="dsTransformationRule dsCorrelationRule"
                    listener="#{activityDataSource.handleCollectorTypeChange}" />
            <f:selectItem itemValue="" itemLabel="#{msgs.select_collector_type}"/>
            <f:selectItems value="#{activityDataSource.collectorTypes}"/>
          </h:selectOneMenu>
          <h:selectOneMenu id="fixedCollectorType" value="#{empty activityDataSource.object.type ? 'None' : activityDataSource.object.type}"
                           rendered="#{not empty activityDataSource.object.id}"
                           disabled="true"
                           readonly="true">
            <f:selectItem itemValue="#{empty activityDataSource.object.type ? 'None' : activityDataSource.object.type}"
                          itemLabel="#{empty activityDataSource.object.type ? msgs.none : activityDataSource.object.type}"/>
          </h:selectOneMenu>
        </a4j:outputPanel>

<a4j:commandButton id="selectTypeButton" action="#{activityDataSource.selectType}" style="display:none"
                       render="configSettings, collectorSettings"
                       oncomplete="initializeSelectedConfigPage();"/>

现在的问题是我不能理解

onchange="$('editForm:selectTypeButton').click();">

我已经为collectorType的更改事件编写了ajax部分,在其中我正在更改其他两个组合框的值。此外,我希望对于collectorType中的一个值,其他两个组合框应更改为默认文本,如"选择收集器类型"。我该怎么做。

此外,ajax事件在正常更改事件之前启动。

Richfaces和Primefaces的原理相同。您的ajax调用应该更新其他backingbeans的当前值

此ajax调用将更新当前俱乐部。

<p:ajax event="change" execute="@this" listener="#{serviceHCP.getClubs(player)
serviceHCP.myCurrentClub // Will be set and used in the next menu.
<p:selectOneMenu value="#{player}"
                converter="playerConverter" id="playerList">
            <f:selectItem itemLabel="---" noSelectionOption="true" />
            <f:selectItems value="#{servicePlayer.allPlayers}"
             var="n"
             itemValue="#{n}"
             itemLabel="#{n.combinedName}"
             itemLabelEscaped="true"/>
              <p:ajax event="change" execute="@this" listener="#{serviceHCP.getClubs(player) }" update="clubMenu" render="clubMenu"/>
            </p:selectOneMenu>
            <h:outputText value="Klubb"></h:outputText>
               <p:selectOneMenu value="#{serviceHCP.myCurrentClub}" converter="clubConverter" id="clubMenu" >
                    <f:selectItem itemLabel="---" noSelectionOption="true" />
                    <f:selectItems value="#{serviceHCP.myClubList}"
                 var="clb"
                 itemValue="#{clb}"
                 itemLabel="#{clb.name}"
                 itemLabelEscaped="true"/>
            </p:selectOneMenu>

相关内容

  • 没有找到相关文章

最新更新