java - Sort/Filter dynamically generated column of <p:dataTable> -


i facing problem filter/sort column role(lazy datamodel) of datatable not property of entity class , because column value created dynamically dependent on user logged in ,the logged in user may user rows,manager rows.

for example have entity class activity 2 properties of entity class :

@javax.persistence.entity @table(name = "activity") public class activity extends entity { private set<user> users; private set<user> managers; } 

if logged in user in managers particular activity row, role(column not in activity entity) of row manager. if logged in user in users particular activity row, role of row user. how can implemented ? can me? pointer helpful me.thanks

update-1: role column value display corrently. in entity class calculate role way:

@transient public string getrole(){     string role="";     //calculate role depending on currettly logged in user..     return role; } 

now when going filter , exception generated:

error [com.edfx.adb.web.model.activitydatamodel] null: org.hibernate.queryexception: not resolve property: role of: com.edfx.adb.persist.entity.activity 

how overcome this?

update-2

activitydao class :

public list<activity> loadactivities(int startindex, int maxresult, string sortfield, boolean sortorder, map<string, object> filters) {     criteria criteria = getsessionfactory().getcurrentsession().createcriteria(entityclass, "act");     createactivitiesfiltercriteria(criteria, filters);     return (list<activity>) criteria.list(); } private void createactivitiesfiltercriteria(criteria criteria, map<string, object> filters) {   httpsession session = (httpsession)  facescontext.getcurrentinstance().getexternalcontext().getsession(true);   string username = session.getattribute("username").tostring();    if(filters.containskey("role")){   string value = (string) filters.get("role");   if(!value.equals("all")){     criteria.add(restrictions.eq("getrole();", value));     }   filters.remove("role");   }   (entry<string, object> entry : filters.entryset()) {   string key = entry.getkey();   object value = entry.getvalue();    criteria.add(restrictions.ilike(key, value.tostring(), matchmode.anywhere));   } } 

activitydatamodel's code:

@override public list<activitydto> load(int first, int pagesize, string sortfield, sortorder sortorder, map<string, string> filters) {     map<string, object> daofilters = new hashmap<string, object>();     map<string, object> totalfilters = new hashmap<string, object>(daofilters);      try {         activitydtos = activityservice.loadactivities(first, pagesize, sortfield, order, daofilters);         setrowcount(activityservice.gettotalnooffilteredactivity(totalfilters));         } catch (throwable throwable) {     } return activitydtos; } 


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -