-
1. Re: Doubt: Conversation?
israel.bgf Jul 29, 2009 4:37 PM (in response to allforjava.allforjava.aol.in)In that example of yours the component don't have the Statefull annotation, so it's a JavaBean and the default scope is set to event, no conversations here. If you put a @Statefull, it's going to be a long-running one, because you told so in the page.xml.
If you still have doubts, just ask it. :)
-
2. Re: Doubt: Conversation?
asookazian Jul 29, 2009 6:19 PM (in response to allforjava.allforjava.aol.in)That's not correct actually. Your Seam component does not need to be an EJB to be included in a LRC.
In a Seam app, you can definitely use @Begin and @End, for example, in a JavaBean that is conversation-scoped.
The example JavaBean above would need something like @Scope(ScopeType.CONVERSATION) at the type (class) level.
The Seam container uses a temporary conversation for a component unless the temp conversation is promoted to LRC via @Begin, <begin-conversation>, or programmatically via
Conversation conversation = Conversation.instance(); conversation.begin();
or the component joins the active LRC via @Begin(join=true) if an active LRC exists...
-
3. Re: Doubt: Conversation?
israel.bgf Jul 29, 2009 6:28 PM (in response to allforjava.allforjava.aol.in)Ops, sorry if what I told seemed to mean that. What i mean was:
He asked if this would be promoted to LRC:
@Name(
hitCount
)
public class HitCount{.. }No, cause the default scope for a javaBean is Event. If it had an @Stateful, it would be promoted cause it's an EJB now. I didn't say that javaBeans can't be included in a LRC, they can with the @Scope(ScopeType.CONVERSATION).
:)
-
4. Re: Doubt: Conversation?
asookazian Jul 29, 2009 8:11 PM (in response to allforjava.allforjava.aol.in)
Israel Fonseca wrote on Jul 29, 2009 18:28:
No, cause the default scope for a javaBean is Event. If it had an @Stateful, it would be promoted cause it's an EJB now.This statement is not 100% accurate. Not because it's an EJB now. It's because it's a SFSB which has default scope of conversation. It's b/c of the conversation scope that would allow the LRC promotion to occur. The default scope of a SLSB is stateless, and the LRC would not happen.
I tested a couple scenarios out of curiosity. In the first case below (conversation scope), the LRC begins after startup() method completes successfully. In the 2nd case, the LRC does not begin and the destroy() method is executed b/c there is a temporary conversation only. The interesting thing is that Seam ignores the @Begin annotation in the 2nd case and does not seem to throw any exception or message (unless it's logged at a lower level than INFO).
@Name("startConversation") @AutoCreate @Scope(ScopeType.CONVERSATION) public class TestStartConversation { @Logger Log log; @Begin(join=true) public void startup(){ log.info("in start()"); } @Destroy public void destroy(){ log.info("in destroy()"); } }
@Name("startConversation") @AutoCreate @Scope(ScopeType.EVENT) //default scope public class TestStartConversation { @Logger Log log; @Begin(join=true) public void startup(){ log.info("in start()"); } @Destroy public void destroy(){ log.info("in destroy()"); } }
The LRC begins with this version as well (session scope):
@Name("startConversation") @AutoCreate @Scope(ScopeType.SESSION) public class TestStartConversation { @Logger Log log; @Begin(join=true) public void startup(){ log.info("in start()"); } @Destroy public void destroy(){ log.info("in destroy()"); } }
-
5. Re: Doubt: Conversation?
israel.bgf Jul 29, 2009 8:24 PM (in response to allforjava.allforjava.aol.in)lol, maybe my English is a little rust and that's why i didn't put the right meaning in the sentence. But anyway, what you say, is what i want to mean in the end.
But the second example do not start a LRC? This is strange enough to be a bug.
-
6. Re: Doubt: Conversation?
asookazian Jul 29, 2009 10:07 PM (in response to allforjava.allforjava.aol.in)I don't use a lot of event-scoped components, so haven't seen that before. Try it yourself.
-
7. Re: Doubt: Conversation?
allforjava.allforjava.aol.in Jul 31, 2009 7:00 AM (in response to allforjava.allforjava.aol.in)Thank you, Israel and Arbi ! I tried to rate ur replies however it throw error 'object not found: jsquery'.
1. I'm unable to get 'temporary conversation'. Is it the default scope of the bean or else?
2. The conversation rules in seam reference are confusing me. It say conversation can be demoted/promoted then how to restart/close&start it?
The scenerio:
1. View loaded on menu click
2. Search operation
3. Clicked same menu-option for view
Problem: The search parameter in url are not removed. Only cid is changed.
Code:
@Name("menu")
@Scope(ScopeType.SESSION)
public class MenuBean {
public void endConversationAndRedirect(final String viewId){
log.debug("endConversationAndRedirect: clicked on " + viewId);
Manager.instance().endRootConversation(true);
Redirect redirect = Redirect.instance();
redirect.setViewId(viewId);
redirect.execute();
}
}
NewMenu.xhtml <rich:menuItem id="IssuesList" value="Issues List"
action="#{menu.endConversationAndRedirect('/IssuesList.xhtml')}">
</rich:menuItem>
Thank you in advance! -
8. Re: Doubt: Conversation?
israel.bgf Jul 31, 2009 2:59 PM (in response to allforjava.allforjava.aol.in)try to make your action point to a method like this:
@End(beforeRedirect="true") public String redirect(String uri){ return uri; }
See if it solves your problem.
-
9. Re: Doubt: Conversation?
allforjava.allforjava.aol.in Jul 31, 2009 3:53 PM (in response to allforjava.allforjava.aol.in)Thank you Israel, for speedy response!
The code 'Manager.instance().endRootConversation(true)' does the same (fingers crossed) w.r.t the details I have read. The 'true' in endRootConversation(), ends the conversation and any of its nested conversation before re-direct.
However, the problem is same. Unable to clear the pageparam in url on re-selection of the menuItem, why?
-
10. Re: Doubt: Conversation?
israel.bgf Jul 31, 2009 4:09 PM (in response to allforjava.allforjava.aol.in)I got some problems like that in the past too (restarting conversation)... I can't help you precisely cause i never used page-params anyway, but let's see... does the bean state get cleaned? Is the only problem the url page params?
-
11. Re: Doubt: Conversation?
allforjava.allforjava.aol.in Aug 3, 2009 8:44 AM (in response to allforjava.allforjava.aol.in)I was enjoying week-end. Sorry, I was unable to reply!
Here are the step I follow:
Step1: Successful Login goes to home page
http://localhost:8080/Portal/home.seam?cid=23
Step2: Menu click
http://localhost:8080/Portal/IssuesList.seam?order=id+desc&cid=24
Step3: Search
http://localhost:8080/Portal/IssuesList.seam?order=id+desc&status=Open&priority=Blocker&issueId=&issueTopic=&cid=24
Step4: Menu click [conversation ends, URL has pageparam and no cid. However debug page shows new cid]
http://localhost:8080/Portal/IssuesList.seam?order=id+desc&status=Open&priority=Blocker&issueId=&issueTopic=
Problems/Query:
1. Null/empty valued param are added to URL
2. URL is not cleared
3. I guess on new conversation the values from components (bean state) in it, are cleared. Is is right?
Thank you for your patience,Israel!