动态消息显示

时间:2015-06-03 11:42:45

标签: jsf

Set<String> testPopUp = new HashSet<String>()
 //getter
  public Set<String> gettestPopUp() {
        return testPopUp;
    }
//setter
 public void settestPopUp(Set<String> testPopUp ) {
        this.testPopUp = testPopUp ;
 }

<h:alertPopup id="popupMessagesId" title="Error" message="#{testBean.testPopUp }" icon="info">
<h:a4jButton id="popUp" value="Ok" onclick="javascript:Richfaces.hideModalPanel('popupMessagesId')"/>                       
</h:alertPopup> 

现在我的Java代码:

TestBean.java:

public void test(){ 
 //validation methods 
 testPopUp.add("This is an error");
 AjaxCommandBean.showPopupOnComplete("popupMessagesId");
 }

现在,弹出窗口显示NULL值,因为在加载页面时会调用getter:gettestPopUp(),那时testPopUp将为NULL。只有在执行test()方法后才会填充testPopUp。因此,当我第二次加载页面时,我获得了价值。 请让我知道如何在弹出窗口中第一次获得该值。 我正在使用JSF2.0

0 个答案:

没有答案