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
JSF2.0Ajax命令按钮仅执行_Ajax_Jsf 2 - Fatal编程技术网

JSF2.0Ajax命令按钮仅执行

JSF2.0Ajax命令按钮仅执行,ajax,jsf-2,Ajax,Jsf 2,我想用ajax执行一个简单的命令,但不需要任何输入。 这是我的代码: <h:form> <h:commandButton class="button" value="Invite" action="#{trainingController.inviteProfile(p)}"> </h:commandButton> </h:form>

我想用ajax执行一个简单的命令,但不需要任何输入。 这是我的代码:

<h:form>
      <h:commandButton class="button" 
                       value="Invite"
                       action="#{trainingController.inviteProfile(p)}">
      </h:commandButton>
</h:form>

变量p来自a,它也是通过ajax请求填充的。
有什么想法可以实现我的目标吗?

您可以使用
f:ajax
进行归档。 示例如下所示

XHTML

您可以从这里看到有关EL库的更多信息,这是如何检查EL is服务器的版本

<?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:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Submit</title>
    </h:head>

    <h:body>
        <h:form>
            <h:commandButton value="Submit" 
                             action="#{coffeeBean.submit('abc')}">
                <f:ajax execute="@this" 
                        render="@this" />
            </h:commandButton>
        </h:form>
    </h:body>

</html>
@ManagedBean(name = "coffeeBean")
@SessionScoped
public class CoffeeBean implements Serializable {

    public void submit(String s){
        System.out.println("s:" + s);
    }
}