[jboss-user] [JBoss Seam] - pageflow definition and start-state

timony do-not-reply at jboss.com
Tue Jun 5 03:31:33 EDT 2007


Hi, I have not found anywhere in the documentation, how to handle the start-state correctly in CRUD operations:

The situation is, that I have non conversational list of items. I select one of the listed items to display the detail of it (car.xhtml). On the detail
the user can select "Edit", what switches him/her to the carEdit.xhtml page. This works fine with the car to edit. What I need is
to use the same page for creating the new car instances. I need to hook the same pageflow dirrectly from the carList.xhtml

I know, that it is possible to have more transitions in the <start-state> element, like I already have, but I don't
know, how to tell the pageflow to use the name="create" one (suppose, that if not specified otherwise, the one without the name is used)

So the question is: how to tell the pageflow to use the transition name="create" to="editCar" 

Here is the code, which works fine with the car to edit:

carList.xhtml - link to display the detail of the car

  | <s:button view="/car/car.xhtml" value="Select" id="selectCarButton">
  |      <f:param name="carId" value="#{car.id}" />
  | </s:button>
  | 

car/car.page.xml
the carHome.start actualy starts the new conversation with the pageflow "editcar"


  | <page action="#{carHome.start}">
  | 	<param name="carId" value="#{carHome.carId}" />
  | </page>
  | 

editcar pagefrow .jpdl.xml file

  | <pageflow-definition xmlns="http://jboss.com/products/seam/pageflow"
  | 	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  | 	xsi:schemaLocation="http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-1.2.xsd"
  | 	name="editcar">
  | 
  | 	<start-state name="start">
  | 		<transition name="create" to="editCar" />
  | 		<transition to="selectCar" />
  | 	</start-state>
  | 
  | 	<page name="selectCar" view-id="/car/car.xhtml">
  | 		<transition name="edit" to="editCar" />
  | 		<transition name="done" to="doneCar" />
  | 	</page>
  | 	
  | 	<page name="editCar" view-id="/car/carEdit.xhtml" no-conversation-view-id="/car/carList.xhtml">
  | 		<redirect />
  | 		<transition name="cancel" to="selectCar" />
  | 		<transition name="save" to="saveCar" />
  | 		<transition name="remove" to="doneCar">
  | 			<action expression="#{carHome.remove}" />
  | 		</transition>
  | 	</page>
  | 
  | 	<decision name="saveCar" expression="#{carHome.managed}">
  | 		<transition name="true" to="selectCar">
  | 			<action expression="#{carHome.update}" />
  | 		</transition>
  | 		<transition name="false" to="selectCar">
  | 			<action expression="#{carHome.persist}" />
  | 		</transition>
  | 	</decision>
  | 
  | 	<page name="doneCar" view-id="/car/carList.xhtml">
  | 		<redirect />
  | 		<end-conversation />
  | 	</page>
  | 
  | </pageflow-definition>
  | 

The component carHome

  | package cz.timony.carConsumption.ejb.session.car;
  | 
  | import org.jboss.seam.annotations.Begin;
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.annotations.RequestParameter;
  | import org.jboss.seam.annotations.security.Restrict;
  | import org.jboss.seam.framework.EntityHome;
  | 
  | import cz.timony.carConsumption.ejb.model.Car;
  | import cz.timony.carConsumption.ejb.model.User;
  | 
  | @Name("carHome")
  | @Restrict("#{identity.loggedIn}")
  | public class CarHome extends EntityHome<Car> {
  | 
  | 	@RequestParameter
  | 	Integer carId;
  | 	
  | 	private static final long serialVersionUID = 1712476447498905090L;
  | 
  | 	@In(value = "currentUser")
  | 	User currentUser;
  | 	
  | 	public Car getInstance() {
  | 		return super.getInstance();
  | 	}
  | 	
  | 	@Begin(join = true, pageflow="editcar")
  | 	public void start() {
  | 		wire();
  | 	}
  | 	
  | 	public void setCarId(Integer id) {
  | 		setId(id);
  | 	}
  | 
  | 	public Integer getCarId() {
  | 		return (Integer) getId();
  | 	}
  | 
  | 	@Override
  | 	protected Car createInstance() {
  | 		Car car = new Car();
  | 		return car;
  | 	}
  | 
  | 	public void wire() {
  | 		if (getInstance().getUser() == null && currentUser != null) {
  | 			getInstance().setUser(currentUser);
  | 		}
  | 	}
  | 
  | 	public boolean isWired() {
  | 		if (getInstance().getUser() == null)
  | 			return false;
  | 		return true;
  | 	}
  | 
  | 	public Car getDefinedInstance() {
  | 		return isIdDefined() ? getInstance() : null;
  | 	}
  | }
  | 


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

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



More information about the jboss-user mailing list