문제

Is the conversation.id not reset when conversation.end is called?

Scenario: I have an app that uses conversation scope in CRUD, so when I visit the list page it starts a conversation. Go to the detail and click back will call end conversation and begin conversation again. But while I'm at debug mode I found out that when conversation.end() is called conversation is set to null. Then when I reinvoke conversation.begin() conversation.id is not reset to 1 but rather the last value + 1. Is it correct to behave that way?

What's more puzzling is after logout and login again, the conversation.id pick up the last value + 1.

My environment: Jboss 7.1.3 using javaee-api.

protected void beginConversation() {
    if (conversation.isTransient()) {
        conversation.begin();
    }
}

protected void endConversation() {
    if (!conversation.isTransient()) {
        conversation.end();
    }
}

So basically I have a base entity (where the above code is defined.) extended by all the backing beans. When a list page is render it will call beginConversation. Clicking the back button in detail page will call endConversation.

도움이 되었습니까?

해결책

Why should the conversation id be reset?

The best way to solve those questions is to directly having a look in the specification (in your case CDI 1.0), which states that the container has to generate an id for the conversation, but not how.

Check out this question, which states how it's done in WELD.

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