-
1. Re: problem with conversations
kruno Jul 5, 2007 8:40 AM (in response to kosl)Try some thing like this:
<page view-id="/register.xhtml" > <begin-conversation join="true"/> </page>
if you are entering a page with GET (bookmark) or in side some other page<s:link value="USER REGISTER" propagation="begin" action="/register.xhtml"/>
-
2. Re: problem with conversations
kosl Jul 5, 2007 8:51 AM (in response to kosl)Thank u very much for the hint, unfortunatelly it doesn't help :(
-
3. Re: problem with conversations
wschwendt Jul 5, 2007 9:03 AM (in response to kosl)"kosl" wrote:
My intention was that everytime the user enters this page a new conversation is started.
How does the user gets to your page? Via an slink?
Try this:
<s:link value="USER REGISTER" view="/register.xhtml" propagation="none" />
Then the link doesn't contain a conversation ID. When user clicks on the link, a non-faces request is received. Then, first a temporary conversation gets created which will later be promoted to a long-running conversation when @Begin is encountered. -
4. Re: problem with conversations
kosl Jul 5, 2007 9:05 AM (in response to kosl)User get's to this page by writint the url directly into the browser.
-
5. Re: problem with conversations
kosl Jul 5, 2007 9:08 AM (in response to kosl)I've added the @Begin annotation to the action linked to submit button but it doesn't really help either..
-
6. Re: problem with conversations
kruno Jul 5, 2007 9:12 AM (in response to kosl)It would be the best if you post the code
-
7. Re: problem with conversations
kosl Jul 5, 2007 9:19 AM (in response to kosl)ok, I'll do that ASAP I have to simplify the code
-
8. Re: problem with conversations
kosl Jul 5, 2007 9:34 AM (in response to kosl)Thank u very much for trying to help me, I really apreciate that. Below you will find all the relevant code:
<page view-id="/register.xhtml" action="#{conversation.begin}"/>
I tried also the version recommended in the first answer to my post.
the backing bean interface:package user.register; public interface Register { public String getStep(); public String go(String dir); public String submit(); public String accept(); public void destroy(); public String getEmail(); public void setEmail(String email); public String getEmailRepeat(); public void setEmailRepeat(String emailRepeat); public String getFirstName(); public void setFirstName(String firstName); public String getLastName(); public void setLastName(String lastName); public String getLogin(); public void setLogin(String login); public String getPassword(); public void setPassword(String password); public String getPasswordRepeat(); public void setPasswordRepeat(String passwordRepeat); public void setStep(String step); public String getSex(); public void setSex(String sex); }
the backing bean code:package user.register; import java.util.List; import javax.ejb.Remove; import javax.ejb.Stateful; import javax.faces.application.FacesMessage; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Begin; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; import org.jboss.seam.core.FacesMessages; @Stateful @Scope(ScopeType.CONVERSATION) @Name("register") public class RegisterAction implements Register { @PersistenceContext private EntityManager em; @In FacesMessages facesMessages; private String login, firstName, lastName, password, passwordRepeat, email, emailRepeat, sex; String step = "who"; public String getStep() { return step; } public String go(String dir) { String goTo = null; String[] steps = {"who", "confirm", "info"}; for(String step : steps) if(step.equals(dir)) goTo = dir; if(goTo == null) { for( int i = 0; i < steps.length; i++) { if(step.equals(steps)) { if(dir.equals("prev") && i > 0) goTo = steps[i-1]; else if(dir.equals("next") && i < (steps.length-1)) goTo = steps[i+1]; break; } } } setStep(goTo); return null; } public String accept() { return null; } @Begin(join=true) public String submit() { if(true) { go("confirm"); return null; } return null; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getEmailRepeat() { return emailRepeat; } public void setEmailRepeat(String emailRepeat) { this.emailRepeat = emailRepeat; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getLogin() { return login; } public void setLogin(String login) { this.login = login; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getPasswordRepeat() { return passwordRepeat; } public void setPasswordRepeat(String passwordRepeat) { this.passwordRepeat = passwordRepeat; } public void setStep(String step) { this.step = step; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } @Destroy @Remove public void destroy() { } }
seems to me nothing interesting going on in the bean code, simple getters and setters.
Webpage code:<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:sx="http://myfaces.apache.org/sandbox" xmlns:x="http://myfaces.apache.org/tomahawk" xmlns:ice="http://www.icesoft.com/icefaces/component" template="templates/page.xhtml"> <ui:define name="title"> <ice:outputText value="#{messages.register_title}" /> </ui:define> <ui:define name="body"> <ice:outputText value="#{messages.register_logoutFirst}" rendered="#{identity.loggedIn}"/> <ice:panelStack selectedPanel="#{register.step}" rendered="#{!identity.loggedIn}"> <!--############################################################# WHO #############################################################--> <ice:panelGroup id="who"> <ice:form> <ice:panelGrid columns="2" columnClasses="formLabel, formInput"> <ice:outputText value="#{messages.login}"/> <ice:inputText id="login" value="#{register.login}" required="true"/> <ice:outputText value="#{messages.firstName}"/> <ice:inputText id="firstName" value="#{register.firstName}" required="true"/> <ice:outputText value="#{messages.lastName}"/> <ice:inputText id="lastName" value="#{register.lastName}" required="true"/> <ice:outputText value="#{messages.sex}"/> <ice:selectOneMenu id="sex" value="#{register.sex}"> <f:selectItem itemLabel="#{messages.choose_value}" itemValue="NotChosen"/> <f:selectItem itemLabel="#{messages.female}" itemValue="female"/> <f:selectItem itemLabel="#{messages.male}" itemValue="male"/> </ice:selectOneMenu> <ice:outputText value="#{messages.password}"/> <ice:inputSecret id="password" value="#{register.password}" required="true"/> <ice:outputText value="#{messages.passwordRepeat}"/> <ice:inputSecret id="passwordRepeat" value="#{register.passwordRepeat}" required="true"> <x:validateEqual for="password" message="#{messages.passwordRepeat}"/> </ice:inputSecret> <ice:outputText value="#{messages.email}"/> <ice:inputText id="email" value="#{register.email}" required="true"> <x:validateEmail/> </ice:inputText> <ice:outputText value="ConversationID"/> <ice:outputText value="#{conversation.id}"/> <ice:outputText value="#{messages.emailRepeat}"/> <ice:inputText id="emailRepeat" value="#{register.emailRepeat}" required="true"> <x:validateEqual for="email" message="#{messages.register_passwordDoesntMatch}"/> </ice:inputText> </ice:panelGrid> <ice:commandButton value="#{messages.confirm}" action="#{register.submit}"/> </ice:form> </ice:panelGroup> <!--############################################################# CONFIRM #############################################################--> <ice:panelGroup id="confirm"> <ice:form> <ice:panelGrid columns="2" columnClasses="formLabel, formInput"> <ice:outputText value="#{messages.login}"/> <ice:outputText value="#{register.login}"/> <ice:outputText value="#{messages.firstName}"/> <ice:outputText value="#{register.firstName}"/> <ice:outputText value="#{messages.lastName}"/> <ice:outputText value="#{register.lastName}" /> <ice:outputText value="#{messages.sex}"/> <ice:outputText value="#{messages[register.sex]}"/> <ice:outputText value="#{messages.email}"/> <ice:outputText value="#{register.email}"/> <ice:commandButton value="#{messages.correct}" action="#{register.go('prev')}"/> <ice:commandButton value="#{messages.accept}" action="#{register.accept}"/> </ice:panelGrid> </ice:form> </ice:panelGroup> </ice:panelStack> </ui:define> </ui:composition>
As I mentioned above I enter the webpage directly putting it's url into the browser, I submit the form in one tab, it's not validated (as expected) open the webpage in another tab/window and the field that I've completed before has the same value in the new window/tab what is unexpected for me since, given the entry in pages.xml I would expect a new conversation to start.
I know that in the case of registration this might be not wrong but I feel that I don't understand something and would be happy to know how to achieve the effect of starting new conversations.
Kind REgards -
9. Re: problem with conversations
kruno Jul 5, 2007 10:13 AM (in response to kosl)I was a bit lost in your example:
here is on of mine :
pages.xml:<page view-id="/page.jsp" > <begin-conversation join="true"/> </page>
RegisterActionpackage orka.test; import javax.ejb.Remove; import javax.ejb.Stateful; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Destroy; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; @Stateful @Scope(ScopeType.CONVERSATION) @Name("register") public class RegisterAction implements Register { @PersistenceContext private EntityManager em; @In User user; public String reg(){ System.err.println(user.getName()); // check for errors // then persist //em.persist(user); return "ok"; } @Remove @Destroy public void destroy(){ } }
user class I belive that this is much better way if you divide data form actionspackage orka.test; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; // make him an entity so you can persist him @Name("user") @Scope(ScopeType.CONVERSATION) public class User { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
and jsp page<%@ page contentType="text/html; charset=UTF-8" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s"%> <f:view> <h:form id="forma"> <h:inputText value="#{user.name}"></h:inputText> <h:commandButton action="#{register.reg}" value="register" /> </h:form> </f:view>
every time you come to page it will be a new conversation because user entity is conversation scope and it is empty, but when you submit it is not new conversation. I think that is what you want -
10. Re: problem with conversations
kosl Jul 5, 2007 10:24 AM (in response to kosl)Thank you very much for this answer, I'll try to use it and I'll let know here whether it helped.
Cheers,
karol -
11. Re: problem with conversations
kosl Jul 5, 2007 6:06 PM (in response to kosl)As I said I am really grateful for your attempts to help me. Thx also for hint's of writing cleaner code. Unfortunatelly this example doens't work either for me. I've no idea why, maybe I have something misconfigured concerning conversations, or it's the problem of icefaces and seam.
Regards