A generic JSF 2 problem
hantsy Mar 14, 2012 6:00 AMI have some entities are inhretance relation...
There is a Company and Agent, agent is extened from Company which has a List<Agent> relatedAgents.
@OneToMany(mappedBy = "parentAgent") private List<Agent> relatedAgents = new ArrayList<Agent>();
In the Company edit page(wich is also designed to be used to edit Agent), I added extre fields in the Agent. I use ui:fragment to differenate Company and Agent(of course the backend entity is different fro different parameter).
it should be not rendered at the runtime.
But when I enter the Company edit page.
I got an error.
Caused by: javax.el.PropertyNotFoundException: /directory/includes/companyAgentEdit.xhtml @39,59 value="#{companyEdit.currentCompany.relatedAgents}": The class 'com.skolarikos.model.Company' does not have the property 'relatedAgents'. at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:104) [jsf-impl-2.0.2-b10.jar:2.0.2-FCS] at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final] at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:181) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final] at org.richfaces.component.UISequence.getValue(UISequence.java:179) [richfaces-components-ui-4.2.0.Final.jar:] at org.richfaces.component.UISequence.createExtendedDataModel(UISequence.java:113) [richfaces-components-ui-4.2.0.Final.jar:] at org.richfaces.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:466) [richfaces-components-ui-4.2.0.Final.jar:] at org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:279) [richfaces-components-ui-4.2.0.Final.jar:] at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1306) [richfaces-components-ui-4.2.0.Final.jar:] at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final] at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final] at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:163) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
This fragment are wrapped within ui:fragment.
<ui:fragment | |||||
rendered="#{companyEdit.entityType ne null and companyEdit.entityType eq 'Agent'}"> | |||||
<ui:include src="/directory/includes/companyAgentEdit.xhtml" /> | |||||
</ui:fragment> |
The final page rendered correctly, the agent related fields are not rendered in the edit page for a Company entity.
1. Bug why I got the error, Is there some guide for this problem.
2. Another cases in application, Yacht, Ship are extended from Vessel, they also have some specific generic fields(NOT associations), they worked well as expected.
Any help here?
Thanks.