JSF2.0 State_Saving_Method客户端问题 [英] JSF2.0 State_Saving_Method client issues

查看:150
本文介绍了JSF2.0 State_Saving_Method客户端问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Mojarra 2.1.3,Netbeans 7.0.1,primefaces 3.2.

Im using Mojarra 2.1.3, Netbeans 7.0.1, primefaces 3.2.

我现在很困惑是否要使用STATE_SAVING_METHOD客户端或服务器.目前,我正在将保存方法设置为客户端.这涉及到我要对许多对象的可序列化进行调整.并将transient关键字放在无状态的外观会话bean上.

I am currently in a quandary whether to use STATE_SAVING_METHOD client or server. Currently Im setting the saving method to client. And this involves me doing adjustment to seriazibility of many objects. And putting transient keyword on the stateless facade session beans.

@ManagedBean
@ViewScoped
public class SaProductController implements Serializable {
@EJB
transient SaProductFacade saProductFacade;
@EJB
transient SaKeywordFacade saKeywordFacade;
....

我的xhtml页面有一个带有分页的primefaces dataTable.第一次加载页面时,它通过在数据表中显示第一页来工作.但是,在单击下一页时,此行将引发NullPointerException错误.

My xhtml page has a primefaces dataTable with pagination. The first time loading the page it works by showing the first page in the datatable. However, upon clicking on next page, this lines throws a NullPointerException error.

data = saProductFacade.selectAll(first, pageSize);

那是为什么?是因为saProductFacade @EJB属性被声明为临时属性,并且在回发到同一页面时被销毁了.无论如何,ViewScoped托管Bean仍然有效.请帮忙,如何解决这个问题?还是我做错了?

Why is that? Is it because saProductFacade @EJB property declared as transient and it's destroyed on postback to the same page. The ViewScoped managed bean is still alive anyway. Please help, how to solve this issue? Or am I doing it wrong?

有关信息,如果我将STATE_SAVING_METHOD设置为服务器,则此方法非常适用.但是浏览器后退按钮的危险使我决定选择客户端状态保存选项.而且,服务器上的内存限制也保证了客户端状态的保存.

For information, this works perfectly if I set the STATE_SAVING_METHOD to server. But the peril of the browser back button made me decide to go the client state saving option. And also, memory limitation on the server is warranting client state saving.

推荐答案

仅供参考,对于初学者,我现在使用服务器状态保存方法.而且我使用会话变量来记住如果用户按下后退按钮,我在哪里.这样,将重新创建ViewScoped支持bean,并自动将其分页到用户上次查看的页面.这样我就可以在用户使用GET HTTP请求导航到另一个页面之前将用户重定向到他们的最后一个数据表页面.

Just for information, for beginners, Im using server state saving method now. And I use session variables to remember where am I if user press on back button. This way the ViewScoped backing bean is recreated and automatically paginate to the page where the user last viewed. So that I can redirect the user to where their last datatable page was before they navigate to another page using GET HTTP request.

这篇关于JSF2.0 State_Saving_Method客户端问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