I have a userManagement.xhtml file name as UserManagement in my portlet and I have included 3 more xhtml files in different panels
my userManagement.xhtmlpage is basically like this
<h:form>
<p:panel rendered="#{userManagement.condition}">
<ui:include src="userTable.xhtml"/>
</p:panel>
<p:panel rendered="#{userManagement.condition}"/>
<ui:include src="userDetails.xhtml"/>
</p:panel>
<p:panel rendered="#{userManagement.condition}"/>
<ui:include src="userActivity.xhtml"/>
</p:panel>
</h:form>
Based on rendering condition I use to show one of the 3 xhtml file(panel) to user.
For managing these I have 1 managed bean name as UserManagement.java. There are 3 more files for other 3 xhtml file.
I tried to make UserTable.java, UserDetails.java and userActivity.java but I am getting
com.example.useroperations.UserTable cannot be cast to javax.faces.component.UIComponent
Right now I am using this as a normal java class by creating object and using it in UserManagement.java. But I would like to make it managed bean.
My Java code is like this UserManagement.java
@ManagedBean
@ViewScoped
class UsermanageMent{
private UserTable userTable;
public void showUserTable(){
this.userTable = new UserTable("some param");
...
...
}
public void setUserTable(UserTable userTable){
this.userTable = userTable
}
public getUserTable(){
return this.userTable();
}
}
UserTable.java
@ManagedBean
@ViewScoped
public UserTable{
......
......
public UserTable(String param){
......
this.retrieveListOfUser(param);
}
public void retrieveListOfUser(String param){
......
......
SomeOtherClass obj = new SomeOtherClass();
obj.retrieve(); // This is for DB call
}
}
Cause of this problem is my datatable binding #{userTable} and my managed bean UserTable which will be same #{userTable}.
Due to this I was getting
com.example.useroperations.UserTable cannot be cast to javax.faces.component.UIComponent
I just changed my dataTable binding as #{userDataTable}. And after that it worked. :)