Recently I did [CRUD Enterprise Application in NetBeans][1.] I made my own scenario for it namely storing scores for player. I have tree tables player, game and playerGame table. Every thing works fine with player and game table (add, remove, edit) as in tutorial form youtube but, I have problem with linked table (playerGame). When I try generate JSF Form From Entity using netBeans Palette I am getting this code
<h:selectOneMenu id="fkGameId" value="#{controller.playerGame.fkGameId}" title="FkGameId" required="true" requiredMessage="The FkGameId field is required.">
<!-- TODO: update below reference to list of available items-->
<f:selectItems value="#{fixme}"/>
</h:selectOneMenu>
Also I have tried this
<h:selectOneMenu id="fkPlayerId" value="#{controller.player.playerId}" title="FkPlayerId" required="true" requiredMessage="The FkPlayerId field is required.">
<!-- TODO: update below reference to list of available items-->
<f:selectItems value="#{controller.player.playerGameList}"/>
</h:selectOneMenu>
but with no result
in place where foreign keys to playerId and gameId should be inputed by palette.
My question is what I have to do to fix this, it would be nice to see similar example on linked tables but I didn't found anything (only one simple table examples I have found) I am newbie in JavaEE and this was my first tutorial ever in this subject and to be honest I don't know how to name thing properly.
Also trying to find the solution for the problem I did JavaServer Faces tutorial form netbeans website Generating JSF CRUD Application form Databases. The tutorial was pretty straight forward and I had no problem with it and it works fine with the same scenario (I was able to select foreign keys form dropdown list and create playerGame record). I have tried solve this problem based on JSF pages form this tutorial but the pages are generated using netBeans command JSF Pages form Entity Classes I because I have no experience in Java EE like mentioned before I have failed to solve the problem.
P.S. I you need me to provide more information please just ask.
UPDATE:
It is partially working now thanks to Geinmachi
Partial SOLUTION:
In my controller class I have added
private String playerList;
public String getPlayerList() {
return playerList;
}
public void setPlayerList(String playerList) {
this.playerList = playerList;
}
private List<Player> playerLists;
public List<Player> getPlayerLists() {
return playerLists;
}
public void setPlayerLists(List<Player> playerLists) {
this.playerLists = playerLists;
}
@PostConstruct
public void init(){
playerLists = playerFacade.findAll();
// playerLists = new ArrayList<>();
// playerLists.add( new Player(player.getPlayerId()));
}
public void submit(){
System.out.println("Selected Player: " + playerList);
}
and my jsf code looks like
<h:selectOneMenu value="#{controller.playerList}">
<f:selectItem itemValue="#{null}" itemLabel="#{player.playerName}"/>
<f:selectItems value="#{controller.playerLists}" var="player" itemValue="#{player.playerId}" itemLabel="#{player.playerName}"/>
</h:selectOneMenu>
the was found in one of links given by Geinmachi.
However now I am getting javax.ejb.EJBException: Transaction aborted
when trying to insert data to database because partial solution doesn't get fk_game_id.