This content has been marked as final.
Show 4 replies
-
1. Additionally info: Conversation - how to start automatically
issad Sep 29, 2005 2:15 PM (in response to issad)For addition a source code from Stateful session bean and view page:
Stateful bean:@Stateful @Name("reportslist") @Interceptor(SeamInterceptor.class) @Conversational(ifNotBegunOutcome="main") public class ReportsBO implements Reports, Serializable { @PersistenceContext(type=EXTENDED) private EntityManager reportsDatabase; @Out(required=false) private Report report; @DataModel private List<Report> reports; @DataModelSelectionIndex private int reportIndex; @Begin public String find() { report = null; String searchQuery = "from Report"; reports = reportsDatabase.createQuery(searchQuery).getResultList(); return "main"; } public String editReport() { report = reports.get(reportIndex); return "edit_report"; } public String newReport() { report = new Report(); return "edit_report"; } public String clearReports() { for (Report rep: reports) { reportsDatabase.remove(rep); } return "main"; } @End public String confirmed() { if (report.getId()==0) reportsDatabase.persist(report); return "show_list"; } }
View:<%@ page contentType="text/html;charset=windows-1250" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <HTML> <HEAD> <title>Report aplikace</title> </HEAD> <body bgcolor="white"> <f:loadBundle basename="resources.Resources" var="bundle"/> <f:view> <h:form id="helloForm"> <h:dataTable id="table" value="#{reports}" var="rep"> <h:column> <f:facet name="header"> <h:outputText value="#{bundle.name}"/> </f:facet> <h:outputText value="#{rep.name}"/> </h:column> <h:column> <h:outputText value="#{rep.id}"/> </h:column> <h:column> <h:commandButton action="#{reportslist.editReport}" value="Edit" /> </h:column> </h:dataTable> <h:commandButton action="#{reportslist.newReport}" value="#{bundle.newreport}" /> <h:commandButton action="#{reportslist.clearReports}" value="#{bundle.clear}" /> </h:form> </f:view> </body> </HTML>
And I simply need to start a new conversation scope always when this view loads (= start "find" method from the stateful bean always when this view loads). -
2. Re: Conversation - how to start automatically with a given p
lavoir Sep 29, 2005 2:50 PM (in response to issad)My *guess* is you want to try looking into @Create
-
3. Re: Conversation - how to start automatically with a given p
gavin.king Sep 29, 2005 7:23 PM (in response to issad)Hmmmmmm, I have never tried to do this. Perhaps you could use @Intercept(ALWAYS), and add a method marked @Create @Begin to the bean. This should work, I guess...
-
4. Re: Conversation - how to start automatically with a given p
udo.krass Nov 14, 2005 8:43 AM (in response to issad)Hi issad,
will this work for you?
If yes, can you post your code?
Thanks.
Regards,
Udo