将<f:param>用于selectOneMenu

时间:2018-08-13 12:58:45

标签: jsf primefaces

我正在将信息从selection.xhtml页发送到托管Bean到editInst方法中,然后将信息传递给stitutionEdit.xhtml页。除了selectOneMenu statusId外,所有数据都正确传递。

selection.xhtml

         <p:dataTable id="instDisplay" var="institutionData" paginator="true"
                                    rows="10" rowsPerPageTemplate="5,10,15,20,25,30"
                                    widgetVar="institutionDataTable" stickyHeader="true"
                                    filteredValue="#{institutionView.filteredInstitutionData}"
                                    emptyMessage="No institutions with given criteria"
                                    value="#{institutionView.institutionData}" selectionMode="single"
                                    selection="#{institutionView.selectedModel}"
                                    rowSelectListener="#{institutionView.onRowSelect}"
                                    rowKey="#{institutionData.institutionCode}" rowIndexVar="rowIndex">
                    ... columns ....
                <p:column>
                                <f:facet name="header">Edit</f:facet>
                                <p:commandButton value="Edit" action="#{institutionView.editInst}"
                                    icon="ui-icon-pencil">
                                    <f:param name="code" value="#{institutionData.institutionCode}" />
                                    <f:param name="desc" value="#{institutionData.institutionDesc}" />
                                    <f:param name="contactName" value="#{institutionData.institutionContactName}" />
                                    <f:param name="contactNumber" value="#{institutionData.institutionContactNumber}" />
                                    <f:param name="fL" value="#{institutionData.fileLiteral}" />
                                    <f:param name="status" value="#{institutionData.statusId}" />
                                    <f:param name="type" value="#{institutionData.institutionTypeId}" />
                                    <f:param name="shortName" value="#{institutionData.bankShortName}" />
                                    <f:param name="bankC" value="#{institutionData.bankCode}" />
                                    <f:param name="stream" value="#{institutionData.bankStreamCode}" />
                                    <f:param name="limit" value="#{institutionData.transactionLimit}" />
                                    <f:param name="file" value="#{institutionData.fileDel}" />
                                    <f:param name="load" value="#{institutionData.loadFunc}" />
                                    <f:param name="extract" value="#{institutionData.extractFunc}" />
                                    <f:param name="val" value="#{institutionData.validateFunc}" />
                                    <f:param name="ct" value="#{institutionData.cardThreshold}" />

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

ManagedBean

        public String editInst()
        {
            FacesContext fc = FacesContext.getCurrentInstance();
            Map<String, String> params = fc.getExternalContext().getRequestParameterMap();  

            String institutionCodeEdit = params.get("code");
            String institutionDescEdit = params.get("desc");
            String instContactName = params.get("contactName");
            String instContactNumber = params.get("contactNumber");
            String fileLiteralEdit = params.get("fL");
            String status = params.get("status");
            String typeId = params.get("type");
            String shortName = params.get("shortName");
            String bankCodeEdit = params.get("bankC");
            String streamCode = params.get("stream");
            String limit = params.get("limit");
            Long limitString = Long.parseLong(limit);
            String fileDel = params.get("file");
            String load = params.get("load");
            String extract = params.get("extract");
            String validate = params.get("val");
            String thresh = params.get("ct");
            Long threshold = Long.parseLong(thresh);

            InstitutionModel getEditModel = new InstitutionModel();

            getEditModel.setInstitutionCode(institutionCodeEdit);
            getEditModel.setInstitutionDesc(institutionDescEdit);
            getEditModel.setInstitutionContactName(instContactName);
            getEditModel.setInstitutionContactNumber(instContactNumber);
            getEditModel.setFileLiteral(fileLiteralEdit);
            getEditModel.setStatusId(status);
            getEditModel.setInstitutionTypeId(typeId);
            getEditModel.setBankShortName(shortName);
            getEditModel.setBankCode(bankCodeEdit);
            getEditModel.setBankStreamCode(streamCode);
            getEditModel.setTransactionLimit(limitString);
            getEditModel.setFileDel(fileDel);
            getEditModel.setLoadFunc(load);
            getEditModel.setExtractFunc(extract);
            getEditModel.setValidateFunc(validate);
            getEditModel.setCardThreshold(threshold);

            InstitutionModel editModel = new InstitutionModel();

            editModel.setInstitutionId(getEditModel.getInstitutionId());
            editModel.setInstitutionCode(getEditModel.getInstitutionCode());
            editModel.setInstitutionDesc(getEditModel.getInstitutionDesc());
            editModel.setInstitutionContactName(getEditModel.getInstitutionContactName());
            editModel.setInstitutionContactNumber(getEditModel.getInstitutionContactNumber());
            editModel.setFileLiteral(getEditModel.getFileLiteral());
            editModel.setStatusId(getEditModel.getStatusId());
            editModel.setInstitutionTypeId(getEditModel.getInstitutionTypeId());
            editModel.setBankShortName(getEditModel.getBankShortName());
            editModel.setBankCode(getEditModel.getBankCode());
            editModel.setBankStreamCode(getEditModel.getBankStreamCode());
            editModel.setTransactionLimit(getEditModel.getTransactionLimit());
            editModel.setFileDel(getEditModel.getFileDel());
            editModel.setLoadFunc(getEditModel.getLoadFunc());
            editModel.setExtractFunc(getEditModel.getExtractFunc());
            editModel.setValidateFunc(getEditModel.getValidateFunc());
            editModel.setCardThreshold(getEditModel.getCardThreshold());

            sessionMap.put("editInstitution", editModel);


            return "institutionEdit?faces-redirect=true";
        }

institutionEdit.xhtml

<p:panel id="institutionEdit" header="Edit Selected Institution.">
            <h:panelGrid columns="6" cellpadding="5">

<p:outputLabel for="fileLiteral" value="File Literal :" />
                <p:inputText id="fileLiteral" value="#{editInstitution.fileLiteral}"
                    required="true" label="File Literal" maxlength="45">
                </p:inputText>
                <p:message for="fileLiteral" display="icon" />

                <p:outputLabel for="statusId" value="Status Id: " />
                <p:selectOneMenu id="statusId" required="true"
                    value="#{institutionView.selectedStatusId}" style="width:140px">
                    <p:ajax listener="#{institutionView.onStatusIdChange}" />
                    <f:selectItem itemLabel="Select Status Id"
                        itemValue="#{editInstitution.statusId}" noSelectionOption="true" />
                    <f:selectItems value="#{institutionView.statusIdList}" />
                </p:selectOneMenu>
                <p:message for="statusId" display="icon" />

</h:panelGrid>
</p:panel>

我正在使用Java 8,JSF 2.3,Primefaces 6.1和Eclipse Oxygen。

0 个答案:

没有答案