Summary on 20080716: close the current page through backend bean method
来源:互联网 发布:哈喽聊天软件 编辑:程序博客网 时间:2024/05/21 00:49
There is such process that: in home page, click some link/button to open one pop up child window, in the window, input/edit/add some content and click 'submit' button to submit the change, if the change is saved successfully, close the child window and refresh the home page if necessary.
For this case, in JSP page, it can be handled by ajax easily, however, in normal jsf(with out ajax), it's quite one tricky and hard-to-resolve problem. The dificulty is that: save is done by backend bean, while close and refresh is done by JavaScript, backend bean can't close/refresh page directly.
To achive this, the only way is that: in backend bean, return some state/value to frontend. And fortunately that we can do this by FacesContext. Refer the following code:
//Get the current context;FacesContext context = FacesContext.getCurrentInstance();//Get servlet response;HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();PrintWriter writer = response.getWriter();writer.write("");the first script code will refresh the home pagethe second script code will close the child page;
The related link:
1. web page for summary of js code that commonly used:
http://www.utf.com.cn/article/s1024
2. one simple sample for the usage:
http://www.itzhe.cn/article/20080116/55203.html
- Summary on 20080716: close the current page through backend bean method
- Invocation of destroy method 'close' failed on bean with name 'sqlSession'
- Couldn't find a destroy method named 'close' on bean with name 'JdbcTemplate
- Couldn't find a destroy method named 'close' on bean with name 'dataSourceFund'
- DoSave save the current page
- Confirmation on Leaving the Current Page in an Angular.js App
- Summary on 20080717: web page refresh
- Get the self URL of current page
- PHP Get the Current Page URL
- JavaScript无提示关闭当前页面窗口,兼容IE/Firefox/Chrome (Close the current page window without confirm by JavaScript, support all browsers)
- 当主页面关闭时关闭所有子窗口(Close all the child windows on unload of main page)
- Summary on 20081111: system method in sql server2005
- One method to disable close button on title bar
- Highlighting the Current Page in a Navigating Bar
- PHP: How to Get the Current Page URL
- current automation framework summary
- java示例3——Get the current method name
- Getting the department_id through the user on domain filter
- 做人难
- DOS命令集
- 远程数据库 链接
- odinms服forV55 用户使用手册
- asp.net用swfupload上传大文件
- Summary on 20080716: close the current page through backend bean method
- WS-BPEL语言基础
- 网络上收集几种画圆及圆环的方法
- 希尔排序
- MessageDigest的功能及用法
- 需要人深思的十句话
- ASCII
- FAQ!!odinms[xxuanwan编译版]常见问题解答
- 高web网页制作,学java,该从何学起?