Jsf 选择一个可编辑的菜单=";“真的”;,使用Primefaces选择项目组会错误地提交标签而不是值

Jsf 选择一个可编辑的菜单=";“真的”;,使用Primefaces选择项目组会错误地提交标签而不是值,jsf,primefaces,Jsf,Primefaces,使用来自的示例 MyShopOrder.java package org.primefaces.test; import java.io.Serializable; public class MyShopOrder implements Serializable { private static final long serialVersionUID = 1L; private String shopOrder; private String shortDesci

使用来自的示例

MyShopOrder.java

package org.primefaces.test;

import java.io.Serializable;

public class MyShopOrder implements Serializable {
    private static final long serialVersionUID = 1L;


    private String shopOrder;
    private String shortDesciption;
    ...setters/getters
}
page.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui" xmlns:pe="http://primefaces.org/ui/extensions" xmlns:o="http://omnifaces.org/ui" xmlns:of="http://omnifaces.org/functions">
<h:head>
    <f:facet name="first">
        <meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
    </f:facet>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />

    <title><ui:insert name="title">PF8 Test</ui:insert></title>

</h:head>

<h:body>
    <h:outputStylesheet name="primeicons/primeicons.css" library="primefaces" />
    <h:outputStylesheet library="css" name="screen.css" />

    <f:metadata>
        <f:viewAction action="#{myView.init()}" onPostback="false" />
    </f:metadata>

    <h2>Select Item Groups with editable Select One Menu</h2>
    <h:form id="editableId">
        <p:selectOneMenu id="so3" value="#{myView.input1}" editable="true">
            <f:selectItem noSelectionOption="true" itemLabel="Select a Shop Order" itemValue="null" />
            <f:selectItems value="#{myView.availableShopOrders}" />
        </p:selectOneMenu>
        <br />
        <p:commandButton value="Submit Select Item Group with edit=true" action="#{myView.submitIt1()}" />
    </h:form>

    <hr />
    <br />
    <br />
    <h2>Select Item Groups with non-editable Select One Menu</h2>
    <h:form id="notEditableId">
        <p:selectOneMenu id="so3" value="#{myView.input2}" editable="false">
            <f:selectItem noSelectionOption="true" itemLabel="Select a Shop Order" itemValue="null" />
            <f:selectItems value="#{myView.availableShopOrders}" var="aso" />
        </p:selectOneMenu>
        <br />
        <p:commandButton value="Submit Select Item Group with edit=false" action="#{myView.submitIt2()}" />
    </h:form>


    <hr />
    <br />
    <br />
    <h2>Without Select Item Groups with editable Select One Menu</h2>
    <h:form id="noGroupsEditableId">
        <p:selectOneMenu id="so3" value="#{myView.input3}" editable="true">
            <f:selectItem noSelectionOption="true" itemLabel="Select a Shop Order" itemValue="null" />

            <f:selectItem noSelectionOption="true" itemLabel="---Saved Favorites" itemValue="null" />
            <f:selectItems value="#{myView.mySavedShopOrders}" var="shopOrder"
                itemLabel="#{shopOrder.shopOrder} #{shopOrder.shortDesciption != null ? '('.concat(shopOrder.shortDesciption).concat(')') : '' }" itemValue="#{shopOrder.shopOrder}" />

            <f:selectItem noSelectionOption="true" itemLabel="---Recently Used Non-Favorites" itemValue="null" />
            <f:selectItems value="#{myView.recentlyUsedShopOrders}" var="shopOrder" itemLabel="#{shopOrder}" itemValue="#{shopOrder}" />

        </p:selectOneMenu>
        <br />
        <p:commandButton value="Submit without Select Item Group with edit=true" action="#{myView.submitIt3()}" />
    </h:form>


</h:body>
</html>

我已提交本期:

我计划为PF 9.0修复它

集成测试:


PR:

