こんにちは、私は JSF が初めてで、少し迷っています。これは私がやりたいことです。すべてのショーに表現のリストがあるショーのリストを表示するページがあります。ユーザーが特定の番組をクリックして、その番組にリンクされた表現のみが表示されるページに移動するようにします。これが現在の .xhtml ページと 2 つのマネージド Bean です。彼らが現在行っていることは、すべてのショーとすべてのリストを表示することです。
@Entity
@Table(name = "SHOW_SPECTACLE")
public class Spectacle implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;
@ElementCollection
@CollectionTable(name = "T_TYPES_SPECTACLE")
@Column(name = "TYPES_SPECTACLE")
private List<String> typesSpectacle;
@Column(name = "NOM_SPECTACLE")
private String nomSpectacle;
@Column(name = "DESCRIPTION")
private String description;
@Column(name = "LIEN_VIDEO")
private String lienVideo; // type Blop
@Column(name = "LIEN_IMAGE")
private String lienImage;
@OneToOne
private Artiste artiste;
@OneToMany(mappedBy = "spectacle")
private List<Representation> representations;
}
public class Representation implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;
@Column(name = "NB_BILLETS_DISPO")
private Integer nbBilletsDispo;
@Column(name = "PRIX")
private Float prix;
@Column(name = "NOM")
private String nom;
@Column(name = "ADRESSE")
private String adresse;
@Column(name = "DATE_DEBUT")
@Temporal(TemporalType.DATE)
private Date dateDebut;
@Column(name = "DATE_FIN")
@Temporal(TemporalType.DATE)
private Date dateFin;
@Column(name = "IS_ANNULATION")
private Boolean isAnnulation;
@OneToOne(mappedBy = "representation")
private Salle salle;
@ManyToOne
private Spectacle spectacle;
}
すべてのショーを表示する xhtml ページ セクション。いくつかのプライムフェイス コンポーネントを使用します。
<h:form id="form">
<p:dataGrid var="spec" value="#{menuCtrl.spectacles}" columns="3"
rows="12" paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="9,12,15">
<p:panel header="#{spec.nomSpectacle}" style="text-align:center">
<h:panelGrid columns="1" style="width:100%">
<ui:param name="imgPath" value="images:#{spec.artiste.lienPhoto}.png" />
<p:graphicImage value="#{resource[imgPath]}" />
<h:outputText value="#{spec.description}" />
<!-- <p:commandLink update=":form:carDetail" oncomplete="carDialog.show()" title="View Detail">
<h:outputText styleClass="ui-icon ui-icon-search" style="margin:0 auto;" />
<f:setPropertyActionListener value="{spec}"
target="{tableBean.selectedCar}" />
</p:commandLink> -->
</h:panelGrid>
</p:panel>
</p:dataGrid>
</h:form>
編集ここで使用されるBeanです
@ManagedBean(name = "menuCtrl")
@ApplicationScoped
public class MenuControleur extends AbstractControleur implements Serializable {
private static final Logger log = Logger.getLogger(ApplicationControleur.class);
// cache
private List<Spectacle> spectacles;
private List<Representation> representations;
private List<Artiste> artistes;
private List<Representation> representationsFiltrees;
@PostConstruct
public void init() {
// instanciation couche [métier]
super.initStubsPresentation();
this.spectacles = this.stubsDaoPresentation.getAllSpectacle();
this.representations = this.stubsDaoPresentation.getAllRepresentation();
this.artistes = this.stubsDaoPresentation.getAllArtistes();
log.info("sonar source Spectacle 1: " + this.spectacles);
log.info("sonar source Representation 1: " + this.representations);
log.info("sonar source Artiste 1: " + this.artistes);
}
public List<Representation> getRepresentationsFiltrees() {
return representationsFiltrees;
}
public void setRepresentationsFiltrees(List<Representation> representationsFiltrees) {
this.representationsFiltrees = representationsFiltrees;
}
public String doHomme(){
return "eticket.index";
}
public String doCart(){
return "eticket.pageCart";
}
public String doShow(){
return "eticket.pageShows";
}
/**
* Creates a new instance of MenuControleur
*/
public MenuControleur() { }
public List<Spectacle> getSpectacles() {
return spectacles;
}
public void setSpectacles(List<Spectacle> spectacles) {
this.spectacles = spectacles;
}
public List<Representation> getRepresentations() {
return representations;
}
public void setRepresentations(List<Representation> representations) {
this.representations = representations;
}
public List<Artiste> getArtistes() {
return artistes;
}
public void setArtistes(List<Artiste> artistes) {
this.artistes = artistes;
}
}