如何根据p:picklist的选择动态生成inputText字段?

时间:2015-11-17 19:05:10

标签: ajax jsf primefaces

我有一个场景,我必须针对同一页面中<pickList>的每个选项生成输入文本字段。我正在使用PrimeFaces 5.2和JSF 2.2。 请建议。

1 个答案:

答案 0 :(得分:4)

回答:

Proof that it works

XHTML:

 <p:pickList id="PojoPickList"
      value="#{editRoleAction.funcFieldDTO}" var="trnxDto"
      effect="bounce" itemValue="#{trnxDto.fieldValue}"
      itemLabel="#{trnxDto.fieldName}" showSourceControls="true"
      showTargetControls="true" converter="pickListConverter">
      <p:ajax event="transfer" update="@form"
        listener="#{editRoleAction.transactionTransferToDestination}" />
      <f:facet id="idar556" name="sourceCaption">#{msg.LBL_AVALIABLE_ROLES}     </f:facet>
    <f:facet id="idar557" name="targetCaption">#{msg.LBL_SELECTED_ROLES}</f:facet>
</p:pickList>




   <h:panelGrid id="myGrid" width="400px;">
     <p:dataTable value="#{editRoleAction.moduleTransactionList}" rendered="#{editRoleAction.moduleTransactionList.size() gt 0}" var="mainMenu">
        <p:column>
          <h:panelGrid columns="2">
            <h:outputText value="Price of #{msg[mainMenu.labelId]}"/>
            <p:inputText value="#{mainMenu.kioskType}"/>
          </h:panelGrid>

        </p:column>
     </p:dataTable>

   </h:panelGrid>

爪哇:

  public void transactionTransferToDestination() {
        List<FunctionalityFieldDTO> destTrnx = funcFieldDTO.getTarget();
        for (FunctionalityFieldDTO dto : destTrnx) {
              moduleTransactionList.add(dto);
        }
  }
相关问题