managed-bean

ManagedProperty not injected in @FacesConverter

雨燕双飞 提交于 2019-11-27 11:21:48
问题 I'm trying to inject a ManagedBean in my FacesConverted the following way: @ManagedBean @RequestScoped @FacesConverter(forClass = Group.class) public class GroupConverter implements Converter { @ManagedProperty("#{groupService}") private GroupService groupService; @Override public Group getAsObject(FacesContext context, UIComponent arg1, String groupName) { return groupService.findGroupByName(groupName); } @Override public String getAsString(FacesContext arg0, UIComponent arg1, Object group)

How to get managedbean property from another bean in JSF

不打扰是莪最后的温柔 提交于 2019-11-27 10:57:10
问题 I searched similar questions but I'm a bit confused. I have a login page, so LoginBean also which is; @ManagedBean(name = "loginBean") @SessionScoped public class LoginBean implements Serializable { private String password=""; private String image=""; @ManagedProperty(value = "#{loginBeanIdentityNr}") private String identityNr=""; ... after success, navigates to orderlist page, so I have also OrderBean. @ManagedBean(name = "OrderBean") @SessionScoped public class OrderBean { List<Ordery>

How can I get a message bundle string from inside a managed bean?

。_饼干妹妹 提交于 2019-11-27 07:26:25
I would like to be able to retrieve a string from a message bundle from inside a JSF 2 managed bean. This would be done in situations where the string is used as the summary or details parameter in a FacesMessage or as the message in a thrown exception. I want to make sure that the managed bean loads the correct message bundle for the user's locale. It is not clear to me how to do this from a managed bean using JSF API calls. My configuration is: Using Tomcat 7 as the container so the solution cannot depend on API calls that only work in a full application server container Using the JSF 2

how is the @RequestScoped bean instance provided to @SessionScoped bean in runtime here?

跟風遠走 提交于 2019-11-27 06:54:47
问题 I am reading through this example in JBoss where a @RequestScoped bean backing up JSF page is used to pass the user credential information which is then saved in a @sessionScoped bean . Here is the example take from JBoss docs. @Named @RequestScoped public class Credentials { private String username; private String password; @NotNull @Length(min=3, max=25) public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } @NotNull @Length

Difference between managed bean and backing bean

夙愿已清 提交于 2019-11-27 06:43:24
I came across the terms "managed bean" and "backing bean" in several forums. Many people think both are the same. But, there seems to be a slight difference. Can any one help me to understand the exact difference between these two terms? Changing my initial answer - there is no meaningful difference between the two. The tutorial says that backing beans are later declared as managed beans. So, to summarize: a backing bean is the class out of context a managed bean is the backing bean whenever it is declared to be used with the JSF managed bean facility. I've never actually used the term

Concurrency of @ApplicationScoped JSF managed beans

旧时模样 提交于 2019-11-27 06:17:54
问题 I'm using Mojarra 2.2.12 and in our project we've got a few @ApplicationScoped beans. For instance: @ManagedBean @ApplicationScoped public class AppScopedBean{ private int commonValueForClients; //GET, SET public void evalNew(){ int newCommonVal; //Evaluation of the new value, doesn't depend on the commonValueForClients commonValueForClients = newCommonVal; } } My question is should we worry about visibility of the new assigned value? I couldn't find in the spec that JSF infrastructure must

JSF does not populate @Named @RequestScoped bean with submitted input values

你离开我真会死。 提交于 2019-11-27 05:30:54
this is my first question in this beautiful site. I have googled a lot but I didn't find any solution. I'm new to JSF and I'm learning it with "JSF 2 APIs and JBoss Seam" by Kent Ka lok Tong. Now I have a problem with a simple login implementation. I have a login page: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Login</title> </h:head> <h:body> <h1>Login</h1> <h:messages for=

JSF 1.2: How to keep request scoped managed bean alive across postbacks on same view?

时光毁灭记忆、已成空白 提交于 2019-11-27 04:51:57
Is it possible to keep a request scoped bean alive across postbacks on the same page? The general problem is, as the bean gets trashed on end of request and recreated on every form submit, for example the booleans behind dynamically manipulated disabled , readonly and rendered get reset to their default values and cause the forms to not work as intented anymore. BalusC I'll assume that the session scope is not an option, otherwise this question makes little sense. You can do it using Tomahawk <t:saveState> . Add the following line somewhere to the page: <t:saveState value="#{bean}" />

NullPointerException while trying to access @Inject bean in constructor

爱⌒轻易说出口 提交于 2019-11-27 01:38:16
I've a session scoped bean: @Named @SessionScoped public class SessionBean implements Serializable { private String someProperty; public String getSomeProperty() { return someProperty; } } I'd like to inject this in a request scoped bean and initialize with it: @Named @RequestScoped public class RequestBean { @Inject private SessionBean sessionBean; public RequestBean() { System.out.println(sessionBean.getProperty()); } } However, it throws the following exception: java.lang.NullPointerException at com.example.RequestBean.<init>(RequestBean.java:42) at sun.reflect.NativeConstructorAccessorImpl

How to reference JSF managed beans which are provided in a JAR file?

▼魔方 西西 提交于 2019-11-27 01:04:47
I have a WAR file with the following structure: The JSF managed bean BusinessObjectTypeListController is located in commons-web-1.0.jar in /WEB-INF/lib and referenced in BusinessObjectTypeListView.xhtml . When I run my web application and I call that view, I get the following error: javax.servlet.ServletException: /view/common/businessObjectTypeListView.xhtml @34,94 listener="#{businessObjectTypeListController.selectData}": Target Unreachable, identifier 'businessObjectTypeListController' resolved to null Why isn't the controller class found? It should be in the classpath, is it? You need to