This content has been marked as final.
Show 2 replies
-
1. Re: Seam CRUD Application generated by Seam-gen
sjmenden Aug 29, 2008 3:42 PM (in response to alexpelliccione)Post the code involved
-
2. Re: Seam CRUD Application generated by Seam-gen
alexpelliccione Sep 1, 2008 3:34 AM (in response to alexpelliccione)Hi Samuel.
Thanks for your help.
This is the code of the entity OrderItems:
package org.domain.OrderEntry.entity;
// Generated 28/08/2008 10:46:25 by Hibernate Tools 3.2.2.GA
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
/**
* Orderitem generated by hbm2java
*/
@Entity
@Table(name = "orderitem", catalog = "test")
public class Orderitem implements java.io.Serializable {
private Integer orderItemId;
private Serviceorder serviceorder;
private String itemDescription;
public Orderitem() {
}
public Orderitem(Serviceorder serviceorder, String itemDescription) {
this.serviceorder = serviceorder;
this.itemDescription = itemDescription;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "OrderItemID", unique = true, nullable = false)
public Integer getOrderItemId() {
return this.orderItemId;
}
public void setOrderItemId(Integer orderItemId) {
this.orderItemId = orderItemId;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "OrderID", nullable = false)
@NotNull
public Serviceorder getServiceorder() {
return this.serviceorder;
}
public void setServiceorder(Serviceorder serviceorder) {
this.serviceorder = serviceorder;
}
@Column(name = "ItemDescription", nullable = false, length = 45)
@NotNull
@Length(max = 45)
public String getItemDescription() {
return this.itemDescription;
}
public void setItemDescription(String itemDescription) {
this.itemDescription = itemDescription;
}
}
and this is the code of the OrderItemHome:
package org.domain.OrderEntry.session;
import org.domain.OrderEntry.entity.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;
@Name("orderitemHome")
public class OrderitemHome extends EntityHome<Orderitem> {
@In(create = true)
ServiceorderHome serviceorderHome;
public void setOrderitemOrderItemId(Integer id) {
setId(id);
}
public Integer getOrderitemOrderItemId() {
return (Integer) getId();
}
@Override
protected Orderitem createInstance() {
Orderitem orderitem = new Orderitem();
return orderitem;
}
public void wire() {
getInstance();
Serviceorder serviceorder = serviceorderHome.getDefinedInstance();
if (serviceorder != null) {
getInstance().setServiceorder(serviceorder);
}
}
public boolean isWired() {
if (getInstance().getServiceorder() == null)
return false;
return true;
}
public Orderitem getDefinedInstance() {
return isIdDefined() ? getInstance() : null;
}
}
The page.xml for the OrderItemEdit.xhtml is:
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns="http://jboss.com/products/seam/pages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd"
no-conversation-view-id="/OrderitemList.xhtml"
login-required="true">
<begin-conversation join="true"/>
<action execute="#{orderitemHome.wire}"/>
<param name="orderitemFrom"/>
<param name="orderitemOrderItemId" value="#{orderitemHome.orderitemOrderItemId}"/>
<param name="serviceorderFrom"/>
<param name="serviceorderOrderId" value="#{serviceorderHome.serviceorderOrderId}"/>
<navigation from-action="#{orderitemHome.persist}">
<end-conversation/>
<redirect view-id="/Orderitem.xhtml"/>
</navigation>
<navigation from-action="#{orderitemHome.update}">
<end-conversation/>
<redirect view-id="/Orderitem.xhtml"/>
</navigation>
<navigation from-action="#{orderitemHome.remove}">
<end-conversation/>
<redirect view-id="/OrderitemList.xhtml"/>
</navigation>
</page>
All of the above codes was generated by the seam-gen using Eclipse Seam-web project.
Regards
Alex