JSF2.0Ajax命令按钮仅执行
我想用ajax执行一个简单的命令,但不需要任何输入。 这是我的代码: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>
<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);
}
}