2010-09-25 94 views
0

异常java.lang.IllegalArgumentException异常在javax.faces.component.UIComponentBase.validateId

java.lang.IllegalArgumentException: partidosPK.idEquipo 
at javax.faces.component.UIComponentBase.validateId(UIComponentBase.java:551) 
at javax.faces.component.UIComponentBase.setId(UIComponentBase.java:366) 
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply  (ComponentTagHandlerDelegateImpl.java:168) 
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114) 
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91) 
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120) 
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204) 
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114) 
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91) 
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:120) 
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:204) 
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114) 
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:91) 
at com.sun.faces.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:97) 
at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:172) 

,并不断去......也 实体Bean

private String ganador; 
@Column(name = "fecha") 
@Temporal(TemporalType.TIMESTAMP) 
private Date fecha; 
@Column(name = "golesEquipoGanador") 
private Integer golesEquipoGanador; 
@Column(name = "golesEquipoPerdedor") 
private Integer golesEquipoPerdedor; 
@Column(name = "perdedor") 
private String perdedor; 
@OneToMany(cascade = CascadeType.ALL, mappedBy = "partidos") 
private Collection<Goleadores> goleadoresCollection; 
@OneToMany(cascade = CascadeType.ALL, mappedBy = "partidos") 
private Collection<SancionesJugadores> sancionesJugadoresCollection; 
@JoinColumns({ 
    @JoinColumn(name = "idCampeonato", referencedColumnName = "idCampeonato", insertable = false, updatable = false), 
    @JoinColumn(name = "idPartido", referencedColumnName = "idEquipo", insertable = false, updatable = false)}) 
@ManyToOne(optional = false) 
private EquiposPorCampeonato equiposPorCampeonato; 

public Partidos() { 
} 

public Partidos(PartidosPK partidosPK) { 
    this.partidosPK = partidosPK; 
} 

public Partidos(int idCampeonato, int idEquipo, int idPartido) { 
    this.partidosPK = new PartidosPK(idCampeonato, idEquipo, idPartido); 
} 

public PartidosPK getPartidosPK() { 
    return partidosPK; 
} 

public void setPartidosPK(PartidosPK partidosPK) { 
    this.partidosPK = partidosPK; 
} 

public String getGanador() { 
    return ganador; 
} 

public void setGanador(String ganador) { 
    this.ganador = ganador; 
} 

public Date getFecha() { 
    return fecha; 
} 

public void setFecha(Date fecha) { 
    this.fecha = fecha; 
} 

public Integer getGolesEquipoGanador() { 
    return golesEquipoGanador; 
} 

public void setGolesEquipoGanador(Integer golesEquipoGanador) { 
    this.golesEquipoGanador = golesEquipoGanador; 
} 

public Integer getGolesEquipoPerdedor() { 
    return golesEquipoPerdedor; 
} 

public void setGolesEquipoPerdedor(Integer golesEquipoPerdedor) { 
    this.golesEquipoPerdedor = golesEquipoPerdedor; 
} 

public String getPerdedor() { 
    return perdedor; 
} 

public void setPerdedor(String perdedor) { 
    this.perdedor = perdedor; 
} 

public Collection<Goleadores> getGoleadoresCollection() { 
    return goleadoresCollection; 
} 

public void setGoleadoresCollection(Collection<Goleadores> goleadoresCollection) { 
    this.goleadoresCollection = goleadoresCollection; 
} 

public Collection<SancionesJugadores> getSancionesJugadoresCollection() { 
    return sancionesJugadoresCollection; 
} 

public void setSancionesJugadoresCollection(Collection<SancionesJugadores> sancionesJugadoresCollection) { 
    this.sancionesJugadoresCollection = sancionesJugadoresCollection; 
} 

public EquiposPorCampeonato getEquiposPorCampeonato() { 
    return equiposPorCampeonato; 
} 

public void setEquiposPorCampeonato(EquiposPorCampeonato equiposPorCampeonato) { 
    this.equiposPorCampeonato = equiposPorCampeonato; 
} 

@Override 
public int hashCode() { 
    int hash = 0; 
    hash += (partidosPK != null ? partidosPK.hashCode() : 0); 
    return hash; 
} 

@Override 
public boolean equals(Object object) { 
    // TODO: Warning - this method won't work in the case the id fields are not set 
    if (!(object instanceof Partidos)) { 
     return false; 
    } 
    Partidos other = (Partidos) object; 
    if ((this.partidosPK == null && other.partidosPK != null) || (this.partidosPK != null && !this.partidosPK.equals(other.partidosPK))) { 
     return false; 
    } 
    return true; 
} 

@Override 
public String toString() { 
    return "" + partidosPK + ""; 
} 

} 

相关的PrimaryKey EntityBean的

