【发布时间】:2020-03-05 05:07:34
【问题描述】:
网页:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="../../Template/template.xhtml">
<ui:define name="content">
<h:form>
<h:outputText id="montest" value="#{ProviderLogin.i}"/>
<button class="ZWButtonActionIntervention pfButtonWhite" type="button" onclick="testpageRC()"/>
<span>TESTING</span>
</button>
<p:remoteCommand name="testpageRC" process="@this" update="montest" action="#{ProviderLogin.TESTING()}"/>
<p:commandButton styleClass="ZWButtonActionIntervention pfButtonOrange" value="#{GestionIntervention.m_typeNonTraitee}" action="#{ProviderLogin.TESTING()}"/>
</h:form>
</ui:define>
</ui:composition>
</h:body>
我的 java 类(Bean)
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
@SessionScoped
@ManagedBean(name="ProviderLogin")
public class ProviderLogin implements Serializable
{
private int i;
public int getI(){return i;}
public void TESTING(){i++;}
}
我在函数“TESTING()”中有一个断点
当我按下 'p:commandButton' 时,到达断点
当我按下“按钮”(调用p:remoteCommand)时,没有到达断点
真正奇怪的是,'p:remoteCommand' 适用于此:update="montest"
但是,bean 中的方法没有被触发。
顺便说一句,当我开始写 #{... 时,我可以访问我的 bean(变量和方法)
我使用 Primefaces 6.2
【问题讨论】:
-
<button>不应该是 primefaces 的一部分。试试<p:button> -
@XtremeBaumer 我试过了,但是当页面加载(onclick)时,一个 p:button 正在触发。这就是为什么我要使用 RemoteCommand 来调用 bean 方法。我使用一个简单的按钮元素,因为我需要一些特定的自定义
-
目前,问题更多的是“为什么我的 bean 方法没有调用 p:remoteCommand”,因为“update”属性有效,为什么 action 属性无效
标签: jsf primefaces remotecommand