1
我使用弹出窗口代码认证,在这里只以下组件:弹出窗口 - 执行操作并关闭
<h:inputText value="#{bean.masterKey.code}" />
<h:commandButton action="#{bean.checkMaster}" value="OK" type="submit"/>
按钮调用方法CHECKMASTER(),它设置的布尔变量真或假
public void checkMaster(){
if (findMasterKey(masterKey.getCode())) Settings.ONCOST = true;
else Settings.ONCOST = false;
}
但是我想在执行动作(每次按下按钮)后关闭弹出窗口。
但不知道如何..你能帮我吗?
更新:
public static boolean findMasterKey(String key)
{
Session session = DaoSF.getSessionFactory('R').openSession();
Criteria criteria = session.createCriteria(MasterType.class);
criteria.add(Restrictions.eq("code", key));
MasterType foundMT = (MasterType)criteria.uniqueResult();
if (foundMT != null) return true;
else return false;
}
哦,感谢快速回复。你能告诉我怎么样吗?我没有太多经验。或者没有一些更优雅的解决方案使用commandbutton的onclick参数?例如调用checkMaster()方法使用javascript函数和类似self.close()? – gaffcz 2011-05-10 12:10:47
这一个更合适。考虑到在执行你的动作的时候会出现一些异常,所以用户永远不会知道它。在这种情况下,它应该得到妥善处理 – 2011-05-10 12:12:24
啊哈,我现在明白了。使用faces-config.xml是实际的xhtml重定向到foo.xhtml,并通过。真的行!谢谢你,Jigar! – gaffcz 2011-05-10 12:26:26