@Embeddable 
public class PartidosPK implements Serializable { 
@Basic(optional = false) 
@Column(name = "idCampeonato") 
private int idCampeonato; 
@Basic(optional = false) 
@Column(name = "idEquipo") 
private int idEquipo; 
@Basic(optional = false) 
@Column(name = "idPartido") 
private int idPartido; 

public PartidosPK() { 
} 

public PartidosPK(int idCampeonato, int idEquipo, int idPartido) { 
    this.idCampeonato = idCampeonato; 
    this.idEquipo = idEquipo; 
    this.idPartido = idPartido; 
} 

public int getIdCampeonato() { 
    return idCampeonato; 
} 

public void setIdCampeonato(int idCampeonato) { 
    this.idCampeonato = idCampeonato; 
} 

public int getIdEquipo() { 
    return idEquipo; 
} 

public void setIdEquipo(int idEquipo) { 
    this.idEquipo = idEquipo; 
} 

public int getIdPartido() { 
    return idPartido; 
} 

public void setIdPartido(int idPartido) { 
    this.idPartido = idPartido; 
} 

@Override 
public int hashCode() { 
    int hash = 0; 
    hash += (int) idCampeonato; 
    hash += (int) idEquipo; 
    hash += (int) idPartido; 
    return hash; 
} 

@Override 
public boolean equals(Object object) { 
    // TODO: Warning - this method won't work in the case the id fields are not set 
    if (!(object instanceof PartidosPK)) { 
     return false; 
    } 
    PartidosPK other = (PartidosPK) object; 
    if (this.idCampeonato != other.idCampeonato) { 
     return false; 
    } 
    if (this.idEquipo != other.idEquipo) { 
     return false; 
    } 
    if (this.idPartido != other.idPartido) { 
     return false; 
    } 
    return true; 
} 

@Override 
public String toString() { 
    return "" + idCampeonato + ", " + idEquipo + ", " + idPartido + ""; 
} 
} 

最后但并非最不重要

如果需要的话
@Entity 
@Table(name = "equipos") 
@NamedQueries({ 
@NamedQuery(name = "Equipos.findAll", query = "SELECT e FROM Equipos e"), 
@NamedQuery(name = "Equipos.findByIdEquipo", query = "SELECT e FROM Equipos e WHERE e.idEquipo = :idEquipo"), 
@NamedQuery(name = "Equipos.findByNombre", query = "SELECT e FROM Equipos e WHERE e.nombre = :nombre")}) 
public class Equipos implements Serializable { 
private static final long serialVersionUID = 1L; 
@Id 
@GeneratedValue(strategy = GenerationType.IDENTITY) 
@Basic(optional = false) 
@Column(name = "idEquipo") 
private Integer idEquipo; 
@Basic(optional = false) 
@Column(name = "nombre") 
private String nombre; 
@JoinColumn(name = "idSexo", referencedColumnName = "idSexo") 
@ManyToOne(optional = false) 
private Sexos idSexo; 
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idEquipo") 
private Collection<Jugadores> jugadoresCollection; 
@OneToMany(cascade = CascadeType.ALL, mappedBy = "equipos") 
private Collection<EquiposPorCampeonato> equiposPorCampeonatoCollection; 

public Equipos() { 
} 

public Equipos(Integer idEquipo) { 
    this.idEquipo = idEquipo; 
} 

public Equipos(Integer idEquipo, String nombre) { 
    this.idEquipo = idEquipo; 
    this.nombre = nombre; 
} 

public Integer getIdEquipo() { 
    return idEquipo; 
} 

public void setIdEquipo(Integer idEquipo) { 
    this.idEquipo = idEquipo; 
} 

public String getNombre() { 
    return nombre; 
} 

public void setNombre(String nombre) { 
    this.nombre = nombre; 
} 

public Sexos getIdSexo() { 
    return idSexo; 
} 

public void setIdSexo(Sexos idSexo) { 
    this.idSexo = idSexo; 
} 

public Collection<Jugadores> getJugadoresCollection() { 
    return jugadoresCollection; 
} 

public void setJugadoresCollection(Collection<Jugadores> jugadoresCollection) { 
    this.jugadoresCollection = jugadoresCollection; 
} 

public Collection<EquiposPorCampeonato> getEquiposPorCampeonatoCollection() { 
    return equiposPorCampeonatoCollection; 
} 

public void setEquiposPorCampeonatoCollection(Collection<EquiposPorCampeonato> equiposPorCampeonatoCollection) { 
    this.equiposPorCampeonatoCollection = equiposPorCampeonatoCollection; 
} 

@Override 
public int hashCode() { 
    int hash = 0; 
    hash += (idEquipo != null ? idEquipo.hashCode() : 0); 
    return hash; 
} 

@Override 
public boolean equals(Object object) { 
    // TODO: Warning - this method won't work in the case the id fields are not set 
    if (!(object instanceof Equipos)) { 
     return false; 
    } 
    Equipos other = (Equipos) object; 
    if ((this.idEquipo == null && other.idEquipo != null) || (this.idEquipo != null && !this.idEquipo.equals(other.idEquipo))) { 
     return false; 
    } 
    return true; 
} 

@Override 
public String toString() { 
    return "" + nombre + ""; 
} 

} 

可用表脚本


非常感谢你。
是的,它的西班牙语请忍受我!
Equipos == Teams;
Partidos ==匹配;
Campeonatos ==锦标赛;

回答

2

这个异常与视图相关,而不是模型。唯一的例外是在告诉你已经设置组件ID和值partidosPK.idEquipo类似如下:

<h:someComponent id="partidosPK.idEquipo"> 

然而,这个ID是按照规则合法。它包含一个点.。将其删除或更换为_-。规则与HTML/CSS identifiers相同。

在CSS中,标识符(包括元素名,类和在选择器的ID)只能包含字符[A-ZA-Z0-9]和ISO 10646个字符U + 00A1和更高的,再加上连字符( - )和下划线(_);他们不能以数字或连字符后跟数字开头。

+0

组件重装和工作流畅谢谢youuu – 2010-09-26 15:28:37

相关问题