I have a Customer table (id, name, surname, email etc.) in a many to many relationship with a Characteristic table (just an id an a name). When I click on the Edit button in the Customer page, sometimes the result is an empty window.
Glassfish throws this error:
javax.el.PropertyNotFoundException: /WEB-INF/include/entity/customer/Edit.xhtml @30,95 > value="#{customerController.selected.id.name}": The class 'java.lang.Long' does not have the property 'name'.
I just created two tables with information from what I read in your post, and the generator did not create such an EL expression in the Edit.xhtml of the Customer entity. Does this happen randomly?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've attached a zip file with three classes: Customer2, which extends the abstract class EndUser2, and Characteristic, which is in a Many-To-Many relationship with Customer2.
So I generate the PrimeFaces CRUD pages and test them. First I add some Characteristics in the Characterstic2 page and then I add one or more Customers in the Customer2 page.
Then, if I select a customer and click on edit, an empty edit window will appear. in Customer2's Edit.xhtml, on line 30, I have this:
After making this correction the Edit window works.
I've found another minor aesthetic annoyance in View.xhtml: the h:selectManyMenu shows a single line. p:selectManyMenu is better, because it adapt it's height to the number of the contained relationship elements. It's possible to customize which elements will be generated?
Ok, I see it now. That's strange. I have to do some debugging. This tool relies a lot on internal APIs from NetBeans. I hope this doesn't happen on their end. I'll report back once I know more.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Alright, so I removed the @GeneratedValue annotation from EndUser2 and regenerated the pages. I wanted to compare Create.xhtml with Edit.xhtml. If a field has auto-generated values, the generator will skip such a field in Create.xhtml. To my surprise, Create.xhtml has the correct line:
So it seems as if the template file for Edit.xhtml has something bad in it. That said, I'm comparing both templates and they seem identical in how they refer to the field name. I'm baffled!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ahhh wait, I had a brain fart there. They are not the same. The other one is a <p:outputText>. And I think I know where this is coming from. This has something to do with the function that checks for those artifact words. I'm debugging...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, Schifazl:
I know why it behaves the way it does. There are a few lines in Edit.xhtml that I'm not sure why I had put them in there, especially on the primary key field. I am removing them in the next release. If you don't want to wait for the next release, you can edit the template yourself. The lines affected are lines 88-92. Change this:
The point of relationLabelName is to find a display field for a related entity when there is one-to-many relationship. This is particularly useful on the List.xhtml and on the View.xhtml. Why I had added this particular logic on the Edit.xhtml and especially on the primary key field, I don't remember. I may have simply copied the code because the primary key field is an output field, but didn't think it through.
If you make these changes to your template, make sure to remove the template file from your home directory once the new release is installed. Ok?
Please give me some feedback if it worked for you.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your help, tomorrow I'll try! Sorry for the stupid question, but how can I modify the template? In the "New PrimeFaces Pages and Classes" wizard there is a "Customize Template" text that seems a link, but nothing happens when I click it. Or should I modify the CRUD Generator's sources?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am actually removing that link because it seems redundant and, as you mentioned, doesn't work. Instead, go to Tools->Templates and find PrimeFaces CRUD Generator in the list. The templates are another level below that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey Schifazl, you may want to hold off with the edit and simply download the new version I just uploaded. It's version 0.19 and takes care of your problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a Customer table (id, name, surname, email etc.) in a many to many relationship with a Characteristic table (just an id an a name). When I click on the Edit button in the Customer page, sometimes the result is an empty window.
Glassfish throws this error:
So i have to change this:
to this:
Apparently PF CRUD appends the ".name" randomly and apparently not in the Create.xhtml pages.
Thanks :)
Last edit: schifazl 2013-11-05
Hm. Can you provide me with the actual schema for this example so I can generate the pages? And some sample data would be good too.
I just created two tables with information from what I read in your post, and the generator did not create such an EL expression in the Edit.xhtml of the Customer entity. Does this happen randomly?
Yes, it seems that this happens randomly. Today I'll prepare the schema you've asked yesterday.
I've attached a zip file with three classes: Customer2, which extends the abstract class EndUser2, and Characteristic, which is in a Many-To-Many relationship with Customer2.
So I generate the PrimeFaces CRUD pages and test them. First I add some Characteristics in the Characterstic2 page and then I add one or more Customers in the Customer2 page.
Then, if I select a customer and click on edit, an empty edit window will appear. in Customer2's Edit.xhtml, on line 30, I have this:
... which is obviously wrong and should be:
After making this correction the Edit window works.
I've found another minor aesthetic annoyance in View.xhtml: the h:selectManyMenu shows a single line. p:selectManyMenu is better, because it adapt it's height to the number of the contained relationship elements. It's possible to customize which elements will be generated?
Thanks for your time!
Ok, I see it now. That's strange. I have to do some debugging. This tool relies a lot on internal APIs from NetBeans. I hope this doesn't happen on their end. I'll report back once I know more.
Alright, so I removed the
@GeneratedValueannotation fromEndUser2and regenerated the pages. I wanted to compare Create.xhtml with Edit.xhtml. If a field has auto-generated values, the generator will skip such a field in Create.xhtml. To my surprise, Create.xhtml has the correct line:So it seems as if the template file for Edit.xhtml has something bad in it. That said, I'm comparing both templates and they seem identical in how they refer to the field name. I'm baffled!
Ahhh wait, I had a brain fart there. They are not the same. The other one is a
<p:outputText>. And I think I know where this is coming from. This has something to do with the function that checks for those artifact words. I'm debugging...Ok, Schifazl:
I know why it behaves the way it does. There are a few lines in Edit.xhtml that I'm not sure why I had put them in there, especially on the primary key field. I am removing them in the next release. If you don't want to wait for the next release, you can edit the template yourself. The lines affected are lines 88-92. Change this:
to this:
The point of
relationLabelNameis to find a display field for a related entity when there is one-to-many relationship. This is particularly useful on theList.xhtmland on theView.xhtml. Why I had added this particular logic on theEdit.xhtmland especially on the primary key field, I don't remember. I may have simply copied the code because the primary key field is an output field, but didn't think it through.If you make these changes to your template, make sure to remove the template file from your home directory once the new release is installed. Ok?
Please give me some feedback if it worked for you.
Thank you for your help, tomorrow I'll try! Sorry for the stupid question, but how can I modify the template? In the "New PrimeFaces Pages and Classes" wizard there is a "Customize Template" text that seems a link, but nothing happens when I click it. Or should I modify the CRUD Generator's sources?
I am actually removing that link because it seems redundant and, as you mentioned, doesn't work. Instead, go to Tools->Templates and find PrimeFaces CRUD Generator in the list. The templates are another level below that.
Awesome! Tomorrow I'll let you know :)
Hey Schifazl, you may want to hold off with the edit and simply download the new version I just uploaded. It's version 0.19 and takes care of your problem.
Well done, everything works as expected now!