【发布时间】:2017-12-01 02:12:57
【问题描述】:
我想从 Primefaces 对话框调用 Java 方法。我测试了这段代码:
<h:form>
<p:dialog header="New Sensor" widgetVar="dlg" focus="name" modal="true" showEffect="fade">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="name" value="Name" />
........
<p:inputText id="enabled" label="enabled" value="#{newSensor.sensor.enabled}" />
</h:panelGrid>
<f:facet name="footer">
<p:commandButton id="ajax" value="Create Sensor" styleClass="ui-priority-primary" type="button" actionListener="#{newSensor.saveRecord()}"/>
</f:facet>
</p:dialog>
</h:form>
Java 豆:
@Named
@RequestScoped
public class NewSensor implements Serializable
{
private SensorObj sensor = new SensorObj();
public SensorObj getSensor()
{
return sensor;
}
public void setSensor(SensorObj sensor)
{
this.sensor = sensor;
}
public void saveRecord(){
System.out.println(">>>>>>>!!!!!! " + sensor.getName());
}
}
当我单击按钮时,没有任何反应。您能给我一些建议如何解决这个问题吗?
【问题讨论】:
-
有时添加属性 process="@this" 解决了我的问题
-
你看到这个帖子Update from dialog了吗?!? (见第三种解决方案)
-
@YagamiLight:#3 是一个非常奇怪的解决方案...非常...为什么不直接删除
type="button"???
标签: jsf primefaces jsf-2