Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 如何从orderlist传递所选对象并在服务器端提交_Jsf 2_Primefaces - Fatal编程技术网

Jsf 2 如何从orderlist传递所选对象并在服务器端提交

Jsf 2 如何从orderlist传递所选对象并在服务器端提交,jsf-2,primefaces,Jsf 2,Primefaces,我正在使用primefaces orderlist,我已经设法从后端获取orderlist,现在我已经从orderist中选择了一个项目,并且必须将其发送到服务器端进行查询。。我已经发布了上面的代码来实现这一点。。由于用户对象为空,我面临问题。。如何从orderlist发送所选项目并通过服务器发送该项目也请向我解释该过程=“@this”。我使用的是PrimeFaces3.4.2和JSF2WebSphere8 提前感谢p:orderList不是一个数据组件。您不能像那样将数据发送到后端。检查。尝试

我正在使用primefaces orderlist,我已经设法从后端获取orderlist,现在我已经从orderist中选择了一个项目,并且必须将其发送到服务器端进行查询。。我已经发布了上面的代码来实现这一点。。由于用户对象为空,我面临问题。。如何从orderlist发送所选项目并通过服务器发送该项目也请向我解释该过程=“@this”。我使用的是PrimeFaces3.4.2和JSF2WebSphere8


提前感谢

p:orderList不是一个数据组件。您不能像那样将数据发送到后端。检查。尝试使用dataTable并在其中显示值。您可以对dataTable使用f:setPropertyActionListener

也要了解@this check this


编辑:选中primefaces以使用datatable传递数据,也可以使用selectOneListbox。唯一的区别是,您必须自己实施订购


Ya我同意@hemanth,我现在删除了orderList和used data table,但data table的选定对象将变为null。。SelectEvent事件,此处事件即将发生,但event.getObject引发空指针异常。。我还使用了数据表的selection属性,我做错了什么?您是否使用f:setPropertyActionListener来设置数据?或者可以使用p:dataTable的“selection”属性。请参阅我提供的演示链接。如果在这里发布代码不起作用,我解决了这个问题,我没有在数据表中添加row-key属性。
<h:panelGrid columns="2">
                        <h:outputText value="Search Results List"/>
                        <p:commandButton value="Add user" process="@this" styleClass="btn-primary" style=" margin-bottom: 20px;margin-left: -80px;width:75px;" action="#{testBean.addUser(user)}"/>
                        <p:orderList styleClass="resultBox" style="color: #263F6A;" var="user" value="#{testBean.contacts}" 
                            itemLabel="#{user.firstName}"  itemValue="#{user.firstName}" controlsLocation="none">
                        </p:orderList>
                    </h:panelGrid>