문제

I use JSF2.0 and WELD-CDI and jboss AS7.I use CDI@ConversiationScope in page-backbean. To go to the one page, I am using the menu-item., As shown:

<rich:menuItem 
     label="redirect  to page1"
     execute="@this"
     action="#{myBean.begin}"/>

In the action of this menu, the following method is called to begin conversation and then redirect to the desired page:

@Named(value = "myBean")
@ConversationScoped
public class MyBean implements Serializable {
@Inject
private Conversation conversation;

public String begin() {
    if (!conversation.isTransient()) {
        conversation.end();
    }
    conversation.setTimeout(“1800000”);
    conversation.begin();    
    return "page1";
}
}

and faces-config.xml:

<navigation-case>
        <from-outcome>page1</from-outcome>
        <to-view-id>/sample/page1.xhtml</to-view-id>
        <redirect/>
</navigation-case>

So far everything works great.

But if I apply again by the way, after execute conversation.end(), still no change variables and All values of variable are maintained. Why?!

after exexute "conversation.end()" ,variables-value are not reset.why variables are not reset?Please help me.

도움이 되었습니까?

해결책

When you end the conversation it becomes transient. This means that it's content will be destroyed after the request ends. This however means that calling end() does not change the beans as long as you're still in the same request. Another way to say it is that end()'s effect is delayed; it only works for the next request. And btw: it is not really that the fields are reset; new beans will be injected and those new beans will of course have initial values for their fields.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top