簡體   English   中英

表單選擇菜單中的數據從jsf / html表單傳遞為null

[英]data from form select menu being passed as null from jsf/html form

我目前在傳遞用戶選擇一個選擇項並單擊“提交”按鈕時應填充的操作變量的值時遇到困難,應該將其寫入日志中,而不返回null

Value passed using FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); is returning as null, when the first xhtml form is submited

the objective is to pass the value of a selected selection menu from XHTML form1  to XHRML form2 using a managed bean method on the click of a submit button on form1

我目前在傳遞用戶選擇一個選擇項並單擊“提交”按鈕時應填充的操作變量的值時遇到困難,應該將其寫入日志中,而不返回null

// form1 starts here
 <h:form>
                                        <select id="inputCategory" data-animate-value="#{quickTellerGetCategoryClientBean.inputCategory}" >
                                            <option value="#{null}" Label="-- select one --"/>

                                            <h:dataTable
                                                    value="#{quickTellerGetCategoryClientBean.getCategoryNamesList()}"
                                                    var="item" >

                                                <h:column style="text-align: left">


                                                    <option value="#{item}" label="#{item}" />

                                                </h:column>
                                            </h:dataTable>
                                            <f:param name="action" value="#{item}" />

                                        </select>
                                        <h:commandButton value="Get All Billers" action="#{quickTellerGetCategoryClientBean.chkMe()}">


                                        </h:commandButton>
                                        <h2><h:outputText id="GetCategoryOutput"
                                      value="#{quickTellerGetCategoryClientBean.getSelectedAction()}"/>
                                    </h2>
 </h:form>

// form2 starts here
              <p>
                                        <h:outputText
                                                value="#{quickTellerGetCategoryClientBean.getAttrListener()}" />
                                    </p>
                                    <h:form>

//managed bean starts here

    String attrListener;
    private String inputCategory;


    public String chkMe() {
        return takeMeToAnotherPage("QuickTeller2");
    }

    public String takeMeToAnotherPage(String linkToGo) {
        return linkToGo + "?faces-redirect=true";
    }


    public void setAttrListener(String attrListener) {
        this.attrListener = attrListener;
    }

    //action listener event
    public String getAttrListener() {
        LOGGER.debug("<< inside >attrListener>" );

        Map<String, String> params =
                FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
        action = params.get("action");
        LOGGER.debug("action  is " + action);

        if ("".equals(action) || action == null) {
            return "";
        } else {
            return action;
        }
    }

                                <h:selectOneMenu
                                        value="#{quickTellerGetCategoryClientBean.inputCategory}"
                                        id="CategorySelected">
                                    <f:selectItem itemLabel="Select..." noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{quickTellerGetCategoryClientBean.getCategoryNamesList()}"> </f:selectItems>
                                    <f:ajax execute="CategorySelected"/>
                                </h:selectOneMenu>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM