小编Sun*_*kia的帖子

JSF 2.0 - ViewScope和SessionScope的优势?

如果有人可以帮助我理解,当我们将SessionBean注入其中时ViewScoped bean的优势是什么呢会很棒.

我们还能节省会话内存的使用吗?

如果我们只使用SessionScoped bean或ViewScoped bean注入SessionBean,我相信会话内存占用没有区别.

当使用SessionScoped bean实现所有目标时,为什么我们要经历使用View和Session scoped bean的麻烦.

谢谢,Sundeep

jsf

4
推荐指数
2
解决办法
2万
查看次数

如何在RequestScoped bean中调用@PostConstruct之前在SessionScoped bean中设置参数值

非常感谢您帮助解决以下问题(JBoss 6.0,Mojarra - 2.2 Snapshot,facelet 1.1和PrimeFaces 3.0.M4:

问题是,在获取值集之前调用请求bean的post构造方法.我们如何确保首先设置会话bean上的参数值,然后调用请求bean的post构造方法.

问题#1:当点击"Next"时,这是一个ajax调用1. testRequestBB的"初始化"post构造方法被调用2. testSessionBB的"next"方法被调用来设置值

预期的行为应该是另一种方式,使用ajax调用在会话bean中设置值,然后应该初始化请求bean.

问题#2:请求bean的"初始化"后构造方法被调用两次.
- 是因为请求bean从基类扩展(尽管基类中没有post构造方法).

当显示test.xhtml页面时,可以采取哪些措施来解决获取post构造方法两次调用的问题?

这是代码:

test.xhtml

<h:dataTable id="testId" emptyMessage="#{messages.noData}" var="test" value="#{testList}">
....
<f:facet name="footer">
    <h:form id="pgId">                  
        <h:commandLink value="#{messages.next} ">
            <f:ajax listener="#{testSessionBB.next}" />
        </h:commandLink>
            .....
    </h:form>
</f:facet>
</h:dataTable>
Run Code Online (Sandbox Code Playgroud)

TestSessionBB.java

@Named("testSessionBB")
@SessionScoped
public class TestSessionBB implements Serializable
{
    private int testStartRow;
    .....

    public String next() 
    {
        if (this.getTestStartRow() + 5 > 15) // hard coded value for simplicity in this post
        {
            this.setTestStartRow(15);
        } else {
            this.setTestStartRow(this.getTestStartRow() + 5);
        } …
Run Code Online (Sandbox Code Playgroud)

jsf-2

2
推荐指数
1
解决办法
5455
查看次数

标签 统计

jsf ×1

jsf-2 ×1