Я использую PrimeFaces 5.
Я хотел бы открыть диалоговое окно при нажатии кнопки.
<p:commandButton value="add upload" actionListener="#{theForm.openUpload}" >
public void openUpload() {
this.item = new Item();
RequestContext.getCurrentInstance().openDialog("uploadForm");
}
There will be a save button in the dialog to save the inputs.
<h:commandButton value="#{text['button.add']}" id="add" styleClass="btn btn-default" actionListener="#{theForm.confirmAdd}"/>
public void confirmAdd() {
RequestContext.getCurrentInstance().closeDialog("uploadForm");
}
My managed bean is @ViewScoped
. Will the command button break the view scope if the dialog is in an external file as done by PrimeFaces Dialog Framework? Whenever I click the "add upload" button, the @PostConstruct
method is called again just like the scope is lost.
В разделе комментариев официального блога говорится, что это не нарушит область представления, но здесь форум основного разработчика говорит, что openDialog()
создает новое представление, поэтому оно нарушает представление объем.
Кто-нибудь может это подтвердить?
javax.faces.bean.ViewScoped
ломается при некоторых обстоятельствах. (См. также balusc.blogspot.de/2010/06. /) Если вы используете CDI, вам следует переключиться наjavax.faces.view.ViewScoped
— это работает, как и ожидалось. - person dognose   schedule 22.10.2014