Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.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 jsf2 selectonemenu提交值不带bean_Jsf 2_Selectonemenu_Commandlink - Fatal编程技术网

Jsf 2 jsf2 selectonemenu提交值不带bean

Jsf 2 jsf2 selectonemenu提交值不带bean,jsf-2,selectonemenu,commandlink,Jsf 2,Selectonemenu,Commandlink,我知道在没有托管bean的情况下实现这一点可能不是最好的做法。。。但我想这样做:) 我想ajax可能会有帮助,但我从未使用过 非常感谢您的帮助将您的值直接绑定到视图: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.co

我知道在没有托管bean的情况下实现这一点可能不是最好的做法。。。但我想这样做:)


我想ajax可能会有帮助,但我从未使用过

非常感谢您的帮助

将您的
值直接绑定到视图:

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">

<h:form>
    <h:selectOneMenu value="#{selected}">
        <f:selectItem itemValue="1" itemLabel="A" />
        <f:selectItem itemValue="2" itemLabel="B" />
        <f:selectItem itemValue="3" itemLabel="C" />
    </h:selectOneMenu>

    <h:commandLink value="click" action='#{myBean.action(selected)}' />
</h:form>

</html>

可能重复:这就是bean的方式:-/我需要一个没有bean的。Ajax、Richfaces和webflow是允许的,但我没有使用它们的经验。您是否使用SpringMVC作为视图层框架?不要把一切都混在一起,那样会使事情变得更复杂。Richfaces是一个JSF组件库,将它与其他框架一起使用是一种过火的做法。不是SpringMVC而是SpringWebFlow(SWF),SpringMVC和JSF不是很好的组合,但SWF和JSF配合得很好。。。至少有人告诉我了。RichFaces更好,AjaxI不会建议您使用SWF,因为JSF有自己的导航管理。如果它是一个遗留项目,你可以考虑它,否则你要建立一个新的项目,丢弃它。JSF管理组件、视图状态和导航,是一个完整的MVC框架。除此之外,如果不使用bean,您希望在这里使用什么来处理您的POST请求?遗憾的是,这是一个遗留项目,有很多页面可以切换。我想让它像:一样工作,但我无法让它与selectonemenu一起工作:(
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">

<h:form>
    <h:selectOneMenu value="#{selected}">
        <f:selectItem itemValue="1" itemLabel="A" />
        <f:selectItem itemValue="2" itemLabel="B" />
        <f:selectItem itemValue="3" itemLabel="C" />
    </h:selectOneMenu>

    <h:commandLink value="click" action='#{myBean.action(selected)}' />
</h:form>

</html>