[jboss-user] [JBoss Seam] - Re: problem with conversations

kosl do-not-reply at jboss.com
Thu Jul 5 09:34:31 EDT 2007


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4060816#4060816

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4060816



More information about the jboss-user mailing list