I want to generate a crud for an entity with an editable primary key but forge doesnt generate the @id field this is my entity note that the id field is an string it is not a an auto increment id field.
package com.samples.model;
// Generated 14/01/2013 11:23:23 AM by Hibernate Tools 3.4.0.CR1
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
* Pais generated by hbm2java
*/
@Entity
@Table(name = "pais", schema = "public")
public class Pais implements java.io.Serializable
{
/**
*
*/
private static final long serialVersionUID = -8369022633869576848L;
private String paisId;
private Date fechaRegistro;
private String descripcion;
private short estatus;
private Set<Estado> estados = new HashSet<Estado>(0);
public Pais()
{
}
public Pais(String paisId, Date fechaRegistro, short estatus)
{
this.paisId = paisId;
this.fechaRegistro = fechaRegistro;
this.estatus = estatus;
}
public Pais(String paisId, Date fechaRegistro, String descripcion, short estatus, Set<Estado> estados)
{
this.paisId = paisId;
this.fechaRegistro = fechaRegistro;
this.descripcion = descripcion;
this.estatus = estatus;
this.estados = estados;
}
@Id
@Column(name = "pais_id", unique = true, nullable = false, length = 5)
public String getPaisId()
{
return this.paisId;
}
public void setPaisId(String paisId)
{
this.paisId = paisId;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "fecha_registro", nullable = false, length = 29)
public Date getFechaRegistro()
{
return this.fechaRegistro;
}
public void setFechaRegistro(Date fechaRegistro)
{
this.fechaRegistro = fechaRegistro;
}
@Column(name = "descripcion", length = 30)
public String getDescripcion()
{
return this.descripcion;
}
public void setDescripcion(String descripcion)
{
this.descripcion = descripcion;
}
@Column(name = "estatus", nullable = false)
public short getEstatus()
{
return this.estatus;
}
public void setEstatus(short estatus)
{
this.estatus = estatus;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "pais")
public Set<Estado> getEstados()
{
return this.estados;
}
public void setEstados(Set<Estado> estados)
{
this.estados = estados;
}
}
JBoss Forge uses Metawidget for its UI generation. So to accomplish this you must modify Forge's metawidget.xml configuration file.
Forge actually has 3 Metawidget configuration files: metawidget-entity.xml for viewing/editing screens, metawidget-search.xml for search filters, and metawidget-qbe.xml for generating Java code.
For your purposes, you need to modify metawidget-entity.xml. Specifically you must find the JpaInspector entry...
...and add a child node...
That bit should be straightforward. However actually getting your modified metawidget-entity.xml back into Forge is clumsy. At the moment the easiest way is probably to unzip and modify the forge-scaffold-faces.jar itself. Hopefully this will be made cleaner in a future Forge release.