managed-bean

@ManagedProperty with request parameter not set in a @Named bean

て烟熏妆下的殇ゞ 提交于 2019-11-30 05:15:00
问题 I've a CDI managed bean wherein I'd like to set request parameters as managed properties: import javax.inject.Named; import javax.enterprise.context.RequestScoped; @Named @RequestScoped public class ActivationBean implements Serializable { @ManagedProperty(value="#{param.key}") private String key; @ManagedProperty(value="#{param.id}") private Long id; // Getters+setters The URL is domain/activate.jsf?key=98664defdb2a4f46a527043c451c3fcd&id=5 , however the properties are never set and remain

Error : non-serializable attribute value into ViewMap

不打扰是莪最后的温柔 提交于 2019-11-30 04:43:43
问题 i have the same application in 2 systems(laptops) but its working in one but not in another.i get the following error in another system. i have also posted the code below.what i want to do is cascading dropdown with a button that calls method of a different managed bean, and a placeOrder button to add a record in database.but i get the following error at the time of page loading WARNING: Setting non-serializable attribute value into ViewMap: (key: stockOrderBean, value class: beans

How to redirect from a ManagedBean for when the request sent is an Ajax request?

Deadly 提交于 2019-11-30 02:27:08
I am using PrimeFaces with JSF2. I am trying to authenticate user by sending login and password as an Ajax request. And in the action method of the backing bean, I am trying to validate user and redirect to a new view if the validation succeeds. Is this possible while using primefaces? Because I think with primefaces' p:commandButton , I can only either have ajax behavior or the navigation. Yes, just send a redirect instead of a (default) forward as outcome. The <navigation-case> -less JSF 2.0 way would be appending ?faces-redirect=true to the outcome string in the action method. E.g. public

JSF page redirecting from java bean

天大地大妈咪最大 提交于 2019-11-29 23:40:58
Is there some way how to redirect page to other page from Java method? I'm able only to forward it using: FacesContext.getCurrentInstance().getExternalContext().dispatch("/foo.xhtml"); or using navigation-rules of faces-config.xml . Do you have any ideas? Not sure what you're after, but the ExternalContext#dispatch() does only a forward, not a redirect. You'd like to use ExternalContext#redirect() instead. externalContext.redirect("foo.xhtml"); or even external (which is not possible with dispatch) externalContext.redirect("http://stackoverflow.com"); You'd normally like to do this in bean's

Canonical way to obtain CDI managed bean instance: BeanManager#getReference() vs Context#get()

点点圈 提交于 2019-11-29 20:36:09
I figured that there are two general ways to obtain an auto-created CDI managed bean instance via BeanManager when having solely a Bean<T> to start with (which is created based on Class<T> ): By BeanManager#getReference() , which is more often shown in snippets: Bean<TestBean> bean = (Bean<TestBean>) beanManager.resolve(beanManager.getBeans(TestBean.class)); TestBean testBean1 = (TestBean) beanManager.getReference(bean, bean.getBeanClass(), beanManager.createCreationalContext(bean)); By Context#get() , which is less often shown in snippets: Bean<TestBean> bean = (Bean<TestBean>) beanManager

Retrieve the web app root path in JSF Managed Bean

浪尽此生 提交于 2019-11-29 18:49:10
问题 Im trying to access the example/web folder (see below in the image) in a jsf managed bean but cant seem to find a way to do it thx 回答1: If you want to get it as a File for some reason, then you need ExternalContext#getRealPath(). This converts a relative web path to an absolute disk file system. Since you need the web's root folder, just pass in / : String absoluteWebPath = externalContext.getRealPath("/"); File webRoot = new File(absoluteWebPath); // ... Unrelated to the concrete problem,

@ManagedProperty injected AFTER @PostConstruct

蓝咒 提交于 2019-11-29 17:56:35
THIS PROBLEM IS ALREADY SOLVED IN THE MYFACES 2.1 IMPLEMENTATION I have a link which passes an Integer parameter properly like this: <h:link outcome="/process/createProcess"> <f:param name="id" value="#{process.idprocess}" /> Edit </h:link> It goes to "createProcess.xhtml?id=21" properly, and I have this code in the request scope backing Bean createProcess: @ManagedProperty(value="#{param.id}") private Integer idProcess; private Process newProcess; @PostConstruct public void init() { log(); if (idProcess!=null) newProcess = Dao.getProcessDAO().get(idProcess); else newProcess = new Process(); }

com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean

时光怂恿深爱的人放手 提交于 2019-11-29 17:26:36
问题 I have a JSF managedbean I am getting the error when a managed bean is referred from from JSF page in WebSphere AppServer. <h:inputText value=#{bean}/> The bean is defined in the faces-config.xml as <managed-bean> <managed-bean-name>bean</managed-bean-name> <managed-bean-class>com.test.Bean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> This is the exception: com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource

Access session scoped JSF managed bean in web filter

随声附和 提交于 2019-11-29 16:57:17
问题 I have SessionScoped bean called userSession to keep track of the user ( username, ifLogged, etc). I want to filter some pages and therefore I need to access the bean from the webFilter I created. How do I do that? I looks like its even impossible to import the bean to be potenitally visible. 回答1: Under the covers, JSF stores session scoped managed beans as an attribute of the HttpSession with the managed bean name as key. So, provided that you've a @ManagedBean @SessionScoped public class

Are there going to be two instances for a bean if I write @managed bean annotation and define same in faces-config.xml

a 夏天 提交于 2019-11-29 15:38:03
In my application in some places we are using @ManagedBean annoation for Person bean and for the same Person bean we defining in the faces-confing.xml like below at the same time. @ManagedBean("name=person") @SessionScoped Public class Person{ } faces-config.xml <managed-bean> <managed-bean-name>person</managed-bean-name> <managed-bean-class>com.test.sample.Person</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> my question is does this approach create two instances for the Person bean or it does matter if I do this? Does this have any effect on performance