Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 弹出窗口-执行操作并关闭_Java_Javascript_Jsf - Fatal编程技术网

Java 弹出窗口-执行操作并关闭

Java 弹出窗口-执行操作并关闭,java,javascript,jsf,Java,Javascript,Jsf,我使用弹出窗口进行代码身份验证,其中只有以下组件: <h:inputText value="#{bean.masterKey.code}" /> <h:commandButton action="#{bean.checkMaster}" value="OK" type="submit"/> 但我想在执行操作后关闭弹出窗口(每次按下按钮) 但是我不知道怎么。。你能帮我吗 更新: public static boolean findMasterKey(String key)

我使用弹出窗口进行代码身份验证,其中只有以下组件:

<h:inputText value="#{bean.masterKey.code}" />
<h:commandButton action="#{bean.checkMaster}" value="OK" type="submit"/>
但我想在执行操作后关闭弹出窗口(每次按下按钮)

但是我不知道怎么。。你能帮我吗

更新:

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;   
}

执行on操作后,将此页面导航到某个页面,例如
Foo


在加载
Foo
execute
windows.close()
javascript

噢,感谢您的快速回复。你能告诉我怎么做吗?我没有多少经验。或者说使用commandbutton的onclick参数不是更优雅的解决方案吗?例如,使用javascript函数和类似self.close()的东西调用checkMaster()方法?这个方法更合适。考虑到在执行您的操作时会出现一些异常,因此用户永远不会知道它。在这种情况下,它应该得到妥善处理。哈哈,我现在明白了。使用faces-config.xml会将实际的xhtml重定向到foo.xhtml,并且会使用by window.close()关闭;。它真的有效!谢谢你,Jigar!还有一件事:)我想要重定向的页面(1)从主页(2)开始重定向到页面foo.xhtml(3),关闭foo页面后如何刷新主页(2)?检查
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;   
}