as don't have experience in javaee programming , hasve noone ask, ask you. have 1 thing in code don't , think it's implemented in wrong way. managed bean request scoped. in jsf use rich:picklist takes data list.
@scope("request") public class mybean{ private list<string> sourcelist; .... public list<string> getsourcelist() { //if (sourcelist == null) <--- has no sence in request scoped bean { sourcelist = service.loadlist(); } return sourcelist; } .... } i have submit button store data.
the problem is, each time when page actions (e.g. clicking submit button) method invoked every time , goes service layer, dao , database. seems not correct solution. how avoid it? thanks' answers.
if you're on jsf 2.0, can use new view scope @viewscoped.
@managedbean @viewscoped public class bean { private list<foo> foos; @ejb private fooservice fooservice; @postconstruct public void init() { foos = fooservice.list(); } public list<foo> getfoos() { return foos; } } when you're still on jsf 1.x, it's know richfaces' <a4j:keepalive> , tomahawk's <t:savestate> have same effect on request scoped bean above code design (i.e. not load data in getter):
<a4j:keepalive beanname="#{bean}" /> and
<t:savestate beanname="#{bean}" /> i haven't used new richfaces' @keepalive annotation, concerning docs, should behave same well.
Comments
Post a Comment