managed-bean

Passing parameters between managed beans with request scope

落爺英雄遲暮 提交于 2019-11-27 23:20:53
Im working on a web application using JSF2 . I want to pass parameters from a managed bean in backing bean action and I want to retrive the same parametrs in an other managed bean the both with a request scope. Thanks in advance. Use <f:param> in the command link/button and use @ManagedProperty or <f:viewParam> in the target bean or view. E.g. <h:commandButton value="Submit" action="#{otherBean.submit}"> <f:param name="foo" value="#{oneBean.foo}" /> </h:commandButton> with in OtherBean @ManagedProperty("#{param.foo}") private String foo; // ... 来源: https://stackoverflow.com/questions/9701590

Getting selected value of a SelectOneMenu

…衆ロ難τιáo~ 提交于 2019-11-27 22:30:15
问题 I'm testing the component "SelectOneMenu" on a jsf page. I'm populating this component dinamically though my ManageBean (that will get all Animals from database). I would like to know if is possible to see the user selected item of that "SelectOneMenu" (combobox), I'm trying with value="#{animalsManage.animalSelect}" but it is only called on the beginning of the page. Also, I'm using an inputText to see the value of the selected intem of the "SelectOneMenu". What I'm doing wrong? JSF: <body>

Java EE 6: Target Unreachable, identifier 'helloBean' resolved to null [duplicate]

走远了吗. 提交于 2019-11-27 22:05:54
This question already has an answer here: Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable 13 answers I am trying to get a simple JSF 2 tutorial example to work. I am using the dynamic web project in Eclipse and publishing to a Glassfish 3 server (run -> run on server). The first index.xhtml page loads correctly, but when I have to access a managed bean, the following error displays: /index.xhtml @14,48 value="#{helloBean.name}": Target Unreachable, identifier 'helloBean' resolved to null I've had a look at the various other discussions on this topic, however the

JSF bean: call @PostConstruct function after ViewParam is set

烂漫一生 提交于 2019-11-27 21:45:43
问题 I have a product.xhtml and a ProductBean. I use /product/{id} to access the products so I have a viewParam in product.xhtml with value=ProductBean.id. The problem is that inside the bean I use an init function with a PostConstruct annotation in order to fill the details of the product. To do this I need the id to call an external function. I guess though that init is called before viewParam sets the id of the bean and therefore inside init I cannot call the external function because id is not

Calling Primefaces dialog box from Managed Bean function

a 夏天 提交于 2019-11-27 18:48:05
Hi I have a managed bean with some functions , based on some condition in that function I will like to call a dialog box Managed bean function goes as public String editStudent(){ setReadOnly(false); setButton(true, true, true, false, true, true,true); LockItem lItem; if(selectStudent !=null){ lItem = (LockItem) services.getbyId("LockItem", condition); if (lItem == null){ System.out.println("Student Avalibale for process :::"); studentRedirect(); return "studentEdit.jsf?faces-redirect=true"; } else { //To show dialog from here System.out.println("Student Not Avalibale : Locked By " + lItem

Inject EJB bean from JSF managed bean programmatically

可紊 提交于 2019-11-27 18:29:27
问题 I have EJB stateless bean. How can I inject it to JSF managed bean by programmatic instead of @EJB annotation? 回答1: You can't inject it programmatically. You can however obtain it programmatically. EJBs are also available via JNDI. Usually, you find those JNDI names/aliases printed in server startup log. At least JBoss / WildFly does that. There are different JNDI name aliases: java:global/APP_NAME[/MODULE_NAME]/EJB_NAME java:app/MODULE_NAME/EJB_NAME java:module/EJB_NAME Where /APP_NAME is

Binding a managed bean instance to composite component

柔情痞子 提交于 2019-11-27 15:51:19
I have a composite component (collapsiblePanel). The component uses the "collapsible" bean to provide the toggle function. When I use the same component multiple times on a page, each instance of the component is bound to the same bean instance. How Can I achieve something like a component scoped bean? collapsibleTemp.xhtml : <cc:interface> <cc:attribute name="model" required="true"> <cc:attribute name="collapsed" required="true" /> <cc:attribute name="toggle" required="true" method-signature="java.lang.String f()" /> </cc:attribute> <cc:actionSource name="toggle" /> <cc:facet name="header" />

How to invoke a managed bean action method in on* attribute of a JSF component

佐手、 提交于 2019-11-27 15:25:31
I'd like to invoke a managed bean action method in an on* attribute. In my particular case I need to logout an user if the user is idle for 3 minutes as below: <p:idleMonitor onidle="#{mybean.processTimeOut()}" timeout="180000" /> However, the managed bean action method is immediately invoked as the page loads. How is this caused and how can I solve it? BalusC Like as all other on* attributes on all JSF components, the onidle attribute must represent a JavaScript callback , not a JSF backing bean action method. Any EL expressions in on* attributes would be evaluated immediately as String value

Target Unreachable, identifier resolved to null in JSF 2.2 [duplicate]

醉酒当歌 提交于 2019-11-27 13:00:57
问题 This question already has an answer here: Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable 14 answers I have a problem with JSF 2.2 and CDI, my managerbean is not solved and this error appear "value="#{userBean.user.name}": Target Unreachable, identifier 'userBean' resolved to null" This is my manager bean. @ManagedBean @RequestScoped public class UserBean implements Serializable { private User user; public void setUser(user) { this.user = user; } ... } My view

what to use, managed beans (backing beans) or entity beans?

懵懂的女人 提交于 2019-11-27 12:53:01
I see a lot of examples marking beans as entity beans (@Entity) & named beans (CDI), so as to avoid creating 2 classes (managed bean & entity bean) and also to make use of Bean Validation so that validation can be performed on both client & server. So should I be using a single class or not, are there any issues or should I be having my managed beans or service layer create entity beans using the data from managed beans ? Arjan Tijms The @Named or @ManagedBean annotations are typically used to let the bean container (CDI/JSF) create an instance of a bean on demand when referenced by expression