您能使用PrimeFaces测试项目创建一个可复制的小示例,以便我调试它吗?请参阅:@Melloware谢谢,我下载了测试项目并添加了代码MyView.java和page.xhtml,其行为与此相同。提交的值是selectonemenu可编辑时的标签。您能在某处发布指向该值的链接,以便我可以获取并运行它吗?代码位于公司内部服务器上。我没有外部存储库。我所做的只是将MyView.java添加到org.primefaces.test,将page.xhtml添加到webapp文件夹。我已经确认了您的问题。我不知道这是否符合设计。因为项目是可编辑的,这意味着它必须提交标签,所以如果您输入的值不在列表中,例如“Foo”,则没有要提交的值。PF showcase使用的城市的值与标签相同,这就是为什么它没有显示问题。这是这个问题的回归:酷!谢谢,我真的很感激!好的,我添加了一个集成测试来捕捉这一点,并提交了一份PR。感谢您的报道!
package org.primefaces.test;

import java.io.Serializable;

public class MyShopOrder implements Serializable {
    private static final long serialVersionUID = 1L;


    private String shopOrder;
    private String shortDesciption;
    ...setters/getters
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:p="http://primefaces.org/ui" xmlns:pe="http://primefaces.org/ui/extensions" xmlns:o="http://omnifaces.org/ui" xmlns:of="http://omnifaces.org/functions">
<h:head>
    <f:facet name="first">
        <meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
    </f:facet>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />

    <title><ui:insert name="title">PF8 Test</ui:insert></title>

</h:head>

<h:body>
    <h:outputStylesheet name="primeicons/primeicons.css" library="primefaces" />
    <h:outputStylesheet library="css" name="screen.css" />

    <f:metadata>
        <f:viewAction action="#{myView.init()}" onPostback="false" />
    </f:metadata>

    <h2>Select Item Groups with editable Select One Menu</h2>
    <h:form id="editableId">
        <p:selectOneMenu id="so3" value="#{myView.input1}" editable="true">
            <f:selectItem noSelectionOption="true" itemLabel="Select a Shop Order" itemValue="null" />
            <f:selectItems value="#{myView.availableShopOrders}" />
        </p:selectOneMenu>
        <br />
        <p:commandButton value="Submit Select Item Group with edit=true" action="#{myView.submitIt1()}" />
    </h:form>

    <hr />
    <br />
    <br />
    <h2>Select Item Groups with non-editable Select One Menu</h2>
    <h:form id="notEditableId">
        <p:selectOneMenu id="so3" value="#{myView.input2}" editable="false">
            <f:selectItem noSelectionOption="true" itemLabel="Select a Shop Order" itemValue="null" />
            <f:selectItems value="#{myView.availableShopOrders}" var="aso" />
        </p:selectOneMenu>
        <br />
        <p:commandButton value="Submit Select Item Group with edit=false" action="#{myView.submitIt2()}" />
    </h:form>


    <hr />
    <br />
    <br />
    <h2>Without Select Item Groups with editable Select One Menu</h2>
    <h:form id="noGroupsEditableId">
        <p:selectOneMenu id="so3" value="#{myView.input3}" editable="true">
            <f:selectItem noSelectionOption="true" itemLabel="Select a Shop Order" itemValue="null" />

            <f:selectItem noSelectionOption="true" itemLabel="---Saved Favorites" itemValue="null" />
            <f:selectItems value="#{myView.mySavedShopOrders}" var="shopOrder"
                itemLabel="#{shopOrder.shopOrder} #{shopOrder.shortDesciption != null ? '('.concat(shopOrder.shortDesciption).concat(')') : '' }" itemValue="#{shopOrder.shopOrder}" />

            <f:selectItem noSelectionOption="true" itemLabel="---Recently Used Non-Favorites" itemValue="null" />
            <f:selectItems value="#{myView.recentlyUsedShopOrders}" var="shopOrder" itemLabel="#{shopOrder}" itemValue="#{shopOrder}" />

        </p:selectOneMenu>
        <br />
        <p:commandButton value="Submit without Select Item Group with edit=true" action="#{myView.submitIt3()}" />
    </h:form>


</h:body>
</html>
[INFO] Started Jetty Server
input1 submitted is: Group 1 Label 3
input2 submitted is: Group 2 Value 1
input3 submitted is: Typed In Value
input3 submitted is: My SO Value 1
input3 submitted is: Non-Favorite Value 1