来自表单选择菜单的数据从jsf / html表单作为null传递

问题描述 投票:0回答:1

我目前难以传递当用户选择一个选择项并单击“提交”按钮时填充的操作变量的值,应将其写入日志中,并且不返回空值

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

我目前难以传递当用户选择一个选择项并单击“提交”按钮时填充的操作变量的值,应将其写入日志中,并且不返回空值

// 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;
        }
    }
jsf managed-bean
1个回答
0
投票

                                <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>
© www.soinside.com 2019 - 2024. All rights reserved.