Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Class as attribute of another class, displaying values  RSS feed

 
Adela Simion
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I'm new in JSF. I have two java classes mapped with JPA (so I have the corresponding tables in the DB) called Student and Classes. The important thing about that is that "Student " has the attribute "Classes" inside, to reference it.
When I run the xhtml that displays details of the Student , I would like to view the corresponding class of each one (his idClasa attribute), but I can't make it work, it don't display me anything.

I'm posting you the code (just the useful things, if I forgot something tell me, please):






And I want to show class in a combobox based on idStudent ( that will be disabled at navigation and enabled at add)



I'm a beginner in that stuff and I don't understand general explanation.
I searched but I don't find something that can help me.
 
Tim Holloway
Bartender
Posts: 18709
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Adela!

Your sample looks a little strange. As I interpret it, you're looking to generate a list that would have OPTION elements something like this:


Where the first column is student ID (not displayed) and the second column is the label that displays in the dropdown list.

I doubt that that is what you are looking for, since the user's view of the data would be ambiguous.

A more common case would be where the student had a 1-to-many class relationship (1 or more classes per term) or there was a many-to-many student/class relationship (since classes would contain more than one student).

So it seems like maybe your JPA definitions are at fault.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!