1
我有index.html頁面與javaserverfaces屬性訪問問題
<h:dataTable id="usersTable" value="#{mainViewController.users}" var="user" border="1">
....
,並請求範圍mainViewController豆
@Component("mainViewController")
@Scope("request")
public class MainViewController {
@Inject
private UserDao userDao;
private Collection<User> users;
public Collection<User> getUsers() {
if (users == null) {
users = userDao.findAll();
}
return users;
}
,當我訪問的index.html getUsers叫,那絕對是正常的,但是當我把index.html留給其他一些頁面getUsers也叫,如何避免二次調用?