5
Good evening, I have the following problem... at first it seems kind of silly, but honestly I can’t get out of it
I want to create a table where the columns are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday respectively... and in these columns are shown the data, these data have as attribute the day of the week in question, what would be the best way then to make them appear in the table in the correct column...
<p:dataTable id="tbl"
value="#{bean.registros}"
var="registro" emptyMessage="Nenhum registro">
<p:column headerText="DOMINGO">
</p:column>
<p:column headerText="TERÇA-FEIRA">
</p:column>
<p:column headerText="QUARTA-FEIRA">
</p:column>
e assim vai...
see, each record contained in the "records" list has an attribute called a day, which is an Enum with the day of the respective week, persist, edit etc., everything is working normally, the problem is that I do not know how to make the records containing the day = MONDAY appear only in the correct column...
in other words I have a list of objects to be shown in a data table where in each column should be listed objects that have an attribute x (an Enum that represents the day of the week)
I tried to make a logic with rendered, but besides thinking it was too "gambiarra", it was not good, causing several other problems...
Someone with some good idea ?
It seems to me that you are using the wrong approach. Creating seven columns, each for a day of the week sounds very strange to me. I would create a table
DIA_DA_SEMANA
with the seven days and would make an N-N relationship of your table of records with the table of days of the week.– Victor Stafusa
Good evening @Victor, thanks for the reply but I could not understand, I would like to explain a little this reasoning ?
– Bruno Santana
Ah, sorry. I’m the one who got it wrong. When you refer to "table" I was thinking of table in database, not table in JSF or HTML.
– Victor Stafusa